diff --git a/compiler/pdecvar.pas b/compiler/pdecvar.pas index 7b814cec49..89166a4b59 100644 --- a/compiler/pdecvar.pas +++ b/compiler/pdecvar.pas @@ -1582,7 +1582,8 @@ implementation (32-bit) alignment, in which case the alignment is determined by the alignment of the first field. */ } - if (target_info.abi=abi_powerpc_aix) and + { TODO: check whether this is also for AIX } + if (target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) and is_first_type and (symtablestack.top.symtabletype=recordsymtable) and (trecordsymtable(symtablestack.top).usefieldalignment=C_alignment) then diff --git a/compiler/powerpc/cgcpu.pas b/compiler/powerpc/cgcpu.pas index a6b55c92e1..70d31a1fda 100644 --- a/compiler/powerpc/cgcpu.pas +++ b/compiler/powerpc/cgcpu.pas @@ -802,7 +802,8 @@ const list.concat(taicpu.op_reg(A_MFLR,NR_R0)); { ... in caller's frame } case target_info.abi of - abi_powerpc_aix: + abi_powerpc_aix, + abi_powerpc_darwin: reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_AIX,4); abi_powerpc_sysv: reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV,4); @@ -814,7 +815,7 @@ const (* { save the CR if necessary in callers frame. } - if target_info.abi = abi_powerpc_aix then + if target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin] then if false then { Not needed at the moment. } begin a_reg_alloc(list,NR_R0); @@ -1014,7 +1015,8 @@ const if (pi_do_call in current_procinfo.flags) then begin case target_info.abi of - abi_powerpc_aix: + abi_powerpc_aix, + abi_powerpc_darwin: reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_AIX,4); abi_powerpc_sysv: reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV,4); @@ -1027,7 +1029,7 @@ const (* { restore the CR if necessary from callers frame} - if target_info.abi = abi_powerpc_aix then + if target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin] then if false then { Not needed at the moment. } begin reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX); @@ -1061,7 +1063,8 @@ const begin { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit } case target_info.abi of - abi_powerpc_aix: + abi_powerpc_aix, + abi_powerpc_darwin: firstfpureg := RS_F14; abi_powerpc_sysv: firstfpureg := RS_F9; @@ -1144,7 +1147,8 @@ const begin { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit } case target_info.abi of - abi_powerpc_aix: + abi_powerpc_aix, + abi_powerpc_darwin: firstfpureg := RS_F14; abi_powerpc_sysv: firstfpureg := RS_F9; diff --git a/compiler/powerpc/cpupara.pas b/compiler/powerpc/cpupara.pas index c06ce6d45d..8855333573 100644 --- a/compiler/powerpc/cpupara.pas +++ b/compiler/powerpc/cpupara.pas @@ -69,6 +69,7 @@ unit cpupara; begin case target_info.abi of abi_powerpc_aix, + abi_powerpc_darwin, abi_powerpc_sysv: result := [RS_F0..RS_F13]; else @@ -108,7 +109,7 @@ unit cpupara; begin loc:=LOC_REFERENCE; paraloc^.reference.index:=NR_STACK_POINTER_REG; - if (target_info.abi <> abi_powerpc_aix) then + if not(target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) then reference.offset:=sizeof(pint)*(nr-8) else reference.offset:=sizeof(pint)*(nr); @@ -138,14 +139,14 @@ unit cpupara; classrefdef: result:=LOC_REGISTER; procvardef: - if (target_info.abi = abi_powerpc_aix) or + if (target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) or (p.size = sizeof(pint)) then result:=LOC_REGISTER else result:=LOC_REFERENCE; recorddef: if not(target_info.system in systems_aix) and - ((target_info.abi<>abi_powerpc_aix) or + (not(target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) or ((p.size >= 3) and ((p.size mod 4) <> 0))) then result:=LOC_REFERENCE @@ -209,11 +210,11 @@ unit cpupara; } procvardef : result:= - (target_info.abi <> abi_powerpc_aix) and + not(target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) and (def.size <> sizeof(pint)); recorddef : result := - (target_info.abi<>abi_powerpc_aix) or + not(target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) or ((varspez = vs_const) and ((calloption = pocall_mwpascal) or (not (calloption in [pocall_cdecl,pocall_cppdecl]) and @@ -239,7 +240,8 @@ unit cpupara; procedure tppcparamanager.init_values(var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword); begin case target_info.abi of - abi_powerpc_aix: + abi_powerpc_aix, + abi_powerpc_darwin: cur_stack_offset:=24; abi_powerpc_sysv: cur_stack_offset:=8; @@ -349,7 +351,8 @@ unit cpupara; nextmmreg := curmmreg; stack_offset := cur_stack_offset; case target_info.abi of - abi_powerpc_aix: + abi_powerpc_aix, + abi_powerpc_darwin: maxfpureg := RS_F13; abi_powerpc_sysv: maxfpureg := RS_F8; @@ -394,7 +397,7 @@ unit cpupara; paralen := paradef.size else paralen := tcgsize2size[def_cgsize(paradef)]; - if (target_info.abi = abi_powerpc_aix) and + if (target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) and (paradef.typ = recorddef) and (hp.varspez in [vs_value,vs_const]) then begin @@ -429,7 +432,7 @@ unit cpupara; loc := getparaloc(paradef); if varargsparas and - (target_info.abi = abi_powerpc_aix) and + (target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) and (paradef.typ = floatdef) then begin loc := LOC_REGISTER; @@ -506,7 +509,7 @@ unit cpupara; paraloc^.register:=newreg(R_INTREGISTER,nextintreg,R_SUBNONE); inc(nextintreg); dec(paralen,tcgsize2size[paraloc^.size]); - if target_info.abi=abi_powerpc_aix then + if target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin] then inc(stack_offset,align(tcgsize2size[paraloc^.size],4)); end else if (loc = LOC_FPUREGISTER) and @@ -520,7 +523,7 @@ unit cpupara; dec(paralen,tcgsize2size[paraloc^.size]); { if nextfpureg > maxfpureg, all intregs are already used, since there } { are less of those available for parameter passing in the AIX abi } - if target_info.abi=abi_powerpc_aix then + if target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin] then {$ifndef cpu64bitaddr} if (paracgsize = OS_F32) then begin @@ -584,7 +587,7 @@ unit cpupara; if not((target_info.system in systems_aix) and (paradef.typ=recorddef)) and - (target_info.abi = abi_powerpc_aix) and + (target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) and (hp.paraloc[side].intsize < 3) then paraloc^.reference.offset:=stack_offset+(4-paralen) else @@ -628,7 +631,7 @@ unit cpupara; begin result:=create_paraloc_info_intern(p,callerside,varargspara,curintreg,curfloatreg,curmmreg,cur_stack_offset,true); { varargs routines have to reserve at least 32 bytes for the AIX abi } - if (target_info.abi = abi_powerpc_aix) and + if (target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) and (result < 32) then result := 32; end diff --git a/compiler/powerpc/cpupi.pas b/compiler/powerpc/cpupi.pas index 73f6f4dca2..8e0d7a84d5 100644 --- a/compiler/powerpc/cpupi.pas +++ b/compiler/powerpc/cpupi.pas @@ -83,7 +83,8 @@ unit cpupi; if not(po_assembler in procdef.procoptions) then begin case target_info.abi of - abi_powerpc_aix: + abi_powerpc_aix, + abi_powerpc_darwin: ofs:=maxpushedparasize+LinkageAreaSizeAIX; abi_powerpc_sysv: ofs:=maxpushedparasize+LinkageAreaSizeSYSV; @@ -143,7 +144,8 @@ unit cpupi; first_save_int_reg := 32; { FIXME: has to be R_F14 instead of R_F8 for SYSV-64bit } case target_info.abi of - abi_powerpc_aix: + abi_powerpc_aix, + abi_powerpc_darwin: low_nonvol_fpu_reg := RS_F14; abi_powerpc_sysv: low_nonvol_fpu_reg := RS_F14; @@ -168,7 +170,7 @@ unit cpupi; end; if not(pi_do_call in flags) and (not uses_stack_temps) and - (((target_info.abi = abi_powerpc_aix) and + (((target_info.abi in [abi_powerpc_aix,abi_powerpc_darwin]) and ((32-first_save_int_reg)*4+(32-first_save_fpu_reg)*8 <= 220)) or ((target_info.abi = abi_powerpc_sysv) and (first_save_int_reg + first_save_fpu_reg = 64))) then diff --git a/compiler/systems.inc b/compiler/systems.inc index 10e64990f8..3ec67ff717 100644 --- a/compiler/systems.inc +++ b/compiler/systems.inc @@ -284,7 +284,7 @@ ); tabi = (abi_default - ,abi_powerpc_sysv,abi_powerpc_aix,abi_powerpc_elfv2 + ,abi_powerpc_sysv,abi_powerpc_aix,abi_powerpc_darwin,abi_powerpc_elfv2 ,abi_eabi,abi_armeb,abi_eabihf ,abi_old_win32_gnu ,abi_aarch64_darwin diff --git a/compiler/systems.pas b/compiler/systems.pas index 3563ffeb5c..d334baab98 100644 --- a/compiler/systems.pas +++ b/compiler/systems.pas @@ -363,6 +363,7 @@ interface (name: 'DEFAULT'; supported: true), (name: 'SYSV' ; supported:{$if defined(powerpc) or defined(powerpc64)}true{$else}false{$endif}), (name: 'AIX' ; supported:{$if defined(powerpc) or defined(powerpc64)}true{$else}false{$endif}), + (name: 'DARWIN' ; supported:{$if defined(powerpc) or defined(powerpc64)}true{$else}false{$endif}), (name: 'ELFV2' ; supported:{$if defined(powerpc64)}true{$else}false{$endif}), (name: 'EABI' ; supported:{$ifdef FPC_ARMEL}true{$else}false{$endif}), (name: 'ARMEB' ; supported:{$ifdef FPC_ARMEB}true{$else}false{$endif}), diff --git a/compiler/systems/i_bsd.pas b/compiler/systems/i_bsd.pas index 8b540f2abc..1e7f5d4cb2 100644 --- a/compiler/systems/i_bsd.pas +++ b/compiler/systems/i_bsd.pas @@ -692,7 +692,7 @@ unit i_bsd; first_parm_offset : 24; stacksize : 262144; stackalign : 16; - abi : abi_powerpc_aix; + abi : abi_powerpc_darwin; ); @@ -884,7 +884,7 @@ unit i_bsd; first_parm_offset : 48; stacksize : 262144; stackalign : 16; - abi : abi_powerpc_aix; + abi : abi_powerpc_darwin; ); diff --git a/compiler/systems/i_macos.pas b/compiler/systems/i_macos.pas index 68f3d8bf20..d6242f2d30 100644 --- a/compiler/systems/i_macos.pas +++ b/compiler/systems/i_macos.pas @@ -87,7 +87,7 @@ unit i_macos; first_parm_offset : 8; stacksize : 262144; stackalign : 16; - abi : abi_powerpc_aix; + abi : abi_powerpc_darwin; ); implementation