Browse Source

* factored out inserting a single bss symbol in ngenutil so it can be
overridden by the llvm target
* override a bunch of other ngenutil methods with empty stubs for things
that are not yet supported when targeting llvm

git-svn-id: branches/hlcgllvm@26051 -

Jonas Maebe 11 years ago
parent
commit
aa5823a454
3 changed files with 146 additions and 21 deletions
  1. 1 0
      .gitattributes
  2. 114 0
      compiler/llvm/nllvmutil.pas
  3. 31 21
      compiler/ngenutil.pas

+ 1 - 0
.gitattributes

@@ -327,6 +327,7 @@ compiler/llvm/nllvmadd.pas svneol=native#text/plain
 compiler/llvm/nllvmcon.pas svneol=native#text/plain
 compiler/llvm/nllvmcon.pas svneol=native#text/plain
 compiler/llvm/nllvmld.pas svneol=native#text/plain
 compiler/llvm/nllvmld.pas svneol=native#text/plain
 compiler/llvm/nllvmmem.pas svneol=native#text/plain
 compiler/llvm/nllvmmem.pas svneol=native#text/plain
+compiler/llvm/nllvmutil.pas svneol=native#text/plain
 compiler/llvm/rgllvm.pas svneol=native#text/plain
 compiler/llvm/rgllvm.pas svneol=native#text/plain
 compiler/llvm/tgllvm.pas svneol=native#text/plain
 compiler/llvm/tgllvm.pas svneol=native#text/plain
 compiler/m68k/aasmcpu.pas svneol=native#text/plain
 compiler/m68k/aasmcpu.pas svneol=native#text/plain

+ 114 - 0
compiler/llvm/nllvmutil.pas

