Browse Source

+ tcalo_apply_constalign option to specify that the alignment should be
modified by applying user alignment settings (so it can be only done for
user-defined data, not not for internally generated data)
o set this option for user-defined data

git-svn-id: trunk@34633 -

Jonas Maebe 9 years ago
parent
commit
9727f289b1
3 changed files with 13 additions and 9 deletions
  1. 8 4
      compiler/aasmcnst.pas
  2. 3 3
      compiler/ncgcon.pas
  3. 2 2
      compiler/ngtcon.pas

+ 8 - 4
compiler/aasmcnst.pas

@@ -132,7 +132,9 @@ type
      { symbol should be registered with the unit's public assembler symbols }
      { symbol should be registered with the unit's public assembler symbols }
      tcalo_is_public_asm,
      tcalo_is_public_asm,
      { symbol should be declared with AT_DATA_FORCEINDIRECT }
      { symbol should be declared with AT_DATA_FORCEINDIRECT }
-     tcalo_data_force_indirect
+     tcalo_data_force_indirect,
+     { apply const_align() to the alignment, for user-defined data }
+     tcalo_apply_constalign
    );
    );
    ttcasmlistoptions = set of ttcasmlistoption;
    ttcasmlistoptions = set of ttcasmlistoption;
 
 
@@ -911,6 +913,8 @@ implementation
      var
      var
        prelist: tasmlist;
        prelist: tasmlist;
      begin
      begin
+       if tcalo_apply_constalign in options then
+         alignment:=const_align(alignment);
        { have we finished all aggregates? }
        { have we finished all aggregates? }
        if (getcurragginfo<>nil) and
        if (getcurragginfo<>nil) and
           { in case of syntax errors, the aggregate may not have been finished }
           { in case of syntax errors, the aggregate may not have been finished }
@@ -937,12 +941,12 @@ implementation
            { we always need a new section here, since if we started a new
            { we always need a new section here, since if we started a new
              object file then we have to say what the section is, and otherwise
              object file then we have to say what the section is, and otherwise
              we need a new section because that's how the dead stripping works }
              we need a new section because that's how the dead stripping works }
-           new_section(prelist,section,secname,const_align(alignment));
+           new_section(prelist,section,secname,alignment);
          end
          end
        else if tcalo_new_section in options then
        else if tcalo_new_section in options then
-         new_section(prelist,section,secname,const_align(alignment))
+         new_section(prelist,section,secname,alignment)
        else
        else
-         prelist.concat(cai_align.Create(const_align(alignment)));
+         prelist.concat(cai_align.Create(alignment));
 
 
        { On Darwin, use .reference to ensure the data doesn't get dead stripped.
        { On Darwin, use .reference to ensure the data doesn't get dead stripped.
          On other platforms, the data must be in the .fpc section (which is
          On other platforms, the data must be in the .fpc section (which is

+ 3 - 3
compiler/ncgcon.pas

@@ -297,7 +297,7 @@ implementation
               { :-(, we must generate a new entry }
               { :-(, we must generate a new entry }
               if not assigned(entry^.Data) then
               if not assigned(entry^.Data) then
                 begin
                 begin
-                  datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
+                  datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable,tcalo_apply_constalign]);
                    case cst_type of
                    case cst_type of
                       cst_ansistring:
                       cst_ansistring:
                         begin
                         begin
@@ -426,7 +426,7 @@ implementation
         current_asmdata.getglobaldatalabel(lab);
         current_asmdata.getglobaldatalabel(lab);
         result:=lab;
         result:=lab;
         lab_set:=lab;
         lab_set:=lab;
-        tcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
+        tcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable,tcalo_apply_constalign]);
         tcb.maybe_begin_aggregate(resultdef);
         tcb.maybe_begin_aggregate(resultdef);
         if (source_info.endian=target_info.endian) then
         if (source_info.endian=target_info.endian) then
           for i:=0 to resultdef.size-1 do
           for i:=0 to resultdef.size-1 do
@@ -534,7 +534,7 @@ implementation
              if not assigned(entry^.Data) then
              if not assigned(entry^.Data) then
                begin
                begin
                  current_asmdata.getglobaldatalabel(lastlabel);
                  current_asmdata.getglobaldatalabel(lastlabel);
-                 datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
+                 datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable,tcalo_apply_constalign]);
                  datatcb.emit_guid_const(value);
                  datatcb.emit_guid_const(value);
                  current_asmdata.asmlists[al_typedconsts].concatList(
                  current_asmdata.asmlists[al_typedconsts].concatList(
                    datatcb.get_final_asmlist(lastlabel,rec_tguid,sec_rodata_norel,lastlabel.name,const_align(16)));
                    datatcb.get_final_asmlist(lastlabel,rec_tguid,sec_rodata_norel,lastlabel.name,const_align(16)));

+ 2 - 2
compiler/ngtcon.pas

@@ -439,7 +439,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
       begin
       begin
         inherited;
         inherited;
         fsym:=sym;
         fsym:=sym;
-        ftcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
+        ftcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable,tcalo_apply_constalign]);
         fdatalist:=tasmlist.create;
         fdatalist:=tasmlist.create;
         curoffset:=0;
         curoffset:=0;
       end;
       end;
@@ -873,7 +873,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                      { create a tcb for the string data (it's placed in a separate
                      { create a tcb for the string data (it's placed in a separate
                        asmlist) }
                        asmlist) }
                      ftcb.start_internal_data_builder(fdatalist,sec_rodata,'',datatcb,ll);
                      ftcb.start_internal_data_builder(fdatalist,sec_rodata,'',datatcb,ll);
-                     datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
+                     datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable,tcalo_apply_constalign]);
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
                      { include terminating #0 }
                      { include terminating #0 }
                      datadef:=carraydef.getreusable(cwidechartype,tstringconstnode(node).len+1);
                      datadef:=carraydef.getreusable(cwidechartype,tstringconstnode(node).len+1);