Переглянути джерело

+ custom section name support for llvm

git-svn-id: trunk@32400 -
Jonas Maebe 9 роки тому
батько
коміт
91e8f4c439
3 змінених файлів з 19 додано та 3 видалено
  1. 10 0
      compiler/llvm/aasmllvm.pas
  2. 7 0
      compiler/llvm/agllvm.pas
  3. 2 3
      compiler/llvm/nllvmtcon.pas

+ 10 - 0
compiler/llvm/aasmllvm.pas

@@ -165,9 +165,11 @@ interface
       sec: TAsmSectiontype;
       sec: TAsmSectiontype;
       alignment: shortint;
       alignment: shortint;
       flags: taillvmdeclflags;
       flags: taillvmdeclflags;
+      secname: TSymStr;
       constructor createdecl(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
       constructor createdecl(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
       constructor createdef(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
       constructor createdef(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
       constructor createtls(_namesym: tasmsymbol; _def: tdef; _alignment: shortint);
       constructor createtls(_namesym: tasmsymbol; _def: tdef; _alignment: shortint);
+      procedure setsecname(const name: TSymStr);
       destructor destroy; override;
       destructor destroy; override;
     end;
     end;
 
 
@@ -221,6 +223,14 @@ uses
       end;
       end;
 
 
 
 
+    procedure taillvmdecl.setsecname(const name: TSymStr);
+      begin
+        if sec<>sec_user then
+          internalerror(2015111501);
+        secname:=name;
+      end;
+
+
     destructor taillvmdecl.destroy;
     destructor taillvmdecl.destroy;
       begin
       begin
         initdata.free;
         initdata.free;

+ 7 - 0
compiler/llvm/agllvm.pas

@@ -1001,6 +1001,13 @@ implementation
                         end;
                         end;
                       dec(fdecllevel);
                       dec(fdecllevel);
                     end;
                     end;
+                  { custom section name? }
+                  if taillvmdecl(hp).sec=sec_user then
+                    begin
+                      writer.AsmWrite(', section "');
+                      writer.AsmWrite(taillvmdecl(hp).secname);
+                      writer.AsmWrite('"');
+                    end;
                   { alignment }
                   { alignment }
                   writer.AsmWrite(', align ');
                   writer.AsmWrite(', align ');
                   writer.AsmWriteln(tostr(taillvmdecl(hp).alignment));
                   writer.AsmWriteln(tostr(taillvmdecl(hp).alignment));

+ 2 - 3
compiler/llvm/nllvmtcon.pas

@@ -162,13 +162,12 @@ implementation
       newasmlist: tasmlist;
       newasmlist: tasmlist;
       decl: taillvmdecl;
       decl: taillvmdecl;
     begin
     begin
-      { todo }
-      if section = sec_user then
-        internalerror(2014052904);
       newasmlist:=tasmlist.create;
       newasmlist:=tasmlist.create;
       { llvm declaration with as initialisation data all the elements from the
       { llvm declaration with as initialisation data all the elements from the
         original asmlist }
         original asmlist }
       decl:=taillvmdecl.createdef(sym,def,fasmlist,section,alignment);
       decl:=taillvmdecl.createdef(sym,def,fasmlist,section,alignment);
+      if section=sec_user then
+        decl.setsecname(secname);
       if tcalo_is_lab in options then
       if tcalo_is_lab in options then
         include(decl.flags,ldf_unnamed_addr);
         include(decl.flags,ldf_unnamed_addr);
       { TODO: tcalo_no_dead_strip: add to @llvm.user meta-variable }
       { TODO: tcalo_no_dead_strip: add to @llvm.user meta-variable }