* some ppc stuff fixed

* memory leak fixed
This commit is contained in:
florian 2003-10-19 01:34:30 +00:00
parent c5df303517
commit 05fcae577a
10 changed files with 161 additions and 48 deletions

View File

@ -183,9 +183,9 @@ unit cgobj;
}
{ Copy a parameter to a (temporary) reference }
procedure a_load_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference);virtual;
procedure a_loadany_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference;shuffle : pmmshuffle);virtual;
{ Copy a parameter to a register }
procedure a_load_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister);virtual;
procedure a_loadany_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister;shuffle : pmmshuffle);virtual;
{# Emits instruction to call the method specified by symbol name.
This routine must be overriden for each new target cpu.
@ -680,7 +680,7 @@ implementation
end;
procedure tcg.a_load_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference);
procedure tcg.a_loadany_param_ref(list : taasmoutput;const locpara : tparalocation;const ref:treference;shuffle : pmmshuffle);
begin
case locpara.loc of
LOC_CREGISTER,
@ -705,16 +705,27 @@ implementation
a_load_reg_ref(list,locpara.size,locpara.size,locpara.register,ref);
end;
end;
LOC_MMREGISTER,
LOC_CMMREGISTER:
begin
getexplicitregister(list,locpara.register);
ungetregister(list,locpara.register);
a_loadmm_reg_ref(list,locpara.size,locpara.size,locpara.register,ref,shuffle);
end;
LOC_FPUREGISTER,
LOC_CFPUREGISTER:
a_loadfpu_reg_ref(list,locpara.size,locpara.register,ref);
begin
getexplicitregister(list,locpara.register);
ungetregister(list,locpara.register);
a_loadfpu_reg_ref(list,locpara.size,locpara.register,ref);
end;
else
internalerror(2002081302);
end;
end;
procedure tcg.a_load_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister);
procedure tcg.a_loadany_param_reg(list : taasmoutput;const locpara : tparalocation;const reg:tregister;shuffle : pmmshuffle);
var
href : treference;
begin
@ -734,7 +745,20 @@ implementation
end;
LOC_CFPUREGISTER,
LOC_FPUREGISTER:
a_loadfpu_reg_reg(list,locpara.size,locpara.register,reg);
begin
getexplicitregister(list,locpara.register);
ungetregister(list,locpara.register);
getexplicitregister(list,reg);
a_loadfpu_reg_reg(list,locpara.size,locpara.register,reg);
end;
LOC_MMREGISTER,
LOC_CMMREGISTER:
begin
getexplicitregister(list,locpara.register);
ungetregister(list,locpara.register);
getexplicitregister(list,reg);
a_loadmm_reg_reg(list,locpara.size,locpara.size,locpara.register,reg,shuffle);
end;
LOC_REFERENCE,
LOC_CREFERENCE:
begin
@ -1787,7 +1811,11 @@ finalization
end.
{
$Log$
Revision 1.132 2003-10-17 15:25:18 florian
Revision 1.133 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.132 2003/10/17 15:25:18 florian
* fixed more ppc stuff
Revision 1.131 2003/10/17 14:38:32 peter

View File

@ -645,7 +645,7 @@ implementation
AsmWriteln(#9#9'DB 66h,68h ; pushw imm16');
AsmWrite(#9#9'DW');
end
else
else
AsmWrite(#9#9+prefix+std_op2str[taicpu(hp).opcode]+cond2str[taicpu(hp).condition]+suffix);
if taicpu(hp).ops<>0 then
begin
@ -875,7 +875,11 @@ initialization
end.
{
$Log$
Revision 1.41 2003-10-18 09:16:45 hajny
Revision 1.42 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.41 2003/10/18 09:16:45 hajny
* Watcom patch by Wiktor Sywula
Revision 1.40 2003/09/30 08:39:50 michael

View File

@ -36,11 +36,6 @@ unit cpupara;
symconst,symtype,symdef,paramgr;
type
{ Returns the location for the nr-st 32 Bit int parameter
if every parameter before is an 32 Bit int parameter as well
and if the calling conventions for the helper routines of the
rtl are used.
}
ti386paramanager = class(tparamanager)
function ret_in_param(def : tdef;calloption : tproccalloption) : boolean;override;
function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
@ -48,6 +43,11 @@ unit cpupara;
function get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;override;
function get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;override;
function get_volatile_registers_mm(calloption : tproccalloption):tcpuregisterset;override;
{ Returns the location for the nr-st 32 Bit int parameter
if every parameter before is an 32 Bit int parameter as well
and if the calling conventions for the helper routines of the
rtl are used.
}
function getintparaloc(calloption : tproccalloption; nr : longint) : tparalocation;override;
function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override;
function create_varargs_paraloc_info(p : tabstractprocdef; varargspara:tlinkedlist):longint;override;
@ -446,7 +446,11 @@ begin
end.
{
$Log$
Revision 1.41 2003-10-17 14:38:32 peter
Revision 1.42 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.41 2003/10/17 14:38:32 peter
* 64k registers supported
* fixed some memory leaks

View File

@ -354,7 +354,7 @@ implementation
(assigned(tcallnode(hp.left).funcretnode) or
(tcallnode(hp.left).procdefinition.proctypeoption=potype_constructor))) and
not(is_void(hp.left.resulttype.def)) then
CGMessagePos(hp.left.fileinfo,cg_e_illegal_expression);
CGMessagePos(hp.left.fileinfo,cg_e_illegal_expression);
{ the resulttype of the block is the last type that is
returned. Normally this is a voidtype. But when the
compiler inserts a block of multiple statements then the
@ -833,7 +833,11 @@ begin
end.
{
$Log$
Revision 1.65 2003-10-17 14:38:32 peter
Revision 1.66 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.65 2003/10/17 14:38:32 peter
* 64k registers supported
* fixed some memory leaks

View File

@ -1115,7 +1115,15 @@ implementation
{ cg.a_load_param_reg will first allocate and then deallocate paraloc }
{ register (if the parameter resides in a register) and then allocate }
{ the regvar (which is currently not allocated) }
cg.a_load_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).localloc.register);
cg.a_loadany_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).localloc.register,nil);
end;
LOC_FPUREGISTER:
begin
gotregvarparas := true;
{ cg.a_load_param_reg will first allocate and then deallocate paraloc }
{ register (if the parameter resides in a register) and then allocate }
{ the regvar (which is currently not allocated) }
cg.a_loadany_param_reg(list,hp.paraloc[calleeside],tvarsym(hp.parasym).localloc.register,nil);
end;
LOC_REFERENCE :
begin
@ -1144,7 +1152,7 @@ implementation
{$endif cpu64bit}
cg.ungetregister(list,hp.paraloc[calleeside].register);
reference_reset_base(href,tvarsym(hp.parasym).localloc.reference.index,tvarsym(hp.parasym).localloc.reference.offset);
cg.a_load_param_ref(list,hp.paraloc[calleeside],href);
cg.a_loadany_param_ref(list,hp.paraloc[calleeside],href,nil);
end;
end;
else
@ -1957,7 +1965,11 @@ implementation
end.
{
$Log$
Revision 1.160 2003-10-17 15:08:34 peter
Revision 1.161 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.160 2003/10/17 15:08:34 peter
* commented out more obsolete constants
Revision 1.159 2003/10/17 14:38:32 peter

View File

@ -232,6 +232,9 @@ implementation
symtablestack.next.foreach_static({$ifdef FPCPROCVAR}@{$endif}clearrefs,nil);
{ firstpass everything }
do_firstpass(p);
{ after pass 1, we should have all necessary information to set the temp. start location }
current_procinfo.set_first_temp_offset;
{ only do secondpass if there are no errors }
if ErrorCount=0 then
begin
@ -278,7 +281,11 @@ implementation
end.
{
$Log$
Revision 1.71 2003-10-18 15:41:26 peter
Revision 1.72 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.71 2003/10/18 15:41:26 peter
* made worklists dynamic in size
Revision 1.70 2003/10/17 15:08:34 peter

View File

@ -49,6 +49,8 @@ unit cgcpu;
procedure ungetregister(list:Taasmoutput;r:Tregister);override;
procedure add_move_instruction(instr:Taicpu);override;
procedure do_register_allocation(list:Taasmoutput;headertai:tai);override;
procedure allocexplicitregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);override;
procedure deallocexplicitregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);override;
{ passing parameters, per default the parameter is pushed }
{ nr gives the number of the parameter (enumerated from }
@ -184,8 +186,9 @@ const
{$warning FIX ME}
rgfpu:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
[RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5],first_fpu_imreg,[]);
rgmm:=trgcpu.create(R_MMXREGISTER,R_SUBNONE,
[],first_mm_imreg,[]);
{$warning FIX ME}
rgmm:=trgcpu.create(R_MMREGISTER,R_SUBNONE,
[RS_M0,RS_M1,RS_M2],first_mm_imreg,[]);
end;
@ -251,6 +254,36 @@ const
end;
procedure tcgppc.allocexplicitregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);
begin
case rt of
R_INTREGISTER :
rgint.allocexplicitregisters(list,r);
R_FPUREGISTER :
rgfpu.allocexplicitregisters(list,r);
R_MMREGISTER :
rgmm.allocexplicitregisters(list,r);
else
internalerror(200310092);
end;
end;
procedure tcgppc.deallocexplicitregisters(list:Taasmoutput;rt:Tregistertype;r:Tcpuregisterset);
begin
case rt of
R_INTREGISTER :
rgint.deallocexplicitregisters(list,r);
R_FPUREGISTER :
rgfpu.deallocexplicitregisters(list,r);
R_MMREGISTER :
rgmm.deallocexplicitregisters(list,r);
else
internalerror(200310093);
end;
end;
procedure tcgppc.add_move_instruction(instr:Taicpu);
begin
rgint.add_move_instruction(instr);
@ -1025,7 +1058,7 @@ const
{ FIXME: has to be R_F8 instad of R_F14 for SYSV abi }
for regcounter:=RS_F14 to RS_F31 do
begin
if supregset_in(rgfpu.used_in_proc,regcounter) then
if regcounter in rgfpu.used_in_proc then
begin
usesfpr:= true;
firstregfpu:=regcounter;
@ -1037,7 +1070,7 @@ const
if not (po_assembler in current_procinfo.procdef.procoptions) then
for regcounter2:=RS_R13 to RS_R31 do
begin
if supregset_in(rgint.used_in_proc,regcounter2) then
if regcounter2 in rgint.used_in_proc then
begin
usesgpr:=true;
firstreggpr:=regcounter2;
@ -1120,7 +1153,7 @@ const
reference_reset_base(href,NR_R12,-8);
for regcounter:=firstregfpu to RS_F31 do
begin
if supregset_in(rgfpu.used_in_proc,regcounter) then
if regcounter in rgfpu.used_in_proc then
begin
a_loadfpu_reg_ref(list,OS_F64,newreg(R_FPUREGISTER,regcounter,R_SUBNONE),href);
dec(href.offset,8);
@ -1146,7 +1179,7 @@ const
reference_reset_base(href,NR_R12,-4);
for regcounter2:=RS_R13 to RS_R31 do
begin
if supregset_in(rgint.used_in_proc,regcounter2) then
if regcounter2 in rgint.used_in_proc then
begin
usesgpr:=true;
a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter2,R_SUBNONE),href);
@ -1239,7 +1272,7 @@ const
if not (po_assembler in current_procinfo.procdef.procoptions) then
for regcounter:=RS_F14 to RS_F31 do
begin
if supregset_in(rgfpu.used_in_proc,regcounter) then
if regcounter in rgfpu.used_in_proc then
begin
usesfpr:=true;
firstregfpu:=regcounter;
@ -1251,7 +1284,7 @@ const
if not (po_assembler in current_procinfo.procdef.procoptions) then
for regcounter2:=RS_R13 to RS_R31 do
begin
if supregset_in(rgint.used_in_proc,regcounter2) then
if regcounter2 in rgint.used_in_proc then
begin
usesgpr:=true;
firstreggpr:=regcounter2;
@ -1272,7 +1305,7 @@ const
reference_reset_base(href,NR_R12,-8);
for regcounter := firstregfpu to RS_F31 do
begin
if supregset_in(rgfpu.used_in_proc,regcounter) then
if regcounter in rgfpu.used_in_proc then
begin
a_loadfpu_ref_reg(list,OS_F64,href,newreg(R_FPUREGISTER,regcounter,R_SUBNONE));
dec(href.offset,8);
@ -1285,7 +1318,7 @@ const
for regcounter2:=RS_R13 to RS_R31 do
begin
if supregset_in(rgint.used_in_proc,regcounter2) then
if regcounter2 in rgint.used_in_proc then
begin
usesgpr:=true;
a_load_ref_reg(list,OS_INT,OS_INT,href,newreg(R_INTREGISTER,regcounter2,R_SUBNONE));
@ -1370,7 +1403,7 @@ const
if not (po_assembler in current_procinfo.procdef.procoptions) then
for regcounter:=RS_F14 to RS_F31 do
begin
if supregset_in(rgfpu.used_in_proc,regcounter) then
if regcounter in rgfpu.used_in_proc then
begin
usesfpr:=true;
firstregfpu:=regcounter;
@ -1381,7 +1414,7 @@ const
if not (po_assembler in current_procinfo.procdef.procoptions) then
for regcounter2:=RS_R13 to RS_R31 do
begin
if supregset_in(rgint.used_in_proc,regcounter2) then
if regcounter2 in rgint.used_in_proc then
begin
usesgpr:=true;
firstreggpr:=regcounter2;
@ -1439,7 +1472,7 @@ const
if not (po_assembler in current_procinfo.procdef.procoptions) then
for regcounter:=RS_F14 to RS_F31 do
begin
if supregset_in(rgfpu.used_in_proc,regcounter) then
if regcounter in rgfpu.used_in_proc then
begin
usesfpr:=true;
firstregfpu:=regcounter;
@ -1451,7 +1484,7 @@ const
if not (po_assembler in current_procinfo.procdef.procoptions) then
for regcounter2:=RS_R13 to RS_R31 do
begin
if supregset_in(rgint.used_in_proc,regcounter2) then
if regcounter2 in rgint.used_in_proc then
begin
usesgpr:=true;
firstreggpr:=regcounter2;
@ -2139,6 +2172,7 @@ const
if (getsupreg(ref.index) < first_int_imreg) and
(supregset_in(rgint.unusedregs,getsupreg(ref.index))) then
begin
internalerror(200310191);
rgint.getexplicitregister(list,ref.index);
orgindex := ref.index;
freeindex := true;
@ -2455,7 +2489,11 @@ begin
end.
{
$Log$
Revision 1.133 2003-10-17 15:25:18 florian
Revision 1.134 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.133 2003/10/17 15:25:18 florian
* fixed more ppc stuff
Revision 1.132 2003/10/17 15:08:34 peter

View File

@ -122,7 +122,7 @@ uses
first_fpu_imreg = $20;
{ MM Super register first and last }
first_mm_imreg = $0;
first_mm_imreg = $20;
{$warning TODO Calculate bsstart}
regnumber_count_bsstart = 64;
@ -714,7 +714,11 @@ implementation
end.
{
$Log$
Revision 1.72 2003-10-17 15:08:34 peter
Revision 1.73 2003-10-19 01:34:31 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.72 2003/10/17 15:08:34 peter
* commented out more obsolete constants
Revision 1.71 2003/10/11 16:06:42 florian

View File

@ -660,7 +660,7 @@ implementation
aktfilepos:=exitpos;
aktlocalswitches:=exitswitches;
gen_finalize_code(templist,false);
{ the finalcode must be concatted if there was no position available,
{ the finalcode must be concated if there was no position available,
using insertlistafter will result in an insert at the start
when currentai=nil }
if assigned(tasmnode(finalasmnode).currenttai) then
@ -1260,12 +1260,14 @@ implementation
end;
begin
cprocinfo:=tcgprocinfo;
end.
{
$Log$
Revision 1.163 2003-10-17 14:38:32 peter
Revision 1.164 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.163 2003/10/17 14:38:32 peter
* 64k registers supported
* fixed some memory leaks

View File

@ -196,6 +196,7 @@ unit rgobj;
Afirst_imaginary:Tsuperregister;
Apreserved_by_proc:Tcpuregisterset);
destructor destroy;override;
{# Allocate a register. An internalerror will be generated if there is
no more free registers which can be allocated.}
function getregister(list:Taasmoutput;subreg:Tsubregister):Tregister;
@ -233,11 +234,12 @@ unit rgobj;
{# Adds an interference edge.}
procedure add_edge(u,v:Tsuperregister);
unusedregs : Tsuperregisterset;
protected
regtype : Tregistertype;
{ default subregister used }
defaultsub : tsubregister;
unusedregs : Tsuperregisterset;
{# First imaginary register.}
first_imaginary : Tsuperregister;
{# Highest register allocated until now.}
@ -311,6 +313,8 @@ implementation
destructor tsuperregisterworklist.done;
begin
if assigned(buf) then
freemem(buf);
end;
@ -505,6 +509,9 @@ implementation
var
i : Tsuperregister;
begin
{ empty super register sets can cause very strange problems }
if high(Ausable)=0 then
internalerror(200210181);
first_imaginary:=Afirst_imaginary;
maxreg:=Afirst_imaginary;
regtype:=Aregtype;
@ -524,9 +531,8 @@ implementation
worklist_moves:=Tlinkedlist.create;
{ Usable registers }
fillchar(usable_registers,sizeof(usable_registers),0);
if high(Ausable)>0 then
for i:=low(Ausable) to high(Ausable) do
usable_registers[i]:=Ausable[i];
for i:=low(Ausable) to high(Ausable) do
usable_registers[i]:=Ausable[i];
usable_registers_cnt:=high(Ausable)+1;
{ Initialize Worklists }
spillednodes.init;
@ -1660,7 +1666,7 @@ implementation
end;
end;
p:=Tai(p.next);
end;
end;
aktfilepos:=current_procinfo.exitpos;
i:=spillednodes.head;
while (i<>spillednodes.tail) do
@ -1765,7 +1771,11 @@ end;
end.
{
$Log$
Revision 1.88 2003-10-18 15:41:26 peter
Revision 1.89 2003-10-19 01:34:30 florian
* some ppc stuff fixed
* memory leak fixed
Revision 1.88 2003/10/18 15:41:26 peter
* made worklists dynamic in size
Revision 1.87 2003/10/17 16:16:08 peter