Просмотр исходного кода

* moved the specification of the options for a ttai_typedconstbuilder from
get_final_asmlist() to the constructor, in preparation of supporting the
creation of internal builders for local data that will ignore some of the
irrelevant flags (at creation time)

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

Jonas Maebe 10 лет назад
Родитель
Сommit
e924dbed90
5 измененных файлов с 48 добавлено и 53 удалено
  1. 16 12
      compiler/aasmcnst.pas
  2. 0 7
      compiler/llvm/nllvmtcon.pas
  3. 4 4
      compiler/ncgcon.pas
  4. 22 24
      compiler/ncgvmt.pas
  5. 6 6
      compiler/ngtcon.pas

+ 16 - 12
compiler/aasmcnst.pas

@@ -170,6 +170,9 @@ type
     protected
      { temporary list in which all data is collected }
      fasmlist: tasmlist;
+     { options for the final asmlist }
+     foptions: ttcasmlistoptions;
+
      { while queueing elements of a compound expression, this is the current
        offset in the top-level array/record }
      fqueue_offset: asizeint;
@@ -198,7 +201,7 @@ type
      { easy access to the top level aggregate information instance }
      property curagginfo: taggregateinformation read getcurragginfo;
     public
-     constructor create; virtual;
+     constructor create(const options: ttcasmlistoptions); virtual;
      destructor destroy; override;
 
      { add a simple constant data element (p) to the typed constant.
@@ -288,7 +291,7 @@ type
        This asmlist will be freed when the builder is destroyed, so add its
        contents to another list first. This property should only be accessed
        once all data has been added. }
-     function get_final_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: longint; const options: ttcasmlistoptions): tasmlist;
+     function get_final_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: longint): tasmlist;
 
      { returns the offset of the string data relative to ansi/unicode/widestring
        constant labels. On most platforms, this is 0 (with the header at a
@@ -696,11 +699,11 @@ implementation
      end;
 
 
-   function ttai_typedconstbuilder.get_final_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: longint; const options: ttcasmlistoptions): tasmlist;
+   function ttai_typedconstbuilder.get_final_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: longint): tasmlist;
      begin
        if not fasmlist_finalized then
          begin
-           finalize_asmlist(sym,def,section,secname,alignment,options);
+           finalize_asmlist(sym,def,section,secname,alignment,foptions);
            fasmlist_finalized:=true;
          end;
        result:=fasmlist;
@@ -750,10 +753,11 @@ implementation
      end;
 
 
-   constructor ttai_typedconstbuilder.create;
+   constructor ttai_typedconstbuilder.create(const options: ttcasmlistoptions);
      begin
        inherited create;
        fasmlist:=tasmlist.create;
+       foptions:=options;
        { queue is empty }
        fqueue_offset:=low(fqueue_offset);
      end;
@@ -952,7 +956,10 @@ implementation
        datatcb: ttai_typedconstbuilder;
        options: ttcasmlistoptions;
      begin
-       datatcb:=self.create;
+       options:=[tcalo_is_lab];
+       if NewSection then
+         include(options,tcalo_new_section);
+       datatcb:=self.create(options);
        result:=datatcb.emit_string_const_common(st_ansistring,len,encoding,startlab);
 
        getmem(s,len+1);
@@ -964,10 +971,7 @@ implementation
        datatcb.emit_tai(tai_string.create_pchar(s,len+1),datadef);
        datatcb.maybe_end_aggregate(datadef);
        ansistrrecdef:=datatcb.end_anonymous_record;
-       options:=[tcalo_is_lab];
-       if NewSection then
-         include(options,tcalo_new_section);
-       list.concatlist(datatcb.get_final_asmlist(startlab,ansistrrecdef,sec_rodata_norel,startlab.name,const_align(sizeof(pint)),options));
+       list.concatlist(datatcb.get_final_asmlist(startlab,ansistrrecdef,sec_rodata_norel,startlab.name,const_align(sizeof(pint))));
        datatcb.free;
      end;
 
