+ op_raddr_reg and op_caddr_reg added to fix functions prologue

This commit is contained in:
mazen 2002-10-20 19:01:38 +00:00
parent e4cabcd385
commit 220be9c38f
5 changed files with 116 additions and 81 deletions

View File

@ -66,9 +66,13 @@ type
constructor op_sym_ofs(op:tasmop;_size:topsize;_op1:tasmsymbol;_op1ofs:longint); 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_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_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); procedure changeopsize(siz:topsize);
function GetString:string; function GetString:string;
procedure CheckNonCommutativeOpcodes; procedure CheckNonCommutativeOpcodes;
procedure loadcaddr(opidx:longint;aReg:TRegister;cnst:Integer);
procedure loadraddr(opidx:longint;rg1,rg2:TRegister);
private private
FOperandOrder:TOperandOrder; FOperandOrder:TOperandOrder;
procedure init(_size:topsize);{this need to be called by all constructor} 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); loadref(1,_op2);
end; 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; function taicpu.GetString:string;
var var
i:longint; i:longint;
@ -1099,6 +1121,30 @@ end;
until false; until false;
calcsize:=len; calcsize:=len;
end; 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; procedure DoneAsm;
begin begin
end; end;
@ -1108,7 +1154,10 @@ procedure InitAsm;
end. end.
{ {
$Log$ $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 * carl's patch applied
Revision 1.5 2002/10/15 09:00:28 mazen Revision 1.5 2002/10/15 09:00:28 mazen

View File

@ -836,8 +836,6 @@ procedure tcgSPARC.g_restore_frame_pointer(list:TAasmOutput);
delay slot of the return instrucion done in g_return_from_proc} delay slot of the return instrucion done in g_return_from_proc}
end; end;
procedure tcgSPARC.g_return_from_proc(list:TAasmOutput;parasize:aword); procedure tcgSPARC.g_return_from_proc(list:TAasmOutput;parasize:aword);
var
RetReference:TReference;
begin begin
{According to the SPARC ABI, the stack is cleared using the RESTORE instruction {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 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 with list do
begin begin
{Return address is computed by adding 8 to the CALL address saved onto %i6} {Return address is computed by adding 8 to the CALL address saved onto %i6}
reference_reset_base(RetReference,R_I7,8); concat(Taicpu.Op_caddr_reg(A_JMPL,R_I7,8,R_G0));
concat(Taicpu.Op_ref_reg(A_JMPL,S_L,RetReference,R_G0));
{We use trivial restore in the delay slot of the JMPL instruction, as we {We use trivial restore in the delay slot of the JMPL instruction, as we
already set result onto %i0} already set result onto %i0}
concat(Taicpu.Op_reg_const_reg(A_RESTORE,S_L,R_G0,0,R_G0)); concat(Taicpu.Op_reg_const_reg(A_RESTORE,S_L,R_G0,0,R_G0));
@ -1264,7 +1261,10 @@ BEGIN
END. END.
{ {
$Log$ $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 * assembler output format fixed
Revision 1.15 2002/10/11 13:35:14 mazen Revision 1.15 2002/10/11 13:35:14 mazen

View File

@ -264,26 +264,22 @@ TYPE
{***************************************************************************** {*****************************************************************************
Operands Operands
*****************************************************************************} *****************************************************************************}
{ Types of operand } { Types of operand }
toptype=(top_none,top_reg,top_ref,top_CONST,top_symbol); toptype=(top_none,top_reg,top_ref,top_const,top_symbol,top_raddr,top_caddr);
toper=record toper=record
ot : LongInt; ot:LongInt;
case typ : toptype of case typ:toptype of
top_none : (); top_none:();
top_reg : (reg:tregister); top_reg:(reg:tregister);
top_ref : (ref:poperreference); top_ref:(ref:poperreference);
top_CONST : (val:aword); top_const:(val:aword);
top_symbol : (sym:tasmsymbol;symofs:LongInt); top_symbol:(sym:tasmsymbol;symofs:LongInt);
END; top_raddr:(reg1,reg2:TRegister);
top_caddr:(regb:TRegister;const13:Integer);
end;
{***************************************************************************** {*****************************************************************************
Argument Classification Argument Classification
*****************************************************************************} *****************************************************************************}
TYPE TYPE
TArgClass = ( TArgClass = (
{ the following classes should be defined by all processor implemnations } { the following classes should be defined by all processor implemnations }
@ -541,7 +537,10 @@ function flags_to_cond(const f:TResFlags):TAsmCond;
END. END.
{ {
$Log$ $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 * carl's patch applied
Revision 1.12 2002/10/11 13:35:14 mazen Revision 1.12 2002/10/11 13:35:14 mazen

View File

@ -54,58 +54,40 @@ function GetReferenceString(var ref:TReference):string;
var var
s:string; s:string;
begin begin
s:='';
with ref do with ref do
begin begin
inc(offset,offsetfixup); 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) if assigned(symbol)
then then
s:=s+symbol.name; s:=s+symbol.name;
if offset<0 if base<>R_NONE
then then
s:=s+tostr(offset) s:=s+gas_reg2str[base]+'+';
else if (offset>0) if index<>R_NONE
then then
begin begin
if ScaleFactor<>0
then
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) if assigned(symbol)
then then
s:=s+'+'+tostr(offset) s:=s+'+'+tostr(offset)
else else
s:=s+tostr(offset); 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+']';
end;
end; end;
getreferencestring:=s; getreferencestring:=s;
end; end;
@ -118,7 +100,7 @@ function getopstr(const Oper:TOper):string;
top_reg: top_reg:
getopstr:=gas_reg2str[reg]; getopstr:=gas_reg2str[reg];
top_ref: top_ref:
getopstr:=getreferencestring(ref^); getopstr:='['+getreferencestring(ref^)+']';
top_const: top_const:
getopstr:={'$'+}tostr(longint(val)); getopstr:={'$'+}tostr(longint(val));
top_symbol: top_symbol:
@ -137,6 +119,10 @@ function getopstr(const Oper:TOper):string;
hs:=hs+'0'; hs:=hs+'0';
getopstr:=hs; getopstr:=hs;
end; end;
top_raddr:
getopstr:=std_reg2str[reg1]+'+'+std_reg2str[reg2];
top_caddr:
getopstr:=std_reg2str[regb]+'+'+ToStr(const13);
else else
internalerror(10001); internalerror(10001);
end; end;
@ -230,7 +216,10 @@ initialization
end. end.
{ {
$Log$ $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 * sone coding style modified
} }

View File

@ -28,9 +28,10 @@ uses
cgbase,cpuinfo; cgbase,cpuinfo;
type type
TSparcprocinfo=class(TProcInfo) 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; 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; maxpushedparasize:aword;
constructor create;override; constructor create;override;
procedure after_header;override; procedure after_header;override;
@ -55,17 +56,11 @@ procedure TSparcprocinfo.after_header;
procedure TSparcprocinfo.after_pass1; procedure TSparcprocinfo.after_pass1;
begin begin
procdef.parast.address_fixup:=align(maxpushedparasize,16); procdef.parast.address_fixup:=align(maxpushedparasize,16);
if cs_asm_source in aktglobalswitches WriteLn('Parameter copies start at: %i6+'+tostr(procdef.parast.address_fixup));
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); procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
if cs_asm_source in aktglobalswitches WriteLn(strpnew('Locals start at: %o6+'+tostr(procdef.localst.address_fixup)));
then
aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: %o6+'+tostr(procdef.localst.address_fixup))));
procinfo.firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16); procinfo.firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16);
if cs_asm_source in aktglobalswitches WriteLn('Temp. space start: %o6+'+tostr(procinfo.firsttemp_offset));
then
aktproccode.insert(Tai_comment.Create(strpnew('Temp. space start: %o6+'+tostr(procinfo.firsttemp_offset))));
tg.firsttemp:=procinfo.firsttemp_offset; tg.firsttemp:=procinfo.firsttemp_offset;
tg.lasttemp:=procinfo.firsttemp_offset; tg.lasttemp:=procinfo.firsttemp_offset;
end; end;
@ -74,7 +69,10 @@ begin
end. end.
{ {
$Log$ $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 * Internal error fixed, but usually i386 parameter model used
Revision 1.2 2002/08/29 11:02:36 mazen Revision 1.2 2002/08/29 11:02:36 mazen