* compile fixes for x86_64

This commit is contained in:
peter 2004-12-12 12:56:18 +00:00
parent 65e54a6250
commit 1c458abb0b
3 changed files with 54 additions and 43 deletions

View File

@ -474,8 +474,8 @@ interface
cg.a_reg_sync(exprasmlist,tempinfo^.location.register64.reghi); cg.a_reg_sync(exprasmlist,tempinfo^.location.register64.reghi);
cg.a_reg_sync(exprasmlist,tempinfo^.location.register64.reglo); cg.a_reg_sync(exprasmlist,tempinfo^.location.register64.reglo);
end end
{$endif cpu64bit}
else else
{$endif cpu64bit}
cg.a_reg_sync(exprasmlist,tempinfo^.location.register); cg.a_reg_sync(exprasmlist,tempinfo^.location.register);
if release_to_normal then if release_to_normal then
tempinfo^.location.loc := LOC_REGISTER; tempinfo^.location.loc := LOC_REGISTER;
@ -495,7 +495,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.73 2004-12-03 16:04:47 peter Revision 1.74 2004-12-12 12:56:18 peter
* compile fixes for x86_64
Revision 1.73 2004/12/03 16:04:47 peter
* use tlocation for tempnodes * use tlocation for tempnodes
Revision 1.72 2004/12/02 19:26:15 peter Revision 1.72 2004/12/02 19:26:15 peter

View File