@@ -981,7 +985,7 @@ implementation
        uniwidestrrecdef: trecorddef;
        datatcb: ttai_typedconstbuilder;
      begin
-       datatcb:=self.create;
+       datatcb:=self.create([tcalo_is_lab,tcalo_new_section]);
        strlength:=getlengthwidestring(pcompilerwidestring(data));
        if winlike then
          begin
@@ -1020,7 +1024,7 @@ implementation
        else
          { code generation for other sizes must be written }
          internalerror(200904271);
-       list.concatlist(datatcb.get_final_asmlist(startlab,uniwidestrrecdef,sec_rodata_norel,startlab.name,const_align(sizeof(pint)),[tcalo_is_lab,tcalo_new_section]));
+       list.concatlist(datatcb.get_final_asmlist(startlab,uniwidestrrecdef,sec_rodata_norel,startlab.name,const_align(sizeof(pint))));
        datatcb.free;
      end;
 

+ 0 - 7
compiler/llvm/nllvmtcon.pas

@@ -69,7 +69,6 @@ interface
       procedure begin_aggregate_internal(def: tdef; anonymous: boolean); override;
       procedure end_aggregate_internal(def: tdef; anonymous: boolean); override;
      public
-      constructor create; override;
       destructor destroy; override;
       procedure emit_tai_procvar2procdef(p: tai; pvdef: tprocvardef); override;
       procedure emit_string_offset(const ll: tasmlabofs; const strlength: longint; const st: tstringtype; const winlikewidestring: boolean; const charptrdef: tdef); override;
@@ -159,12 +158,6 @@ implementation
     end;
 
 
-  constructor tllvmtai_typedconstbuilder.create;
-    begin
-      inherited create;
-    end;
-
-
   destructor tllvmtai_typedconstbuilder.destroy;
     begin
       inherited destroy;

+ 4 - 4
compiler/ncgcon.pas

@@ -360,7 +360,7 @@ implementation
                         begin
                           current_asmdata.getdatalabel(lastlabel.lab);
 
-                          datatcb:=ctai_typedconstbuilder.create;
+                          datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_new_section]);
                           { truncate strings larger than 255 chars }
                           if len>255 then
                            l:=255
@@ -376,7 +376,7 @@ implementation
                           datatcb.emit_tai(Tai_string.Create_pchar(pc,l+1),datadef);
                           datatcb.maybe_end_aggregate(datadef);
                           current_asmdata.asmlists[al_typedconsts].concatList(
-                            datatcb.get_final_asmlist(lastlabel.lab,datadef,sec_rodata_norel,lastlabel.lab.name,const_align(sizeof(pint)),[tcalo_is_lab,tcalo_new_section])
+                            datatcb.get_final_asmlist(lastlabel.lab,datadef,sec_rodata_norel,lastlabel.lab.name,const_align(sizeof(pint)))
                           );
                           datatcb.free;
                         end;
@@ -384,7 +384,7 @@ implementation
                         begin
                           current_asmdata.getdatalabel(lastlabel.lab);
 
-                          datatcb:=ctai_typedconstbuilder.create;
+                          datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_new_section]);
                           { include terminating zero }
                           getmem(pc,len+1);
                           move(value_str^,pc[0],len);
@@ -398,7 +398,7 @@ implementation
                           datatcb.emit_tai(Tai_string.Create_pchar(pc,len+1),datadef);
                           datatcb.maybe_end_aggregate(datadef);
                           current_asmdata.asmlists[al_typedconsts].concatList(
-                            datatcb.get_final_asmlist(lastlabel.lab,datadef,sec_rodata_norel,lastlabel.lab.name,const_align(sizeof(pint)),[tcalo_is_lab,tcalo_new_section])
+                            datatcb.get_final_asmlist(lastlabel.lab,datadef,sec_rodata_norel,lastlabel.lab.name,const_align(sizeof(pint)))
                           );
                           datatcb.free;
                         end;

