Sfoglia il codice sorgente

* removed systems_need_16_byte_stack_alignment and use target_info.stackalign instead

git-svn-id: trunk@22279 -
Jonas Maebe 13 anni fa
parent
commit
b1dc518ac4
4 ha cambiato i file con 9 aggiunte e 18 eliminazioni
  1. 3 3
      compiler/i386/cgcpu.pas
  2. 3 1
      compiler/i386/cpupi.pas
  3. 0 11
      compiler/systems.pas
  4. 3 3
      compiler/x86/cgx86.pas

+ 3 - 3
compiler/i386/cgcpu.pas

@@ -303,13 +303,13 @@ unit cgcpu;
             if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
               begin
                 stacksize:=current_procinfo.calc_stackframe_size;
-                if (target_info.system in [system_i386_darwin,system_i386_iphonesim]) and
+                if (target_info.stackalign>4) and
                    ((stacksize <> 0) or
                     (pi_do_call in current_procinfo.flags) or
                     { can't detect if a call in this case -> use nostackframe }
                     { if you (think you) know what you are doing              }
                     (po_assembler in current_procinfo.procdef.procoptions)) then
-                  stacksize := align(stacksize+sizeof(aint),16) - sizeof(aint);
+                  stacksize := align(stacksize+sizeof(aint),target_info.stackalign) - sizeof(aint);
                 if (stacksize<>0) then
                   cg.a_op_const_reg(list,OP_ADD,OS_ADDR,stacksize,current_procinfo.framepointer);
               end
@@ -321,7 +321,7 @@ unit cgcpu;
         { return from proc }
         if (po_interrupt in current_procinfo.procdef.procoptions) and
            { this messes up stack alignment }
-           not(target_info.system in [system_i386_darwin,system_i386_iphonesim]) then
+           (target_info.stackalign=4) then
           begin
             if assigned(current_procinfo.procdef.funcretloc[calleeside].location) and
                (current_procinfo.procdef.funcretloc[calleeside].location^.loc=LOC_REGISTER) then

+ 3 - 1
compiler/i386/cpupi.pas

@@ -76,9 +76,11 @@ unit cpupi;
       begin
         { align to 4 bytes at least
           otherwise all those subl $2,%esp are meaningless PM }
-        if not(target_info.system in [system_i386_darwin,system_i386_iphonesim]) then
+        if target_info.stackalign<=4 then
           result:=Align(tg.direction*tg.lasttemp,min(current_settings.alignment.localalignmax,4))
         else
+          { aligned during stack frame allocation, because also depends number
+            of saved registers }
           result:=tg.direction*tg.lasttemp+maxpushedparasize;
       end;
 

+ 0 - 11
compiler/systems.pas

@@ -312,17 +312,6 @@ interface
        systems_interrupt_table = [{system_arm_embedded}];
        {$endif FPC_HAS_SYSTEMS_INTERRUPT_TABLE}
 
-       { all systems for which istack must be at a 16 byte boundary
-         when calling a function }
-       systems_need_16_byte_stack_alignment = [
-      	system_i386_darwin,
-      	system_i386_iphonesim,
-        system_x86_64_darwin,
-        system_x86_64_win64,
-        system_x86_64_linux,
-        system_x86_64_freebsd,
-        system_x86_64_solaris];
-
        { all systems that use garbage collection for reference-counted types }
        systems_garbage_collected_managed_types = [
          system_jvm_java32,

+ 3 - 3
compiler/x86/cgx86.pas

@@ -2216,13 +2216,13 @@ unit cgx86;
 
             { allocate stackframe space }
             if (localsize<>0) or
-               ((target_info.system in systems_need_16_byte_stack_alignment) and
+               ((target_info.stackalign>sizeof(pint)) and
                 (stackmisalignment <> 0) and
                 ((pi_do_call in current_procinfo.flags) or
                  (po_assembler in current_procinfo.procdef.procoptions))) then
               begin
-                if (target_info.system in systems_need_16_byte_stack_alignment) then
-                  localsize := align(localsize+stackmisalignment,16)-stackmisalignment;
+                if target_info.stackalign>sizeof(pint) then
+                  localsize := align(localsize+stackmisalignment,target_info.stackalign)-stackmisalignment;
                 cg.g_stackpointer_alloc(list,localsize);
                 if current_procinfo.framepointer=NR_STACK_POINTER_REG then
                   current_asmdata.asmcfi.cfa_def_cfa_offset(list,localsize+sizeof(pint));