@@ -0,0 +1,114 @@
+{
+    Copyright (c) 20011 by Jonas Maebe
+
+    LLVM version of some node tree helper routines
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit nllvmutil;
+
+{$i fpcdefs.inc}
+
+interface
+
+  uses
+    globtype,
+    aasmdata,ngenutil,
+    symtype,symconst,symsym,symdef;
+
+
+  type
+    tllvmnodeutils = class(tnodeutils)
+     strict protected
+      class procedure insertbsssym(list: tasmlist; sym: tstaticvarsym; size: asizeint); override;
+     public
+      class procedure InsertInitFinalTable; override;
+      class procedure InsertThreadvarTablesTable; override;
+      class procedure InsertThreadvars; override;
+      class procedure InsertWideInitsTablesTable; override;
+      class procedure InsertWideInits; override;
+      class procedure InsertResourceTablesTable; override;
+      class procedure InsertResourceInfo(ResourcesUsed : boolean); override;
+      class procedure InsertMemorySizes; override;
+    end;
+
+
+implementation
+
+    uses
+      verbose,cutils,globals,fmodule,
+      aasmtai,cpubase,llvmbase,aasmllvm,
+      symbase,symtable,defutil;
+
+  class procedure tllvmnodeutils.insertbsssym(list: tasmlist; sym: tstaticvarsym; size: asizeint);
+    begin
+      list.concat(taillvmvarsym.Create(sym));
+    end;
+
+
+  class procedure tllvmnodeutils.InsertInitFinalTable;
+    begin
+      { todo }
+    end;
+
+
+  class procedure tllvmnodeutils.InsertThreadvarTablesTable;
+    begin
+      { not yet supported }
+    end;
+
+
+  class procedure tllvmnodeutils.InsertThreadvars;
+    begin
+      { not yet supported }
+    end;
+
+
+  class procedure tllvmnodeutils.InsertWideInitsTablesTable;
+    begin
+      { not required }
+    end;
+
+
+  class procedure tllvmnodeutils.InsertWideInits;
+    begin
+      { not required }
+    end;
+
+
+  class procedure tllvmnodeutils.InsertResourceTablesTable;
+    begin
+      { not supported }
+    end;
+
+
+  class procedure tllvmnodeutils.InsertResourceInfo(ResourcesUsed: boolean);
+    begin
+      { not supported }
+    end;
+
+
+  class procedure tllvmnodeutils.InsertMemorySizes;
+    begin
+      { not required }
+    end;
+
+
+begin
+  cnodeutils:=tllvmnodeutils;
+end.
+

+ 31 - 21
compiler/ngenutil.pas

@@ -27,7 +27,8 @@ unit ngenutil;
 interface
 interface
 
 
   uses
   uses
-    cclasses,
+    cclasses,globtype,
+    aasmdata,
     node,nbas,symtype,symsym,symconst,symdef;
     node,nbas,symtype,symsym,symconst,symdef;
 
 
 
 
@@ -68,6 +69,9 @@ interface
       { trashing for differently sized variables that those handled by
       { trashing for differently sized variables that those handled by
         trash_small() }
         trash_small() }
       class procedure trash_large(var stat: tstatementnode; trashn, sizen: tnode; trashintval: int64); virtual;
       class procedure trash_large(var stat: tstatementnode; trashn, sizen: tnode; trashintval: int64); virtual;
+      { insert a single bss sym, called by insert bssdata (factored out
+        non-common part for llvm) }
+      class procedure insertbsssym(list: tasmlist; sym: tstaticvarsym; size: asizeint); virtual;
      public
      public
       class procedure insertbssdata(sym : tstaticvarsym); virtual;
       class procedure insertbssdata(sym : tstaticvarsym); virtual;
 
 
@@ -100,9 +104,9 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      verbose,version,globtype,globals,cutils,constexp,
+      verbose,version,globals,cutils,constexp,
       scanner,systems,procinfo,fmodule,
       scanner,systems,procinfo,fmodule,
-      aasmbase,aasmdata,aasmtai,
+      aasmbase,aasmtai,
       symbase,symtable,defutil,
       symbase,symtable,defutil,
       nadd,ncal,ncnv,ncon,nflw,ninl,nld,nmem,nobj,nutils,
       nadd,ncal,ncnv,ncon,nflw,ninl,nld,nmem,nobj,nutils,
       ppu,
       ppu,
@@ -457,6 +461,29 @@ implementation
     end;
     end;
 
 
 
 
+  class procedure tnodeutils.insertbsssym(list: tasmlist; sym: tstaticvarsym; size: asizeint);
+    begin
+      if sym.globalasmsym then
+        begin
+          { on AIX/stabx, we cannot generate debug information that encodes
+            the address of a global symbol, you need a symbol with the same
+            name as the identifier -> create an extra *local* symbol.
+            Moreover, such a local symbol will be removed if it's not
+            referenced anywhere, so also create a reference }
+          if (target_dbg.id=dbg_stabx) and
+             (cs_debuginfo in current_settings.moduleswitches) and
+             not assigned(current_asmdata.GetAsmSymbol(sym.name)) then
+            begin
+              list.concat(tai_symbol.Create(current_asmdata.DefineAsmSymbol(sym.name,AB_LOCAL,AT_DATA),0));
+              list.concat(tai_directive.Create(asd_reference,sym.name));
+            end;
+          list.concat(Tai_datablock.create_global(sym.mangledname,size));
+        end
+      else
+        list.concat(Tai_datablock.create(sym.mangledname,size));
+    end;
+
+
   class procedure tnodeutils.insertbssdata(sym: tstaticvarsym);
   class procedure tnodeutils.insertbssdata(sym: tstaticvarsym);
     var
     var
       l : asizeint;
       l : asizeint;
@@ -504,24 +531,7 @@ implementation
         new_section(list,sec_user,sym.section,varalign)
         new_section(list,sec_user,sym.section,varalign)
       else
       else
         new_section(list,sectype,lower(sym.mangledname),varalign);
         new_section(list,sectype,lower(sym.mangledname),varalign);
-      if sym.globalasmsym then
-        begin
-          { on AIX/stabx, we cannot generate debug information that encodes
-            the address of a global symbol, you need a symbol with the same
-            name as the identifier -> create an extra *local* symbol.
-            Moreover, such a local symbol will be removed if it's not
-            referenced anywhere, so also create a reference }
-          if (target_dbg.id=dbg_stabx) and
-             (cs_debuginfo in current_settings.moduleswitches) and
-             not assigned(current_asmdata.GetAsmSymbol(sym.name)) then
-            begin
-              list.concat(tai_symbol.Create(current_asmdata.DefineAsmSymbol(sym.name,AB_LOCAL,AT_DATA),0));
-              list.concat(tai_directive.Create(asd_reference,sym.name));
-            end;
-          list.concat(Tai_datablock.create_global(sym.mangledname,l));
-        end
-      else
-        list.concat(Tai_datablock.create(sym.mangledname,l));
+      insertbsssym(list,sym,l);
       current_filepos:=storefilepos;
       current_filepos:=storefilepos;
     end;
     end;