+ 22 - 24
compiler/ncgvmt.pas

@@ -238,7 +238,7 @@ implementation
          current_asmdata.getdatalabel(p^.nl);
          if assigned(p^.l) then
            writenames(list,p^.l);
-         tcb:=ctai_typedconstbuilder.create;
+         tcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
          len:=length(p^.data.messageinf.str^);
          tcb.maybe_begin_aggregate(getarraydef(cansichartype,len+1));
          tcb.emit_tai(tai_const.create_8bit(len),cansichartype);
@@ -247,7 +247,7 @@ implementation
          ca[len]:=#0;
          tcb.emit_tai(Tai_string.Create_pchar(ca,len),getarraydef(cansichartype,len));
          tcb.maybe_end_aggregate(getarraydef(cansichartype,len+1));
-         list.concatList(tcb.get_final_asmlist(p^.nl,getarraydef(cansichartype,len+1),sec_rodata_norel,'',sizeof(pint),[tcalo_is_lab]));
+         list.concatList(tcb.get_final_asmlist(p^.nl,getarraydef(cansichartype,len+1),sec_rodata_norel,'',sizeof(pint)));
          tcb.free;
          if assigned(p^.r) then
            writenames(list,p^.r);
@@ -283,7 +283,7 @@ implementation
          { insert all message handlers into a tree, sorted by name }
          _class.symtable.SymList.ForEachCall(@insertmsgstr,@count);
 
-         tcb:=ctai_typedconstbuilder.create;
+         tcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
          { write all names }
          if assigned(root) then
            writenames(list,root);
@@ -312,7 +312,7 @@ implementation
               disposeprocdeftree(root);
            end;
          tcb.maybe_end_aggregate(msgstrtabdef);
-         list.concatList(tcb.get_final_asmlist(result,msgstrtabdef,sec_rodata,'',sizeof(pint),[tcalo_is_lab]));
+         list.concatList(tcb.get_final_asmlist(result,msgstrtabdef,sec_rodata,'',sizeof(pint)));
          tcb.free;
       end;
 
@@ -364,7 +364,7 @@ implementation
              end;
          }
          current_asmdata.getlabel(r,alt_data);
-         tcb:=ctai_typedconstbuilder.create;
+         tcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
          genintmsgtab:=r;
          gettabledef('fpc_msgint_table_entries_',s32inttype,msginttabledef,count,0,msgintdef,msgintarrdef);
          tcb.maybe_begin_aggregate(msgintdef);
@@ -377,7 +377,7 @@ implementation
               disposeprocdeftree(root);
            end;
          tcb.maybe_end_aggregate(msgintdef);
-         list.concatList(tcb.get_final_asmlist(result,msgintdef,sec_rodata,'',sizeof(pint),[tcalo_is_lab]));
+         list.concatList(tcb.get_final_asmlist(result,msgintdef,sec_rodata,'',sizeof(pint)));
          tcb.free;
       end;
 
@@ -514,10 +514,10 @@ implementation
               begin
                 current_asmdata.getlabel(l,alt_data);
                 { l: name_of_method }
-                tcb:=ctai_typedconstbuilder.create;
+                tcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
 
                 namedef:=tcb.emit_shortstring_const(tsym(p).realname);
-                lists^.list.concatList(tcb.get_final_asmlist(l,namedef,sec_rodata_norel,'',sizeof(pint),[tcalo_is_lab]));
+                lists^.list.concatList(tcb.get_final_asmlist(l,namedef,sec_rodata_norel,'',sizeof(pint)));
                 tcb.free;
                 { the tmethodnamerec }
                 lists^.pubmethodstcb.maybe_begin_aggregate(lists^.methodnamerec);
@@ -567,7 +567,7 @@ implementation
                     entries : packed array[0..0] of tmethodnamerec;
                   end;
                }