@ -33,7 +33,8 @@ type
S_IS,S_IL,S_IQ, S_IS,S_IL,S_IQ,
S_FS,S_FL,S_FX,S_FV,S_FXX, S_FS,S_FL,S_FX,S_FV,S_FXX,
S_MD, S_MD,
S_NEAR,S_FAR,S_SHORT S_NEAR,S_FAR,S_SHORT,
S_T
); );
{***************************************************************************** {*****************************************************************************
@ -146,7 +147,10 @@ const
{ {
$Log$ $Log$
Revision 1.15 2004-06-20 08:55:32 florian Revision 1.16 2004-12-12 12:56:18 peter
* compile fixes for x86_64
Revision 1.15 2004/06/20 08:55:32 florian
* logs truncated * logs truncated
Revision 1.14 2004/06/16 20:07:11 florian Revision 1.14 2004/06/16 20:07:11 florian

View File

@ -29,7 +29,7 @@ unit cpupara;
uses uses
globtype, globtype,
cpubase,cgbase, cpubase,cgbase,
symconst,symbase,symtype,symdef, symconst,symbase,symtype,symsym,symdef,
aasmtai, aasmtai,
parabase,paramgr; parabase,paramgr;
@ -37,7 +37,7 @@ unit cpupara;
tx86_64paramanager = class(tparamanager) tx86_64paramanager = class(tparamanager)
private private
procedure create_funcretloc_info(p : tabstractprocdef; side: tcallercallee); procedure create_funcretloc_info(p : tabstractprocdef; side: tcallercallee);
procedure create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee;firstpara:tparaitem; procedure create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee;paras:tparalist;
var intparareg,mmparareg,parasize:longint); var intparareg,mmparareg,parasize:longint);
public public
procedure getintparaloc(calloption : tproccalloption; nr : longint;var cgpara:TCGPara);override; procedure getintparaloc(calloption : tproccalloption; nr : longint;var cgpara:TCGPara);override;
@ -45,7 +45,7 @@ unit cpupara;
function get_volatile_registers_mm(calloption : tproccalloption):tcpuregisterset;override; function get_volatile_registers_mm(calloption : tproccalloption):tcpuregisterset;override;
function get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;override; function get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;override;
function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override; function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override;
function create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargspara):longint;override; function create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargsparalist):longint;override;
end; end;
implementation implementation
@ -53,7 +53,8 @@ unit cpupara;
uses uses
cutils,verbose, cutils,verbose,
systems, systems,
defutil; defutil,
cgutils;
const const
paraintsupregs : array[0..5] of tsuperregister = (RS_RDI,RS_RSI,RS_RDX,RS_RCX,RS_R8,RS_R9); paraintsupregs : array[0..5] of tsuperregister = (RS_RDI,RS_RSI,RS_RDX,RS_RCX,RS_R8,RS_R9);
@ -195,73 +196,75 @@ unit cpupara;
retcgsize:=OS_ADDR retcgsize:=OS_ADDR
else else
retcgsize:=def_cgsize(p.rettype.def); retcgsize:=def_cgsize(p.rettype.def);
p.funcretloc[side].reset;
p.funcretloc[side].Alignment:=std_param_align; location_reset(p.funcretloc[side],LOC_INVALID,OS_NO);
p.funcretloc[side].size:=retcgsize;
{ void has no location } { void has no location }
if is_void(p.rettype.def) then if is_void(p.rettype.def) then
exit; begin
paraloc:=p.funcretloc[side].add_location; location_reset(p.funcretloc[side],LOC_VOID,OS_NO);
exit;
end;
{ Return in FPU register? } { Return in FPU register? }
if p.rettype.def.deftype=floatdef then if p.rettype.def.deftype=floatdef then
begin begin
case tfloatdef(p.rettype.def).typ of case tfloatdef(p.rettype.def).typ of
s32real,s64real: s32real,s64real:
begin begin
paraloc^.loc:=LOC_MMREGISTER; p.funcretloc[side].loc:=LOC_MMREGISTER;
paraloc^.register:=NR_MM_RESULT_REG; p.funcretloc[side].register:=NR_MM_RESULT_REG;
p.funcretloc[side].size:=retcgsize;
end; end;
s64currency, s64currency,
s64comp, s64comp,
s80real: s80real:
begin begin
paraloc^.loc:=LOC_FPUREGISTER; p.funcretloc[side].loc:=LOC_FPUREGISTER;
paraloc^.register:=NR_FPU_RESULT_REG; p.funcretloc[side].register:=NR_FPU_RESULT_REG;
p.funcretloc[side].size:=retcgsize;
end; end;
else else
internalerror(200405034); internalerror(200405034);
end; end;
paraloc^.size:=retcgsize;
end end
else else
{ Return in register? } { Return in register? }
if not ret_in_param(p.rettype.def,p.proccalloption) then if not ret_in_param(p.rettype.def,p.proccalloption) then
begin begin
paraloc^.loc:=LOC_REGISTER; p.funcretloc[side].loc:=LOC_REGISTER;
paraloc^.size:=retcgsize; p.funcretloc[side].size:=retcgsize;
if side=callerside then if side=callerside then
paraloc^.register:=newreg(R_INTREGISTER,RS_FUNCTION_RESULT_REG,cgsize2subreg(retcgsize)) p.funcretloc[side].register:=newreg(R_INTREGISTER,RS_FUNCTION_RESULT_REG,cgsize2subreg(retcgsize))
else else
paraloc^.register:=newreg(R_INTREGISTER,RS_FUNCTION_RETURN_REG,cgsize2subreg(retcgsize)); p.funcretloc[side].register:=newreg(R_INTREGISTER,RS_FUNCTION_RETURN_REG,cgsize2subreg(retcgsize));
end end
else else
begin begin
paraloc^.loc:=LOC_REFERENCE; p.funcretloc[side].loc:=LOC_REFERENCE;
paraloc^.size:=retcgsize; p.funcretloc[side].size:=retcgsize;
end; end;
end; end;
procedure tx86_64paramanager.create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee;firstpara:tparaitem; procedure tx86_64paramanager.create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee;paras:tparalist;
var intparareg,mmparareg,parasize:longint); var intparareg,mmparareg,parasize:longint);
var var
hp : tparaitem; hp : tparavarsym;
paraloc, paraloc,
paraloc2 : pcgparalocation; paraloc2 : pcgparalocation;
subreg : tsubregister; subreg : tsubregister;
pushaddr : boolean; pushaddr : boolean;
paracgsize : tcgsize; paracgsize : tcgsize;
loc1,loc2 : tcgloc; loc1,loc2 : tcgloc;
l, l,i,
varalign, varalign,
paraalign : longint; paraalign : longint;
begin begin
paraalign:=get_para_align(p.proccalloption); paraalign:=get_para_align(p.proccalloption);
{ Register parameters are assigned from left to right } { Register parameters are assigned from left to right }
hp:=firstpara; for i:=0 to paras.count-1 do
while assigned(hp) do
begin begin
pushaddr:=push_addr_param(hp.paratyp,hp.paratype.def,p.proccalloption); hp:=tparavarsym(paras[i]);
pushaddr:=push_addr_param(hp.varspez,hp.vartype.def,p.proccalloption);
if pushaddr then if pushaddr then
begin begin
loc1:=LOC_REGISTER; loc1:=LOC_REGISTER;
@ -270,8 +273,8 @@ unit cpupara;
end end
else else
begin begin
getvalueparaloc(hp.paratype.def,loc1,loc2); getvalueparaloc(hp.vartype.def,loc1,loc2);
paracgsize:=def_cgsize(hp.paratype.def); paracgsize:=def_cgsize(hp.vartype.def);
end; end;
hp.paraloc[side].reset; hp.paraloc[side].reset;
hp.paraloc[side].size:=paracgsize; hp.paraloc[side].size:=paracgsize;
@ -317,7 +320,7 @@ unit cpupara;
paraloc^.reference.index:=NR_STACK_POINTER_REG paraloc^.reference.index:=NR_STACK_POINTER_REG
else else
paraloc^.reference.index:=NR_FRAME_POINTER_REG; paraloc^.reference.index:=NR_FRAME_POINTER_REG;
l:=push_size(hp.paratyp,hp.paratype.def,p.proccalloption); l:=push_size(hp.varspez,hp.vartype.def,p.proccalloption);
varalign:=size_2_align(l); varalign:=size_2_align(l);
paraloc^.reference.offset:=parasize; paraloc^.reference.offset:=parasize;
varalign:=used_align(varalign,paraalign,paraalign); varalign:=used_align(varalign,paraalign,paraalign);
@ -363,14 +366,13 @@ unit cpupara;
paraloc^.reference.index:=NR_STACK_POINTER_REG paraloc^.reference.index:=NR_STACK_POINTER_REG
else else
paraloc^.reference.index:=NR_FRAME_POINTER_REG; paraloc^.reference.index:=NR_FRAME_POINTER_REG;
l:=push_size(hp.paratyp,hp.paratype.def,p.proccalloption); l:=push_size(hp.varspez,hp.vartype.def,p.proccalloption);
varalign:=size_2_align(l); varalign:=size_2_align(l);
paraloc^.reference.offset:=parasize; paraloc^.reference.offset:=parasize;
varalign:=used_align(varalign,paraalign,paraalign); varalign:=used_align(varalign,paraalign,paraalign);
parasize:=align(parasize+l,varalign); parasize:=align(parasize+l,varalign);
end; end;
end; end;
hp:=tparaitem(hp.next);
end; end;
{ Register parameters are assigned from left-to-right, but the { Register parameters are assigned from left-to-right, but the
offsets on the stack are right-to-left. There is no need offsets on the stack are right-to-left. There is no need
@ -378,19 +380,18 @@ unit cpupara;
start offset of the first param on the stack } start offset of the first param on the stack }
if side=calleeside then if side=calleeside then
begin begin
hp:=tparaitem(p.para.first); for i:=0 to paras.count-1 do
while assigned(hp) do
begin begin
hp:=tparavarsym(paras[i]);
with hp.paraloc[side].location^ do with hp.paraloc[side].location^ do
if (loc=LOC_REFERENCE) then if (loc=LOC_REFERENCE) then
inc(reference.offset,target_info.first_parm_offset); inc(reference.offset,target_info.first_parm_offset);
hp:=tparaitem(hp.next);
end; end;
end; end;
end; end;
function tx86_64paramanager.create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargspara):longint; function tx86_64paramanager.create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tvarargsparalist):longint;
var var
intparareg,mmparareg, intparareg,mmparareg,
parasize : longint; parasize : longint;
@ -399,9 +400,9 @@ unit cpupara;
mmparareg:=0; mmparareg:=0;
parasize:=0; parasize:=0;
{ calculate the registers for the normal parameters } { calculate the registers for the normal parameters }
create_paraloc_info_intern(p,callerside,tparaitem(p.para.first),intparareg,mmparareg,parasize); create_paraloc_info_intern(p,callerside,p.paras,intparareg,mmparareg,parasize);
{ append the varargs } { append the varargs }
create_paraloc_info_intern(p,callerside,tparaitem(varargspara.first),intparareg,mmparareg,parasize); create_paraloc_info_intern(p,callerside,varargspara,intparareg,mmparareg,parasize);
{ store used no. of SSE registers, that needs to be passed in %AL } { store used no. of SSE registers, that needs to be passed in %AL }
varargspara.mmregsused:=mmparareg; varargspara.mmregsused:=mmparareg;
result:=parasize; result:=parasize;
@ -416,7 +417,7 @@ unit cpupara;
intparareg:=0; intparareg:=0;
mmparareg:=0; mmparareg:=0;
parasize:=0; parasize:=0;
create_paraloc_info_intern(p,side,tparaitem(p.para.first),intparareg,mmparareg,parasize); create_paraloc_info_intern(p,side,p.paras,intparareg,mmparareg,parasize);
{ Create Function result paraloc } { Create Function result paraloc }
create_funcretloc_info(p,side); create_funcretloc_info(p,side);
{ We need to return the size allocated on the stack } { We need to return the size allocated on the stack }
@ -429,7 +430,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.12 2004-11-21 17:54:59 peter Revision 1.13 2004-12-12 12:56:18 peter
* compile fixes for x86_64
Revision 1.12 2004/11/21 17:54:59 peter
* ttempcreatenode.create_reg merged into .create with parameter * ttempcreatenode.create_reg merged into .create with parameter
whether a register is allowed whether a register is allowed
* funcret_paraloc renamed to funcretloc * funcret_paraloc renamed to funcretloc