Ver Fonte

Add dwarf CFI for 32-bit powerpc cpu

(cherry picked from commit b8036f717365c837e2181932b9ba571ebf16f123)
Pierre Muller há 1 ano atrás
pai
commit
8ed9c79c23
1 ficheiros alterados com 20 adições e 2 exclusões
  1. 20 2
      compiler/powerpc/cgcpu.pas

+ 20 - 2
compiler/powerpc/cgcpu.pas

@@ -776,6 +776,8 @@ const
 
 
      var regcounter,firstregfpu,firstregint: TSuperRegister;
      var regcounter,firstregfpu,firstregint: TSuperRegister;
          href : treference;
          href : treference;
+	 aoffset : aint;
+	 reg : tregister;
          usesfpr,usesgpr : boolean;
          usesfpr,usesgpr : boolean;
 
 
       begin
       begin
@@ -809,6 +811,7 @@ const
                     reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV,ctempposinvalid,4,[]);
                     reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV,ctempposinvalid,4,[]);
                 end;
                 end;
                 list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
                 list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
+                current_asmdata.asmcfi.cfa_offset(list, NR_R0, href.offset);
                 if not(cs_profile in current_settings.moduleswitches) then
                 if not(cs_profile in current_settings.moduleswitches) then
                   a_reg_dealloc(list,NR_R0);
                   a_reg_dealloc(list,NR_R0);
               end;
               end;
@@ -834,13 +837,16 @@ const
              if tcpuprocinfo(current_procinfo).needs_frame_pointer then
              if tcpuprocinfo(current_procinfo).needs_frame_pointer then
                list.concat(taicpu.op_reg_reg(A_MR,NR_OLD_STACK_POINTER_REG,NR_STACK_POINTER_REG));
                list.concat(taicpu.op_reg_reg(A_MR,NR_OLD_STACK_POINTER_REG,NR_STACK_POINTER_REG));
           end;
           end;
+        current_asmdata.asmcfi.cfa_def_cfa_register(list,NR_FRAME_POINTER_REG);
 
 
         if usesfpr then
         if usesfpr then
           begin
           begin
              reference_reset_base(href,NR_R1,-8,ctempposinvalid,8,[]);
              reference_reset_base(href,NR_R1,-8,ctempposinvalid,8,[]);
              for regcounter:=firstregfpu to RS_F31 do
              for regcounter:=firstregfpu to RS_F31 do
                begin
                begin
-                 a_loadfpu_reg_ref(list,OS_F64,OS_F64,newreg(R_FPUREGISTER,regcounter,R_SUBNONE),href);
+                 reg:=newreg(R_FPUREGISTER,regcounter,R_SUBNONE);
+                 a_loadfpu_reg_ref(list,OS_F64,OS_F64,reg,href);
+                 current_asmdata.asmcfi.cfa_offset(list, reg, href.offset);
                  dec(href.offset,8);
                  dec(href.offset,8);
                end;
                end;
              { compute start of gpr save area }
              { compute start of gpr save area }
@@ -859,13 +865,22 @@ const
                 (firstregint <= RS_R29)) then
                 (firstregint <= RS_R29)) then
               begin
               begin
                 { TODO: TODO: 64 bit support }
                 { TODO: TODO: 64 bit support }
+                aoffset:=href.offset;
                 dec(href.offset,(RS_R31-firstregint)*sizeof(pint));
                 dec(href.offset,(RS_R31-firstregint)*sizeof(pint));
                 list.concat(taicpu.op_reg_ref(A_STMW,newreg(R_INTREGISTER,firstregint,R_SUBNONE),href));
                 list.concat(taicpu.op_reg_ref(A_STMW,newreg(R_INTREGISTER,firstregint,R_SUBNONE),href));
+                for regcounter:=firstregint to RS_R31 do
+                  begin
+                    reg:=newreg(R_INTREGISTER,regcounter,R_SUBNONE);
+                    current_asmdata.asmcfi.cfa_offset(list, reg, aoffset);
+                    dec(aoffset,4);
+		  end;
               end
               end
             else
             else
               for regcounter:=firstregint to RS_R31 do
               for regcounter:=firstregint to RS_R31 do
                 begin
                 begin
-                  a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter,R_SUBNONE),href);
+                  reg:=newreg(R_INTREGISTER,regcounter,R_SUBNONE);
+                  a_load_reg_ref(list,OS_INT,OS_INT,reg,href);
+                  current_asmdata.asmcfi.cfa_offset(list, reg, href.offset);
                   dec(href.offset,4);
                   dec(href.offset,4);
                 end;
                 end;
           end;
           end;
@@ -883,6 +898,7 @@ const
               begin
               begin
                 reference_reset_base(href,NR_STACK_POINTER_REG,-localsize,ctempposinvalid,8,[]);
                 reference_reset_base(href,NR_STACK_POINTER_REG,-localsize,ctempposinvalid,8,[]);
                 a_load_store(list,A_STWU,NR_STACK_POINTER_REG,href);
                 a_load_store(list,A_STWU,NR_STACK_POINTER_REG,href);
+                current_asmdata.asmcfi.cfa_def_cfa_offset(list,localsize);
               end
               end
             else
             else
               begin
               begin
@@ -901,6 +917,7 @@ const
                 else
                 else
                   list.concat(taicpu.op_reg_reg_const(A_ORIS,NR_R0,NR_R0,word(((-localsize) shr 16) and $ffff)));
                   list.concat(taicpu.op_reg_reg_const(A_ORIS,NR_R0,NR_R0,word(((-localsize) shr 16) and $ffff)));
                 a_load_store(list,A_STWUX,NR_STACK_POINTER_REG,href);
                 a_load_store(list,A_STWUX,NR_STACK_POINTER_REG,href);
+                current_asmdata.asmcfi.cfa_def_cfa_offset(list,localsize);
                 a_reg_dealloc(list,href.index);
                 a_reg_dealloc(list,href.index);
               end;
               end;
           end;
           end;
@@ -911,6 +928,7 @@ const
           begin
           begin
             reference_reset_base(href,NR_STACK_POINTER_REG,get_rtoc_offset,ctempposinvalid,target_info.stackalign,[]);
             reference_reset_base(href,NR_STACK_POINTER_REG,get_rtoc_offset,ctempposinvalid,target_info.stackalign,[]);
             a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_RTOC,href);
             a_load_reg_ref(list,OS_ADDR,OS_ADDR,NR_RTOC,href);
+            current_asmdata.asmcfi.cfa_offset(list, NR_RTOC, href.offset);
           end;
           end;
 
 
         { save the CR if/when we ever start using caller-save portions of that
         { save the CR if/when we ever start using caller-save portions of that