-              lists.pubmethodstcb:=ctai_typedconstbuilder.create;
+              lists.pubmethodstcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
               current_asmdata.getlabel(l,alt_data);
               gettabledef('fpc_intern_tmethodnametable_',u32inttype,lists.methodnamerec,count,1,pubmethodsdef,pubmethodsarraydef);
               { begin tmethodnametable }
@@ -582,7 +582,7 @@ implementation
               lists.pubmethodstcb.maybe_end_aggregate(pubmethodsarraydef);
               { end methodnametable }
               lists.pubmethodstcb.maybe_end_aggregate(pubmethodsdef);
-              list.concatlist(lists.pubmethodstcb.get_final_asmlist(l,pubmethodsdef,sec_rodata,'',sizeof(pint),[tcalo_is_lab]));
+              list.concatlist(lists.pubmethodstcb.get_final_asmlist(l,pubmethodsdef,sec_rodata,'',sizeof(pint)));
               lists.pubmethodstcb.free;
               genpublishedmethodstable:=l;
            end
@@ -635,7 +635,7 @@ implementation
               packrecords:=1;
 
             { generate the class table }
-            tcb:=ctai_typedconstbuilder.create;
+            tcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
             tcb.begin_anonymous_record('$fpc_intern_classtable_'+tostr(classtablelist.Count-1),packrecords);
             tcb.emit_tai(Tai_const.Create_16bit(classtablelist.count),u16inttype);
             for i:=0 to classtablelist.Count-1 do
@@ -649,7 +649,7 @@ implementation
                   tfieldvarsym(classdef.vmt_field).vardef);
               end;
             classtabledef:=tcb.end_anonymous_record;
-            list.concatlist(tcb.get_final_asmlist(classtable,classtabledef,sec_rodata,'',sizeof(pint),[tcalo_is_lab]));
+            list.concatlist(tcb.get_final_asmlist(classtable,classtabledef,sec_rodata,'',sizeof(pint)));
             tcb.free;
 
             { write fields }
@@ -664,7 +664,7 @@ implementation
                 Fields: array[0..0] of TFieldInfo
               end;
             }
-            tcb:=ctai_typedconstbuilder.create;
+            tcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
             { can't easily specify a name here for reuse of the constructed def,
               since it's full of variable length shortstrings (-> all of those
               lengths and their order would have to incorporated in the name,
@@ -701,7 +701,7 @@ implementation
                   end;
               end;
             fieldtabledef:=tcb.end_anonymous_record;
-            list.concatlist(tcb.get_final_asmlist(fieldtable,fieldtabledef,sec_rodata,'',sizeof(pint),[tcalo_is_lab]));
+            list.concatlist(tcb.get_final_asmlist(fieldtable,fieldtabledef,sec_rodata,'',sizeof(pint)));
             tcb.free;
 
             result:=fieldtable;
@@ -803,7 +803,7 @@ implementation
         interfacearray: tdef;
       begin
         current_asmdata.getlabel(result,alt_data);
-        tcb:=ctai_typedconstbuilder.create;
+        tcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
         tcb.begin_anonymous_record('',0);
         tcb.emit_tai(Tai_const.Create_pint(_class.ImplementedInterfaces.count),search_system_type('SIZEUINT').typedef);
         interfaceentrydef:=search_system_type('TINTERFACEENTRY').typedef;
@@ -818,7 +818,7 @@ implementation
           end;
         tcb.maybe_end_aggregate(interfacearray);
         tabledef:=tcb.end_anonymous_record;
-        list.concatlist(tcb.get_final_asmlist(result,tabledef,sec_rodata,'',tabledef.alignment,[tcalo_is_lab]));
+        list.concatlist(tcb.get_final_asmlist(result,tabledef,sec_rodata,'',tabledef.alignment));
 
         { Write vtbls }
         for i:=0 to _class.ImplementedInterfaces.count-1 do
@@ -894,27 +894,25 @@ implementation
       if assigned(_class.iidguid) then
         begin
           s:=make_mangledname('IID',_class.owner,_class.objname^);
-          tcb:=ctai_typedconstbuilder.create;
+          tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
           tcb.emit_guid_const(_class.iidguid^);
           list.concatlist(tcb.get_final_asmlist(
             current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
             rec_tguid,
             sec_rodata_norel,
             s,
-            const_align(sizeof(pint)),
-            [tcalo_new_section]));
+            const_align(sizeof(pint))));
           tcb.free;
         end;
       s:=make_mangledname('IIDSTR',_class.owner,_class.objname^);
