* fixed code generation after recent changes of int_cgsize()

* initial code generation for gprof

git-svn-id: trunk@3271 -
This commit is contained in:
tom_at_work 2006-04-18 10:27:11 +00:00
parent b64981a704
commit f31ede0b12
5 changed files with 37 additions and 28 deletions

View File

@ -99,6 +99,7 @@ type
procedure g_flags2reg(list: TAsmList; size: TCgSize; const f: TResFlags;
reg: TRegister); override;
procedure g_profilecode(list: TAsmList); override;
procedure g_proc_entry(list: TAsmList; localsize: longint; nostackframe:
boolean); override;
procedure g_proc_exit(list: TAsmList; parasize: longint; nostackframe:
@ -182,7 +183,7 @@ uses
sysutils,
globals, verbose, systems, cutils,
symconst, symsym, fmodule,
rgobj, tgobj, cpupi, procinfo, paramgr;
rgobj, tgobj, cpupi, procinfo, paramgr, cpupara;
function ref2string(const ref : treference) : string;
begin
@ -1299,6 +1300,14 @@ begin
end;
end;
procedure tcgppc.g_profilecode(list: TAsmList);
begin
// TODO: save GPRs
a_call_name_direct(list, '_mcount', false, true);
// TODO: restore GPRs
end;
{ Generates the entry code of a procedure/function.
This procedure may be called before, as well as after g_return_from_proc
@ -1356,12 +1365,12 @@ var
end;
{ VMX registers not supported by FPC atm }
{ in this branch we may always need to store LR ourselves}
{ in this branch we always need to store LR ourselves}
mayNeedLRStore := true;
end;
{ we may need to store R0 (=LR) ourselves }
if (mayNeedLRStore) and (needslinkreg) then begin
if ((cs_profile in initmoduleswitches) or (mayNeedLRStore)) and (needslinkreg) then begin
reference_reset_base(href, NR_STACK_POINTER_REG, LA_LR_ELF);
list.concat(taicpu.op_reg_ref(A_STD, NR_R0, href));
end;
@ -1369,7 +1378,6 @@ var
var
href: treference;
begin
calcFirstUsedFPR(firstregfpu, fprcount);
calcFirstUsedGPR(firstreggpr, gprcount);
@ -1380,7 +1388,8 @@ begin
{ determine whether we need to save the link register }
needslinkreg :=
((not (po_assembler in current_procinfo.procdef.procoptions)) and (pi_do_call in current_procinfo.flags)) or
((not (po_assembler in current_procinfo.procdef.procoptions)) and
((pi_do_call in current_procinfo.flags) or (cs_profile in initmoduleswitches))) or
((cs_opt_size in aktoptimizerswitches) and ((fprcount > 0) or (gprcount > 0))) or
([cs_lineinfo, cs_debuginfo] * aktmoduleswitches <> []);
@ -1518,7 +1527,8 @@ begin
{ determine whether we need to restore the link register }
needslinkreg :=
((not (po_assembler in current_procinfo.procdef.procoptions)) and (pi_do_call in current_procinfo.flags)) or
((not (po_assembler in current_procinfo.procdef.procoptions)) and
((pi_do_call in current_procinfo.flags) or (cs_profile in initmoduleswitches))) or
((cs_opt_size in aktoptimizerswitches) and ((fprcount > 0) or (gprcount > 0))) or
([cs_lineinfo, cs_debuginfo] * aktmoduleswitches <> []);

View File

@ -348,7 +348,8 @@ const
stdcall and cdecl. The alignment value should be the one defined
by GCC or the target ABI.
}
std_param_align = 16;
std_param_align = 8;
vmx_std_param_align = 16;
{*****************************************************************************
CPU Dependent Constants

View File

@ -90,7 +90,7 @@ begin
with paraloc^ do begin
size := OS_INT;
if (nr <= 8) then begin
if nr = 0 then
if (nr = 0) then
internalerror(200309271);
loc := LOC_REGISTER;
register := newreg(R_INTREGISTER, RS_R2 + nr, R_SUBWHOLE);
@ -248,10 +248,9 @@ end;
function tppcparamanager.create_paraloc_info(p: tabstractprocdef; side:
tcallercallee): longint;
var
cur_stack_offset: aword;
curintreg, curfloatreg, curmmreg: tsuperregister;
curintreg, curfloatreg, curmmreg : tsuperregister;
begin
init_values(curintreg, curfloatreg, curmmreg, cur_stack_offset);
@ -265,7 +264,6 @@ function tppcparamanager.create_paraloc_info_intern(p: tabstractprocdef; side:
tcallercallee; paras: tparalist;
var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset:
aword; isVararg : boolean): longint;
var
stack_offset: longint;
paralen: aint;
@ -280,6 +278,7 @@ var
parashift : byte;
begin
//writeln('begin create_paraloc_info');
{$IFDEF extdebug}
if po_explicitparaloc in p.procoptions then
internalerror(200411141);
@ -341,7 +340,7 @@ begin
loc := LOC_REGISTER;
paracgsize := int_cgsize(paralen);
if (paralen in [3,5,6,7]) then
parashift := (tcgsize2size[paracgsize]-paralen) * 8;
parashift := (8-paralen) * 8;
end;
end else begin
loc := getparaloc(paradef);
@ -382,14 +381,13 @@ begin
paraloc^.loc := loc;
paraloc^.shiftval := parashift;
if (paracgsize <> OS_NO) then
{ make sure we don't lose whether or not the type is signed }
if (paradef.deftype <> orddef) then
paraloc^.size := int_cgsize(paralen)
else
paraloc^.size := paracgsize
else
paraloc^.size := OS_INT;
{ make sure we don't lose whether or not the type is signed }
if (paracgsize <> OS_NO) and (paradef.deftype <> orddef) then
paracgsize := int_cgsize(paralen);
if (paracgsize = OS_NO) then
paraloc^.size := OS_INT
else
paraloc^.size := paracgsize;
paraloc^.register := newreg(R_INTREGISTER, nextintreg, R_SUBNONE);
inc(nextintreg);
@ -406,7 +404,7 @@ begin
inc(nextintreg);
inc(nextfloatreg);
dec(paralen, tcgsize2size[paraloc^.size]);
inc(stack_offset, tcgsize2size[OS_FLOAT]);
end else if (loc = LOC_MMREGISTER) then begin
{ Altivec not supported }
@ -444,7 +442,7 @@ function tppcparamanager.create_varargs_paraloc_info(p: tabstractprocdef;
var
cur_stack_offset: aword;
parasize, l: longint;
curintreg, firstfloatreg, curfloatreg, curmmreg: tsuperregister;
curintreg, firstfloatreg, curfloatreg, curmmreg: tsuperregister;
i: integer;
hp: tparavarsym;
paraloc: pcgparalocation;

View File

@ -68,14 +68,14 @@ var
begin
if not (po_assembler in procdef.procoptions) then begin
{ align the stack properly }
ofs := align(maxpushedparasize + LinkageAreaSizeELF, 8);
ofs := align(maxpushedparasize + LinkageAreaSizeELF, ELF_STACK_ALIGN);
{ the ABI specification says that it is required to always allocate space for 8 * 8 bytes
for registers R3-R10 and stack header if there's a stack frame, but GCC doesn't do that,
so we don't that too. Uncomment the next three lines if this is required }
// if (ofs < 112) then begin
// ofs := 112;
// end;
if (cs_profile in initmoduleswitches) and (ofs < 112) then begin
ofs := 112;
end;
tg.setfirsttemp(ofs);
end else begin
locals := 0;
@ -100,7 +100,7 @@ begin
numfpr * tcgsize2size[OS_FLOAT], ELF_STACK_ALIGN);
if (pi_do_call in flags) or (tg.lasttemp <> tg.firsttemp) or
(result > RED_ZONE_SIZE) then begin
(result > RED_ZONE_SIZE) {or (cs_profile in initmoduleswitches)} then begin
result := align(result + tg.lasttemp, ELF_STACK_ALIGN);
end;
end else

View File

@ -79,7 +79,7 @@ begin
// everything that is less than 64 bits is converted to a 64 bit signed
// integer - because the int_to_real conversion is faster for 64 bit
// signed ints compared to 64 bit unsigned ints.
if (not (torddef(left.resulttype.def).typ in [s64bit, u64bit])) then begin
if (not (torddef(left.resulttype.def).typ in [s64bit, u64bit, scurrency])) then begin
inserttypeconv(left, s64inttype);
end;
end;