diff --git a/compiler/sparc/aasmcpu.pas b/compiler/sparc/aasmcpu.pas index 8bb22e721e..03b28a114d 100644 --- a/compiler/sparc/aasmcpu.pas +++ b/compiler/sparc/aasmcpu.pas @@ -66,9 +66,13 @@ type constructor op_sym_ofs(op:tasmop;_size:topsize;_op1:tasmsymbol;_op1ofs:longint); constructor op_sym_ofs_reg(op:tasmop;_size:topsize;_op1:tasmsymbol;_op1ofs:longint;_op2:tregister); constructor op_sym_ofs_ref(op:tasmop;_size:topsize;_op1:tasmsymbol;_op1ofs:longint;const _op2:treference); + constructor op_caddr_reg(op:TAsmOp;rgb:TRegister;cnst:Integer;reg:TRegister); + constructor op_raddr_reg(op:TAsmOp;rg1,rg2:TRegister;reg:TRegister); procedure changeopsize(siz:topsize); function GetString:string; procedure CheckNonCommutativeOpcodes; + procedure loadcaddr(opidx:longint;aReg:TRegister;cnst:Integer); + procedure loadraddr(opidx:longint;rg1,rg2:TRegister); private FOperandOrder:TOperandOrder; procedure init(_size:topsize);{this need to be called by all constructor} @@ -330,6 +334,24 @@ constructor taicpu.op_sym_ofs_ref(op:tasmop;_size:topsize;_op1:tasmsymbol;_op1of loadref(1,_op2); end; +constructor taicpu.op_caddr_reg(op:TAsmOp;rgb:TRegister;cnst:Integer;reg:TRegister); + begin + inherited create(op); + init(S_L); + ops:=2; + WriteLn(1,std_reg2str[rgb]); + loadcaddr(0,rgb,cnst); + WriteLn(2,std_reg2str[rgb]); + loadreg(1,reg); + end; +constructor taicpu.op_raddr_reg(op:TAsmOp;rg1,rg2,reg:TRegister); + begin + inherited create(op); + init(S_L); + ops:=2; + loadraddr(0,rg1,rg2); + loadreg(1,reg); + end; function taicpu.GetString:string; var i:longint; @@ -1099,6 +1121,30 @@ end; until false; calcsize:=len; end; +procedure taicpu.loadcaddr(opidx:longint;aReg:TRegister;cnst:Integer); + begin + if opidx>=ops + then + ops:=opidx+1; + with oper[opidx] do + begin + typ:=top_caddr; + regb:=aReg; + const13:=cnst; + end; + end; +procedure taicpu.loadraddr(opidx:longint;rg1,rg2:TRegister); + begin + if opidx>=ops + then + ops:=opidx+1; + with oper[opidx] do + begin + typ:=top_caddr; + reg1:=rg1; + reg2:=rg2; + end; + end; procedure DoneAsm; begin end; @@ -1108,7 +1154,10 @@ procedure InitAsm; end. { $Log$ - Revision 1.6 2002-10-19 20:35:07 mazen + Revision 1.7 2002-10-20 19:01:38 mazen + + op_raddr_reg and op_caddr_reg added to fix functions prologue + + Revision 1.6 2002/10/19 20:35:07 mazen * carl's patch applied Revision 1.5 2002/10/15 09:00:28 mazen diff --git a/compiler/sparc/cgcpu.pas b/compiler/sparc/cgcpu.pas index 46d3c8309a..1a87b35526 100644 --- a/compiler/sparc/cgcpu.pas +++ b/compiler/sparc/cgcpu.pas @@ -836,8 +836,6 @@ procedure tcgSPARC.g_restore_frame_pointer(list:TAasmOutput); delay slot of the return instrucion done in g_return_from_proc} end; procedure tcgSPARC.g_return_from_proc(list:TAasmOutput;parasize:aword); - var - RetReference:TReference; begin {According to the SPARC ABI, the stack is cleared using the RESTORE instruction which is genereted in the g_restore_frame_pointer. Notice that SPARC has no @@ -852,8 +850,7 @@ If no inversion we can use just with list do begin {Return address is computed by adding 8 to the CALL address saved onto %i6} - reference_reset_base(RetReference,R_I7,8); - concat(Taicpu.Op_ref_reg(A_JMPL,S_L,RetReference,R_G0)); + concat(Taicpu.Op_caddr_reg(A_JMPL,R_I7,8,R_G0)); {We use trivial restore in the delay slot of the JMPL instruction, as we already set result onto %i0} concat(Taicpu.Op_reg_const_reg(A_RESTORE,S_L,R_G0,0,R_G0)); @@ -1264,7 +1261,10 @@ BEGIN END. { $Log$ - Revision 1.16 2002-10-13 21:46:07 mazen + Revision 1.17 2002-10-20 19:01:38 mazen + + op_raddr_reg and op_caddr_reg added to fix functions prologue + + Revision 1.16 2002/10/13 21:46:07 mazen * assembler output format fixed Revision 1.15 2002/10/11 13:35:14 mazen diff --git a/compiler/sparc/cpubase.pas b/compiler/sparc/cpubase.pas index 1bb1fbba43..b7d1c1d3bf 100644 --- a/compiler/sparc/cpubase.pas +++ b/compiler/sparc/cpubase.pas @@ -264,26 +264,22 @@ TYPE {***************************************************************************** Operands *****************************************************************************} - - { Types of operand } - toptype=(top_none,top_reg,top_ref,top_CONST,top_symbol); - - toper=record - ot : LongInt; - case typ : toptype of - top_none : (); - top_reg : (reg:tregister); - top_ref : (ref:poperreference); - top_CONST : (val:aword); - top_symbol : (sym:tasmsymbol;symofs:LongInt); - END; - - - + { Types of operand } + toptype=(top_none,top_reg,top_ref,top_const,top_symbol,top_raddr,top_caddr); + toper=record + ot:LongInt; + case typ:toptype of + top_none:(); + top_reg:(reg:tregister); + top_ref:(ref:poperreference); + top_const:(val:aword); + top_symbol:(sym:tasmsymbol;symofs:LongInt); + top_raddr:(reg1,reg2:TRegister); + top_caddr:(regb:TRegister;const13:Integer); + end; {***************************************************************************** Argument Classification *****************************************************************************} - TYPE TArgClass = ( { the following classes should be defined by all processor implemnations } @@ -541,7 +537,10 @@ function flags_to_cond(const f:TResFlags):TAsmCond; END. { $Log$ - Revision 1.13 2002-10-19 20:35:07 mazen + Revision 1.14 2002-10-20 19:01:38 mazen + + op_raddr_reg and op_caddr_reg added to fix functions prologue + + Revision 1.13 2002/10/19 20:35:07 mazen * carl's patch applied Revision 1.12 2002/10/11 13:35:14 mazen diff --git a/compiler/sparc/cpugas.pas b/compiler/sparc/cpugas.pas index 0e83255f35..ff814ffac7 100644 --- a/compiler/sparc/cpugas.pas +++ b/compiler/sparc/cpugas.pas @@ -54,58 +54,40 @@ function GetReferenceString(var ref:TReference):string; var s:string; begin + s:=''; with ref do begin inc(offset,offsetfixup); - offsetfixup:=0; - { have we a segment prefix ? } - { These are probably not correctly handled under GAS } - { should be replaced by coding the segment override } - { directly! - DJGPP FAQ } - if segment<>R_NONE - then - s:=gas_reg2str[segment]+':' - else - s:=''; if assigned(symbol) then s:=s+symbol.name; - if offset<0 + if base<>R_NONE then - s:=s+tostr(offset) - else if (offset>0) + s:=s+gas_reg2str[base]+'+'; + if index<>R_NONE then begin - if assigned(symbol) + if ScaleFactor<>0 then - s:=s+'+'+tostr(offset) - else - s:=s+tostr(offset); - end - else if (index=R_NONE) and (base=R_NONE) and not assigned(symbol) - then - s:=s+'0'; - if (index<>R_NONE) and (base=R_NONE) - then - begin - s:='['+gas_reg2str[index]+s; - if scalefactor<>0 - then - s:=tostr(scalefactor)+'+'+s; - s:=s+']'; - end - else if (index=R_NONE) and (base<>R_NONE) - then - s:='['+gas_reg2str[base]+'+'+s+']' - else if (index<>R_NONE) and (base<>R_NONE) - then - begin - s:='['+gas_reg2str[base]+'+'+gas_reg2str[index]; - if scalefactor<>0 - then - s:=tostr(scalefactor)+'+'+s; - s:= s+']'; + s:=s+ToStr(ScaleFactor)+'*'; + s:=s+gas_reg2str[index]+'+'; end; + if Offset=0 + then + SetLength(s,Length(s)-1) + else if offset<0 + then + begin + SetLength(s,Length(s)-1); + s:=s+tostr(offset); + end + else if offset>0 + then + if assigned(symbol) + then + s:=s+'+'+tostr(offset) + else + s:=s+tostr(offset); end; getreferencestring:=s; end; @@ -118,7 +100,7 @@ function getopstr(const Oper:TOper):string; top_reg: getopstr:=gas_reg2str[reg]; top_ref: - getopstr:=getreferencestring(ref^); + getopstr:='['+getreferencestring(ref^)+']'; top_const: getopstr:={'$'+}tostr(longint(val)); top_symbol: @@ -137,6 +119,10 @@ function getopstr(const Oper:TOper):string; hs:=hs+'0'; getopstr:=hs; end; + top_raddr: + getopstr:=std_reg2str[reg1]+'+'+std_reg2str[reg2]; + top_caddr: + getopstr:=std_reg2str[regb]+'+'+ToStr(const13); else internalerror(10001); end; @@ -230,7 +216,10 @@ initialization end. { $Log$ - Revision 1.6 2002-10-15 09:00:28 mazen + Revision 1.7 2002-10-20 19:01:38 mazen + + op_raddr_reg and op_caddr_reg added to fix functions prologue + + Revision 1.6 2002/10/15 09:00:28 mazen * sone coding style modified } diff --git a/compiler/sparc/cpupi.pas b/compiler/sparc/cpupi.pas index 86e4a772cd..18c1dc9ed1 100644 --- a/compiler/sparc/cpupi.pas +++ b/compiler/sparc/cpupi.pas @@ -28,9 +28,10 @@ uses cgbase,cpuinfo; type TSparcprocinfo=class(TProcInfo) - {overall size of allocated stack space, currently this is used for the PowerPC only} + {overall size of allocated stack space, currently this is used for the + PowerPC only} localsize:aword; - {max. of space need for parameters, currently used by the PowerPC port only} + {max of space need for parameters, currently used by the PowerPC port only} maxpushedparasize:aword; constructor create;override; procedure after_header;override; @@ -55,26 +56,23 @@ procedure TSparcprocinfo.after_header; procedure TSparcprocinfo.after_pass1; begin procdef.parast.address_fixup:=align(maxpushedparasize,16); - if cs_asm_source in aktglobalswitches - then - aktproccode.insert(Tai_comment.Create(strpnew('Parameter copies start at: %i6+'+tostr(procdef.parast.address_fixup)))); - procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16); - if cs_asm_source in aktglobalswitches - then - aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: %o6+'+tostr(procdef.localst.address_fixup)))); + WriteLn('Parameter copies start at: %i6+'+tostr(procdef.parast.address_fixup)); + procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16); + WriteLn(strpnew('Locals start at: %o6+'+tostr(procdef.localst.address_fixup))); procinfo.firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16); - if cs_asm_source in aktglobalswitches - then - aktproccode.insert(Tai_comment.Create(strpnew('Temp. space start: %o6+'+tostr(procinfo.firsttemp_offset)))); + WriteLn('Temp. space start: %o6+'+tostr(procinfo.firsttemp_offset)); tg.firsttemp:=procinfo.firsttemp_offset; tg.lasttemp:=procinfo.firsttemp_offset; end; begin - cprocinfo:=TSparcprocinfo; + cprocinfo:=TSparcprocinfo; end. { $Log$ - Revision 1.3 2002-10-10 15:10:39 mazen + Revision 1.4 2002-10-20 19:01:38 mazen + + op_raddr_reg and op_caddr_reg added to fix functions prologue + + Revision 1.3 2002/10/10 15:10:39 mazen * Internal error fixed, but usually i386 parameter model used Revision 1.2 2002/08/29 11:02:36 mazen