-      tcb:=ctai_typedconstbuilder.create;
+      tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
       def:=tcb.emit_shortstring_const(_class.iidstr^);
       list.concatlist(tcb.get_final_asmlist(
         current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
         def,
         sec_rodata_norel,
         s,
-        sizeof(pint),
-        [tcalo_new_section]));
+        sizeof(pint)));
       tcb.free;
     end;
 
@@ -1058,10 +1056,10 @@ implementation
           begin
             { write class name }
             current_asmdata.getlabel(classnamelabel,alt_data);
-            tcb:=ctai_typedconstbuilder.create;
+            tcb:=ctai_typedconstbuilder.create([tcalo_is_lab]);
             hs:=_class.RttiName;
             classnamedef:=tcb.emit_shortstring_const(_class.RttiName);
-            templist.concatlist(tcb.get_final_asmlist(classnamelabel,classnamedef,sec_rodata_norel,'',sizeof(pint),[tcalo_is_lab]));
+            templist.concatlist(tcb.get_final_asmlist(classnamelabel,classnamedef,sec_rodata_norel,'',sizeof(pint)));
             tcb.free;
 
             { interface table }

+ 6 - 6
compiler/ngtcon.pas

@@ -441,7 +441,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
       begin
         inherited;
         fsym:=sym;
-        ftcb:=ctai_typedconstbuilder.create;
+        ftcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
         fdatalist:=tasmlist.create;
         curoffset:=0;
       end;
@@ -804,7 +804,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
             begin
               { create a tcb for the string data (it's placed in a separate
                 asmlist) }
-              datatcb:=ctai_typedconstbuilder.create;
+              datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_new_section]);
               current_asmdata.getlabel(ll,alt_data);
               if node.nodetype=stringconstn then
                 varalign:=size_2_align(tstringconstnode(node).len)
@@ -838,7 +838,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                   IncompatibleTypes(node.resultdef, def);
                   datadef:=getarraydef(cansichartype,1);
                 end;
-              current_asmdata.asmlists[al_const].concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,varalign,[tcalo_is_lab,tcalo_new_section]));
+              current_asmdata.asmlists[al_const].concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,varalign));
               datatcb.free;
               { we now emit the address of the first element of the array
                 containing the string data }
@@ -865,7 +865,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                    begin
                      { create a tcb for the string data (it's placed in a separate
                        asmlist) }
-                     datatcb:=ctai_typedconstbuilder.create;
+                     datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_new_section]);
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
                      { include terminating #0 }
                      datadef:=getarraydef(cwidechartype,tstringconstnode(node).len+1);
@@ -876,7 +876,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                      datatcb.emit_tai(Tai_const.Create_16bit(0),cwidechartype);
                      datatcb.maybe_end_aggregate(datadef);
                      { concat add the string data to the fdatalist }
-                     fdatalist.concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,const_align(sizeof(pint)),[tcalo_is_lab,tcalo_new_section]));
+                     fdatalist.concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,const_align(sizeof(pint))));
                      datatcb.free;
                      { we now emit the address of the first element of the array
                        containing the string data }
@@ -1102,7 +1102,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
               sec:=sec_data;
             secname:=asmsym.Name;
           end;
-        reslist:=ftcb.get_final_asmlist(asmsym,fsym.vardef,sec,secname,fsym.vardef.alignment,[tcalo_new_section]);
+        reslist:=ftcb.get_final_asmlist(asmsym,fsym.vardef,sec,secname,fsym.vardef.alignment);
         if addstabx then
           begin
             { see same code in ncgutil.insertbssdata }