Pārlūkot izejas kodu

+ initial native x86-64 support

git-svn-id: branches/debug_eh@41499 -
florian 6 gadi atpakaļ
vecāks
revīzija
ded001753d

+ 5 - 3
compiler/psabiehpi.pas

@@ -716,12 +716,14 @@ implementation
           begin
             typeindex:=(current_procinfo as tpsabiehprocinfo).CurrentAction.AddAction(excepttype);
             current_asmdata.getjumplabel(catchstartlab);
-{$ifdef i386}
+{$if defined(i386)}
             hlcg.a_cmp_const_reg_label (list,osuinttype,OC_EQ,typeindex+1,NR_FUNCTION_RESULT64_HIGH_REG,catchstartlab);
-{$else i386}
+{$elseif defined(x86_64)}
+            hlcg.a_cmp_const_reg_label (list,osuinttype,OC_EQ,typeindex+1,NR_RDX,catchstartlab);
+{$else}
             { we need to find a way to fix this in a generic way }
             Internalerror(2019021008);
-{$endif i386}
+{$endif}
             hlcg.a_jmp_always(list,nextonlabel);
             hlcg.a_label(list,catchstartlab);
           end

+ 5 - 1
compiler/systems/i_linux.pas

@@ -389,7 +389,11 @@ unit i_linux;
 {$endif tls_threadvars}
                             tf_library_needs_pic,tf_needs_symbol_type,tf_files_case_sensitive,
                             tf_has_winlike_resources,tf_safecall_exceptions,tf_safecall_clearstack
-                            {$ifdef llvm},tf_use_psabieh{$endif}];
+                            {$ifdef llvm},tf_use_psabieh{$endif}
+{$ifdef psabieh}
+                            ,tf_use_psabieh
+{$endif psabieh}
+                            ];
             cpu          : cpu_x86_64;
             unit_env     : 'LINUXUNITS';
             extradefines : 'UNIX;HASUNIX';

+ 15 - 2
compiler/x86_64/cgcpu.pas

@@ -145,6 +145,7 @@ unit cgcpu;
       var
         hitem: tlinkedlistitem;
         seh_proc: tai_seh_directive;
+        regsize: longint;
         r: integer;
         href: treference;
         templist: TAsmList;
@@ -169,17 +170,28 @@ unit cgcpu;
         var
           r: longint;
           usedregs: tcpuregisterset;
+          hreg: TRegister;
         begin
           usedregs:=rg[R_INTREGISTER].used_in_proc-paramanager.get_volatile_registers_int(current_procinfo.procdef.proccalloption);
           for r := low(regs_to_save_int) to high(regs_to_save_int) do
             if regs_to_save_int[r] in usedregs then
               begin
-                inc(stackmisalignment,sizeof(pint));
+                inc(regsize,sizeof(aint));
+                inc(stackmisalignment,sizeof(aint));
                 push_one_reg(newreg(R_INTREGISTER,regs_to_save_int[r],R_SUBWHOLE));
+                hreg:=newreg(R_INTREGISTER,regs_to_save_int[r],R_SUBWHOLE);
+                if current_procinfo.framepointer<>NR_STACK_POINTER_REG then
+                  current_asmdata.asmcfi.cfa_offset(list,hreg,-(regsize+sizeof(pint)*2+localsize))
+                else
+                  begin
+                    current_asmdata.asmcfi.cfa_offset(list,hreg,-(regsize+sizeof(pint)+localsize));
+                    current_asmdata.asmcfi.cfa_def_cfa_offset(list,regsize+localsize+sizeof(pint));
+                  end;
               end;
         end;
 
       begin
+        regsize:=0;
         regs_to_save_int:=paramanager.get_saved_registers_int(current_procinfo.procdef.proccalloption);
         regs_to_save_mm:=paramanager.get_saved_registers_mm(current_procinfo.procdef.proccalloption);
         hitem:=list.last;
@@ -248,7 +260,7 @@ unit cgcpu;
                   localsize := align(localsize+stackmisalignment,target_info.stackalign)-stackmisalignment;
                 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));
+                  current_asmdata.asmcfi.cfa_def_cfa_offset(list,regsize+localsize+sizeof(pint));
                 current_procinfo.final_localsize:=localsize;
                 if (target_info.system=system_x86_64_win64) then
                   begin
@@ -376,6 +388,7 @@ unit cgcpu;
 
                 if (current_procinfo.procdef.proctypeoption=potype_exceptfilter) then
                   list.concat(Taicpu.op_reg(A_POP,tcgsize2opsize[OS_ADDR],NR_FRAME_POINTER_REG));
+                current_asmdata.asmcfi.cfa_def_cfa_offset(list,sizeof(pint));
               end
             else if (target_info.system=system_x86_64_win64) then
               begin

+ 4 - 2
compiler/x86_64/cpupi.pas

@@ -29,10 +29,12 @@ interface
 
     uses
        globtype,
-       psub,procinfo,aasmbase,aasmdata;
+       psub,
+       procinfo,psabiehpi,
+       aasmbase,aasmdata;
 
     type
-       tcpuprocinfo = class(tcgprocinfo)
+       tcpuprocinfo = class(tpsabiehprocinfo)
        private
          scopes: TAsmList;
          scopecount: longint;