From 9c476ba5f1d3c416a371d844952f4cdb2461bed2 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 24 Dec 2003 00:10:02 +0000 Subject: [PATCH] - delete parameter in cg64 methods removed --- compiler/cg64f32.pas | 40 +++-- compiler/cg64f64.pas | 15 +- compiler/cgobj.pas | 15 +- compiler/i386/cgcpu.pas | 9 +- compiler/i386/n386add.pas | 10 +- compiler/i386/rgcpu.pas | 185 +---------------------- compiler/ncgld.pas | 7 +- compiler/ncgutil.pas | 15 +- compiler/x86/cgx86.pas | 9 +- compiler/x86_64/cpupara.pas | 34 +++-- compiler/x86_64/rgcpu.pas | 285 ++---------------------------------- 11 files changed, 100 insertions(+), 524 deletions(-) diff --git a/compiler/cg64f32.pas b/compiler/cg64f32.pas index 85f77e102b..5b646ed7d7 100644 --- a/compiler/cg64f32.pas +++ b/compiler/cg64f32.pas @@ -50,10 +50,10 @@ unit cg64f32; procedure a_reg_dealloc(list : taasmoutput;r : tregister64);override; procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);override; procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);override; - procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64;delete:boolean);override; - procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64;delete:boolean);override; + procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);override; + procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);override; procedure a_load64_const_reg(list : taasmoutput;value: qword;reg : tregister64);override; - procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64;delete: boolean);override; + procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);override; procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);override; procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);override; procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);override; @@ -157,7 +157,7 @@ unit cg64f32; end; - procedure tcg64f32.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64;delete:boolean); + procedure tcg64f32.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64); var tmpreg: tregister; tmpref: treference; @@ -191,25 +191,16 @@ unit cg64f32; end; cg.a_load_ref_reg(list,OS_32,OS_32,tmpref,reg.reglo); inc(tmpref.offset,4); - if delete then - begin - tg.ungetiftemp(list,tmpref); - reference_release(list,tmpref); - end; cg.a_load_ref_reg(list,OS_32,OS_32,tmpref,reg.reghi); if got_scratch then cg.ungetregister(list,tmpreg); end; - procedure tcg64f32.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64;delete:boolean); + procedure tcg64f32.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64); begin - if delete then - cg.ungetregister(list,regsrc.reglo); cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reglo,regdst.reglo); - if delete then - cg.ungetregister(list,regsrc.reghi); cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reghi,regdst.reghi); end; @@ -222,14 +213,14 @@ unit cg64f32; end; - procedure tcg64f32.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64;delete :boolean); + procedure tcg64f32.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64); begin case l.loc of LOC_REFERENCE, LOC_CREFERENCE: - a_load64_ref_reg(list,l.reference,reg,delete); + a_load64_ref_reg(list,l.reference,reg); LOC_REGISTER,LOC_CREGISTER: - a_load64_reg_reg(list,l.register64,reg,delete); + a_load64_reg_reg(list,l.register64,reg); LOC_CONSTANT : a_load64_const_reg(list,l.valueqword,reg); else @@ -272,7 +263,7 @@ unit cg64f32; LOC_REFERENCE, LOC_CREFERENCE: a_load64_reg_ref(list,reg,l.reference); LOC_REGISTER,LOC_CREGISTER: - a_load64_reg_reg(list,reg,l.register64,false); + a_load64_reg_reg(list,reg,l.register64); else internalerror(200112293); end; @@ -417,7 +408,7 @@ unit cg64f32; begin tempreg.reghi:=cg.getintregister(list,OS_INT); tempreg.reglo:=cg.getintregister(list,OS_INT); - a_load64_ref_reg(list,ref,tempreg,false); + a_load64_ref_reg(list,ref,tempreg); a_op64_reg_reg(list,op,tempreg,reg); cg.ungetregister(list,tempreg.reglo); cg.ungetregister(list,tempreg.reghi); @@ -430,7 +421,7 @@ unit cg64f32; begin tempreg.reghi:=cg.getintregister(list,OS_INT); tempreg.reglo:=cg.getintregister(list,OS_INT); - a_load64_ref_reg(list,ref,tempreg,false); + a_load64_ref_reg(list,ref,tempreg); a_op64_reg_reg(list,op,reg,tempreg); a_load64_reg_ref(list,tempreg,ref); cg.ungetregister(list,tempreg.reglo); @@ -444,7 +435,7 @@ unit cg64f32; begin tempreg.reghi:=cg.getintregister(list,OS_INT); tempreg.reglo:=cg.getintregister(list,OS_INT); - a_load64_ref_reg(list,ref,tempreg,false); + a_load64_ref_reg(list,ref,tempreg); a_op64_const_reg(list,op,value,tempreg); a_load64_reg_ref(list,tempreg,ref); cg.ungetregister(list,tempreg.reglo); @@ -569,7 +560,7 @@ unit cg64f32; if (temploc.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and (target_info.endian = endian_big) then inc(temploc.reference.offset,4); - + cg.g_rangecheck(list,temploc,hdef,todef); hdef.free; @@ -765,7 +756,10 @@ begin end. { $Log$ - Revision 1.55 2003-12-07 15:00:45 jonas + Revision 1.56 2003-12-24 00:10:02 florian + - delete parameter in cg64 methods removed + + Revision 1.55 2003/12/07 15:00:45 jonas * fixed g_rangecheck64 so it works again for big endian Revision 1.54 2003/12/06 01:15:22 florian diff --git a/compiler/cg64f64.pas b/compiler/cg64f64.pas index e17663af67..35c41a07d2 100644 --- a/compiler/cg64f64.pas +++ b/compiler/cg64f64.pas @@ -77,7 +77,7 @@ unit cg64f64; function optimize64_op_const_reg(list: taasmoutput; var op: topcg; var a : qword; var reg: tregister64): boolean;override; { override to catch 64bit rangechecks } - procedure g_rangecheck64(list: taasmoutput; const l: tlocation;fromdef,todef: tdef); override; + procedure g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef); override; end; implementation @@ -89,12 +89,12 @@ unit cg64f64; procedure tcg64f64.a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference); begin - cg.a_load_reg_ref(list,OS_64,reg,ref); + cg.a_load_reg_ref(list,OS_64,OS_64,reg,ref); end; procedure tcg64f64.a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64); begin - cg.a_load_ref_reg(list,OS_64,ref,reg); + cg.a_load_ref_reg(list,OS_64,OS_64,ref,reg); end; procedure tcg64f64.a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64); @@ -114,7 +114,7 @@ unit cg64f64; procedure tcg64f64.a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference); begin - cg.a_load_loc_ref(list,l,ref); + cg.a_load_loc_ref(list,l.size,l,ref); end; procedure tcg64f64.a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation); @@ -197,7 +197,7 @@ unit cg64f64; begin end; - procedure tcg64f64.g_rangecheck64(list: taasmoutput; const p: tnode;def: tdef); + procedure tcg64f64.g_rangecheck64(list: taasmoutput; const l:tlocation;fromdef,todef: tdef); begin end; @@ -223,7 +223,10 @@ unit cg64f64; end. { $Log$ - Revision 1.9 2003-12-22 19:00:17 florian + Revision 1.10 2003-12-24 00:10:02 florian + - delete parameter in cg64 methods removed + + Revision 1.9 2003/12/22 19:00:17 florian * fixed some x86-64 issues Revision 1.8 2003/06/03 21:11:09 peter diff --git a/compiler/cgobj.pas b/compiler/cgobj.pas index ecc28b7ed2..609c20e8eb 100644 --- a/compiler/cgobj.pas +++ b/compiler/cgobj.pas @@ -456,10 +456,10 @@ unit cgobj; procedure a_reg_dealloc(list : taasmoutput;r : tregister64);virtual;abstract; procedure a_load64_const_ref(list : taasmoutput;value : qword;const ref : treference);virtual;abstract; procedure a_load64_reg_ref(list : taasmoutput;reg : tregister64;const ref : treference);virtual;abstract; - procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64;delete : boolean);virtual;abstract; - procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64;delete : boolean);virtual;abstract; + procedure a_load64_ref_reg(list : taasmoutput;const ref : treference;reg : tregister64);virtual;abstract; + procedure a_load64_reg_reg(list : taasmoutput;regsrc,regdst : tregister64);virtual;abstract; procedure a_load64_const_reg(list : taasmoutput;value : qword;reg : tregister64);virtual;abstract; - procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64;delete : boolean);virtual;abstract; + procedure a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);virtual;abstract; procedure a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);virtual;abstract; procedure a_load64_const_loc(list : taasmoutput;value : qword;const l : tlocation);virtual;abstract; procedure a_load64_reg_loc(list : taasmoutput;reg : tregister64;const l : tlocation);virtual;abstract; @@ -1883,14 +1883,14 @@ implementation procedure tcg64.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword; regsrc,regdst : tregister64); begin - a_load64_reg_reg(list,regsrc,regdst,false); + a_load64_reg_reg(list,regsrc,regdst); a_op64_const_reg(list,op,value,regdst); end; procedure tcg64.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64); begin - a_load64_reg_reg(list,regsrc2,regdst,false); + a_load64_reg_reg(list,regsrc2,regdst); a_op64_reg_reg(list,op,regsrc1,regdst); end; @@ -2000,7 +2000,10 @@ finalization end. { $Log$ - Revision 1.143 2003-12-23 14:38:07 florian + Revision 1.144 2003-12-24 00:10:02 florian + - delete parameter in cg64 methods removed + + Revision 1.143 2003/12/23 14:38:07 florian + second_floataddsse implemented Revision 1.142 2003/12/22 19:00:17 florian diff --git a/compiler/i386/cgcpu.pas b/compiler/i386/cgcpu.pas index e7b75b5e4d..14cd4e6777 100644 --- a/compiler/i386/cgcpu.pas +++ b/compiler/i386/cgcpu.pas @@ -155,7 +155,7 @@ unit cgcpu; OP_NEG : begin if (regsrc.reglo<>regdst.reglo) then - a_load64_reg_reg(list,regsrc,regdst,false); + a_load64_reg_reg(list,regsrc,regdst); list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reghi)); list.concat(taicpu.op_reg(A_NEG,S_L,regdst.reglo)); list.concat(taicpu.op_const_reg(A_SBB,S_L,aword(-1),regdst.reghi)); @@ -164,7 +164,7 @@ unit cgcpu; OP_NOT : begin if (regsrc.reglo<>regdst.reglo) then - a_load64_reg_reg(list,regsrc,regdst,false); + a_load64_reg_reg(list,regsrc,regdst); list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reghi)); list.concat(taicpu.op_reg(A_NOT,S_L,regdst.reglo)); exit; @@ -232,7 +232,10 @@ begin end. { $Log$ - Revision 1.41 2003-12-19 22:08:44 daniel + Revision 1.42 2003-12-24 00:10:02 florian + - delete parameter in cg64 methods removed + + Revision 1.41 2003/12/19 22:08:44 daniel * Some work to restore the MMX capabilities Revision 1.40 2003/10/10 17:48:14 peter diff --git a/compiler/i386/n386add.pas b/compiler/i386/n386add.pas index 03145b26a7..45acdfb0cd 100644 --- a/compiler/i386/n386add.pas +++ b/compiler/i386/n386add.pas @@ -884,7 +884,7 @@ interface pushedfpu, mboverflow, cmpop, - unsigned,delete:boolean; + unsigned:boolean; r:Tregister; procedure firstjmp64bitcmp; @@ -1010,10 +1010,9 @@ interface { we can reuse a CREGISTER for comparison } if not((left.location.loc=LOC_CREGISTER) and cmpop) then begin - delete:=left.location.loc<>LOC_CREGISTER; hregister:=cg.getintregister(exprasmlist,OS_INT); hregister2:=cg.getintregister(exprasmlist,OS_INT); - cg64.a_load64_loc_reg(exprasmlist,left.location,joinreg64(hregister,hregister2),delete); + cg64.a_load64_loc_reg(exprasmlist,left.location,joinreg64(hregister,hregister2)); location_reset(left.location,LOC_REGISTER,OS_64); left.location.registerlow:=hregister; left.location.registerhigh:=hregister2; @@ -1589,7 +1588,10 @@ begin end. { $Log$ - Revision 1.90 2003-12-23 22:13:41 peter + Revision 1.91 2003-12-24 00:10:02 florian + - delete parameter in cg64 methods removed + + Revision 1.90 2003/12/23 22:13:41 peter * overlfow support in second_mul Revision 1.89 2003/12/21 11:28:41 daniel diff --git a/compiler/i386/rgcpu.pas b/compiler/i386/rgcpu.pas index 9251ef3acf..bca418f225 100644 --- a/compiler/i386/rgcpu.pas +++ b/compiler/i386/rgcpu.pas @@ -32,62 +32,13 @@ unit rgcpu; cpubase, cpuinfo, aasmbase,aasmtai, - cclasses,globtype,cgbase,rgobj; + cclasses,globtype,cgbase,rgobj,rgx86; type trgcpu = class(trgobj) procedure add_constraints(reg:Tregister);override; end; - tpushedsavedloc = record - case byte of - 0: (pushed: boolean); - 1: (ofs: longint); - end; - - tpushedsavedfpu = array[tsuperregister] of tpushedsavedloc; - - trgx86fpu = class - { The "usableregsxxx" contain all registers of type "xxx" that } - { aren't currently allocated to a regvar. The "unusedregsxxx" } - { contain all registers of type "xxx" that aren't currently } - { allocated } - unusedregsfpu,usableregsfpu : Tsuperregisterset; - { these counters contain the number of elements in the } - { unusedregsxxx/usableregsxxx sets } - countunusedregsfpu : byte; - - { Contains the registers which are really used by the proc itself. - It doesn't take care of registers used by called procedures - } - used_in_proc : tcpuregisterset; - - {reg_pushes_other : regvarother_longintarray; - is_reg_var_other : regvarother_booleanarray; - regvar_loaded_other : regvarother_booleanarray;} - - { tries to hold the amount of times which the current tree is processed } - t_times: longint; - - fpuvaroffset : byte; - - constructor create; - - function getregisterfpu(list: taasmoutput) : tregister; - procedure ungetregisterfpu(list: taasmoutput; r : tregister); - - { pushes and restores registers } - procedure saveusedfpuregisters(list:Taasmoutput; - var saved:Tpushedsavedfpu; - const s:Tcpuregisterset); - procedure restoreusedfpuregisters(list:Taasmoutput; - const saved:Tpushedsavedfpu); - - { corrects the fpu stack register by ofs } - function correct_fpuregister(r : tregister;ofs : byte) : tregister; - end; - - implementation uses @@ -118,139 +69,13 @@ implementation end; -{****************************************************************************** - Trgobj -******************************************************************************} - - constructor Trgx86fpu.create; - - var i:Tsuperregister; - - begin - used_in_proc:=[]; - t_times := 0; - unusedregsfpu:=usableregsfpu; - end; - - - function trgx86fpu.getregisterfpu(list: taasmoutput) : tregister; - - begin - { note: don't return R_ST0, see comments above implementation of } - { a_loadfpu_* methods in cgcpu (JM) } - result:=NR_ST; - end; - - - procedure trgx86fpu.ungetregisterfpu(list : taasmoutput; r : tregister); - - begin - { nothing to do, fpu stack management is handled by the load/ } - { store operations in cgcpu (JM) } - end; - - - - function trgx86fpu.correct_fpuregister(r : tregister;ofs : byte) : tregister; - - begin - correct_fpuregister:=r; - setsupreg(correct_fpuregister,ofs); - end; - - - procedure trgx86fpu.saveusedfpuregisters(list: taasmoutput; - var saved : tpushedsavedfpu; - const s: tcpuregisterset); - var - r : tregister; - hr : treference; - begin - used_in_proc:=used_in_proc+s; - -{$warning TODO firstsavefpureg} -(* - { don't try to save the fpu registers if not desired (e.g. for } - { the 80x86) } - if firstsavefpureg <> R_NO then - for r.enum:=firstsavefpureg to lastsavefpureg do - begin - saved[r.enum].ofs:=reg_not_saved; - { if the register is used by the calling subroutine and if } - { it's not a regvar (those are handled separately) } - if not is_reg_var_other[r.enum] and - (r.enum in s) and - { and is present in use } - not(r.enum in unusedregsfpu) then - begin - { then save it } - tg.GetTemp(list,extended_size,tt_persistent,hr); - saved[r.enum].ofs:=hr.offset; - cg.a_loadfpu_reg_ref(list,OS_FLOAT,r,hr); - cg.a_reg_dealloc(list,r); - include(unusedregsfpu,r.enum); - inc(countunusedregsfpu); - end; - end; -*) - end; - - - procedure trgx86fpu.restoreusedfpuregisters(list : taasmoutput; - const saved : tpushedsavedfpu); - - var - r,r2 : tregister; - hr : treference; - - begin -{$warning TODO firstsavefpureg} -(* - if firstsavefpureg <> R_NO then - for r.enum:=lastsavefpureg downto firstsavefpureg do - begin - if saved[r.enum].ofs <> reg_not_saved then - begin - r2.enum:=R_INTREGISTER; - r2.number:=NR_FRAME_POINTER_REG; - reference_reset_base(hr,r2,saved[r.enum].ofs); - cg.a_reg_alloc(list,r); - cg.a_loadfpu_ref_reg(list,OS_FLOAT,hr,r); - if not (r.enum in unusedregsfpu) then - { internalerror(10) - in n386cal we always save/restore the reg *state* - using save/restoreunusedstate -> the current state - may not be real (JM) } - else - begin - dec(countunusedregsfpu); - exclude(unusedregsfpu,r.enum); - end; - tg.UnGetTemp(list,hr); - end; - end; -*) - end; - -(* - procedure Trgx86fpu.saveotherregvars(list: taasmoutput; const s: totherregisterset); - var - r: Tregister; - begin - if not(cs_regvars in aktglobalswitches) then - exit; - if firstsavefpureg <> NR_NO then - for r.enum := firstsavefpureg to lastsavefpureg do - if is_reg_var_other[r.enum] and - (r.enum in s) then - store_regvar(list,r); - end; -*) - end. { $Log$ - Revision 1.40 2003-10-17 15:08:34 peter + Revision 1.41 2003-12-24 00:10:02 florian + - delete parameter in cg64 methods removed + + Revision 1.40 2003/10/17 15:08:34 peter * commented out more obsolete constants Revision 1.39 2003/10/17 14:38:32 peter diff --git a/compiler/ncgld.pas b/compiler/ncgld.pas index 09bc4aaa96..68f5c9ad9d 100644 --- a/compiler/ncgld.pas +++ b/compiler/ncgld.pas @@ -552,7 +552,7 @@ implementation if cgsize in [OS_64,OS_S64] then begin cg64.a_load64_ref_reg(exprasmlist, - right.location.reference,left.location.register64,false); + right.location.reference,left.location.register64); location_release(exprasmlist,right.location); end else @@ -892,7 +892,10 @@ begin end. { $Log$ - Revision 1.102 2003-12-06 01:15:22 florian + Revision 1.103 2003-12-24 00:10:02 florian + - delete parameter in cg64 methods removed + + Revision 1.102 2003/12/06 01:15:22 florian * reverted Peter's alloctemp patch; hopefully properly Revision 1.101 2003/12/03 23:13:20 peter diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index c45c0b7fe7..b88f679315 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -414,7 +414,7 @@ implementation hreg64.reglo:=hregister; hreg64.reghi:=hregisterhi; { load value in new register } - cg64.a_load64_loc_reg(list,l,hreg64,false); + cg64.a_load64_loc_reg(list,l,hreg64); location_reset(l,LOC_REGISTER,dst_size); l.registerlow:=hregister; l.registerhigh:=hregisterhi; @@ -1057,7 +1057,7 @@ implementation cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_LOW_REG); cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_HIGH_REG); cg64.a_load64_loc_reg(list,resloc,joinreg64(NR_FUNCTION_RETURN64_LOW_REG, - NR_FUNCTION_RETURN64_HIGH_REG),false); + NR_FUNCTION_RETURN64_HIGH_REG)); end else {$endif cpu64bit} @@ -1098,7 +1098,7 @@ implementation cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_LOW_REG); cg.a_reg_alloc(list,NR_FUNCTION_RETURN64_HIGH_REG); cg64.a_load64_loc_reg(list,resloc,joinreg64(NR_FUNCTION_RETURN64_LOW_REG, - NR_FUNCTION_RETURN64_HIGH_REG),false); + NR_FUNCTION_RETURN64_HIGH_REG)); end else {$endif cpu64bit} @@ -1627,7 +1627,7 @@ implementation begin r:=cg.getregisterint(list,OS_INT); r2:=cg.getregisterint(list,OS_INT); - cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2),false); + cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2)); end else {$endif cpu64bit} @@ -1656,7 +1656,7 @@ implementation begin r:=cg.getregisterint(list,OS_INT); r2:=cg.getregisterint(list,OS_INT); - cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2),false); + cg64.a_load64_loc_reg(list,resloc,joinreg64(r,r2)); end else {$endif cpu64bit} @@ -2019,7 +2019,10 @@ implementation end. { $Log$ - Revision 1.176 2003-12-23 14:38:07 florian + Revision 1.177 2003-12-24 00:10:02 florian + - delete parameter in cg64 methods removed + + Revision 1.176 2003/12/23 14:38:07 florian + second_floataddsse implemented Revision 1.175 2003/12/22 19:00:17 florian diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas index ddbbfc8fac..d78828264f 100644 --- a/compiler/x86/cgx86.pas +++ b/compiler/x86/cgx86.pas @@ -31,7 +31,7 @@ unit cgx86; uses cgbase,cgobj, aasmbase,aasmtai,aasmcpu, - cpubase,cpuinfo,rgobj,rgcpu, + cpubase,cpuinfo,rgobj,rgx86,rgcpu, symconst,symtype; type @@ -804,7 +804,7 @@ unit cgx86; } {$ifdef x86_64} ( { OS_F64 } - A_NOP,A_ADDSD,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP + A_NOP,{!!! A_ADDSD}A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP,A_NOP ) {$else x86_64} ( { OS_F64 } @@ -1901,7 +1901,10 @@ unit cgx86; end. { $Log$ - Revision 1.93 2003-12-21 19:42:43 florian + Revision 1.94 2003-12-24 00:10:03 florian + - delete parameter in cg64 methods removed + + Revision 1.93 2003/12/21 19:42:43 florian * fixed ppc inlining stuff * fixed wrong unit writing + added some sse stuff diff --git a/compiler/x86_64/cpupara.pas b/compiler/x86_64/cpupara.pas index fd4573e04c..94e008b848 100644 --- a/compiler/x86_64/cpupara.pas +++ b/compiler/x86_64/cpupara.pas @@ -29,8 +29,10 @@ unit cpupara; interface uses - cpubase, - symconst,symbase,symtype,symdef,paramgr; + globtype, + cpubase, + symconst,symbase,symtype,symdef, + paramgr; type { Returns the location for the nr-st 32 Bit int parameter @@ -39,18 +41,20 @@ unit cpupara; rtl are used. } tx86_64paramanager = class(tparamanager) - function getintparaloc(nr : longint) : tparalocation;override; - procedure create_param_loc_info(p : tabstractprocdef);override; + function getintparaloc(calloption : tproccalloption; nr : longint) : tparalocation;override; + function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override; end; implementation uses verbose, - globtype, - cpuinfo,cginfo,cgbase, + cpuinfo,cgbase, defutil; + const + intreg_nr2reg : array[1..6] of tsuperregister = (RS_RDI,RS_RSI,RS_RDX,RS_RCX,RS_R8,RS_R9); + function getparaloc(p : tdef) : tcgloc; begin @@ -116,9 +120,7 @@ unit cpupara; end; end; - function tx86_64paramanager.getintparaloc(nr : longint) : tparalocation; - const - nr2reg : array[1..6] of word = (NR_RDI,NR_RSI,NR_RDX,NR_RCX,NR_R8,NR_R9); + function tx86_64paramanager.getintparaloc(calloption : tproccalloption; nr : longint): tparalocation; begin fillchar(result,sizeof(tparalocation),0); if nr<1 then @@ -126,19 +128,18 @@ unit cpupara; else if nr<=6 then begin result.loc:=LOC_REGISTER; - result.register.enum:=R_INTREGISTER; - result.register.number:=nr2reg[nr]; + result.register:=newreg(R_INTREGISTER,intreg_nr2reg[nr],R_SUBWHOLE); end else begin result.loc:=LOC_REFERENCE; - result.reference.index.enum:=R_INTREGISTER; - result.reference.index.number:=NR_STACK_POINTER_REG; + result.reference.index:=NR_STACK_POINTER_REG; result.reference.offset:=(nr-6)*8; end; end; - procedure tx86_64paramanager.create_param_loc_info(p : tabstractprocdef); + + function tx86_64paramanager.create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint; begin { set default para_alignment to target_info.stackalignment } { if para_alignment=0 then @@ -152,7 +153,10 @@ begin end. { $Log$ - Revision 1.4 2003-04-30 20:53:32 florian + Revision 1.5 2003-12-24 00:10:03 florian + - delete parameter in cg64 methods removed + + Revision 1.4 2003/04/30 20:53:32 florian * error when address of an abstract method is taken * fixed some x86-64 problems * merged some more x86-64 and i386 code diff --git a/compiler/x86_64/rgcpu.pas b/compiler/x86_64/rgcpu.pas index 1a452096e7..7d5192d49d 100644 --- a/compiler/x86_64/rgcpu.pas +++ b/compiler/x86_64/rgcpu.pas @@ -2,7 +2,7 @@ $Id$ Copyright (c) 1998-2002 by Florian Klaempfl - This unit implements the i386 specific class for the register + This unit implements the x86-64 specific class for the register allocator This program is free software; you can redistribute it and/or modify @@ -28,288 +28,21 @@ unit rgcpu; interface - uses - cpubase, - cpuinfo, - aasmbase,aasmtai,aasmcpu, - cclasses,globtype,cgbase,cginfo,rgobj; + uses + aasmbase,aasmtai, + cpubase, + rgobj; - type + type trgcpu = class(trgobj) - fpuvaroffset : byte; - - function getregisterfpu(list: taasmoutput;size:TCGSize) : tregister; override; - procedure ungetregisterfpu(list: taasmoutput; r : tregister;size:TCGSize); override; - - {# Returns a subset register of the register r with the specified size. - WARNING: There is no clearing of the upper parts of the register, - if a 8-bit / 16-bit register is converted to a 32-bit register. - It is up to the code generator to correctly zero fill the register - } - function makeregsize(reg: tregister; size: tcgsize): tregister; override; - - { pushes and restores registers } -{$ifdef SUPPORT_MMX} - procedure pushusedotherregisters(list:Taasmoutput; - var pushed:Tpushedsavedother; - const s:Totherregisterset); -{$endif SUPPORT_MMX} -{$ifdef SUPPORT_MMX} - procedure popusedotherregisters(list:Taasmoutput; - const pushed:Tpushedsavedother); -{$endif SUPPORT_MMX} - - procedure saveusedotherregisters(list:Taasmoutput; - var saved:Tpushedsavedother; - const s:Totherregisterset);override; - procedure restoreusedotherregisters(list:Taasmoutput; - const saved:Tpushedsavedother);override; - - procedure resetusableregisters;override; - - { corrects the fpu stack register by ofs } - function correct_fpuregister(r : tregister;ofs : byte) : tregister; end; - implementation - uses - systems, - globals,verbose, - tgobj; - - function trgcpu.getregisterfpu(list: taasmoutput;size: TCGSize) : tregister; - - begin - { note: don't return R_ST0, see comments above implementation of } - { a_loadfpu_* methods in cgcpu (JM) } - result:=NR_ST; - end; - - - procedure trgcpu.ungetregisterfpu(list : taasmoutput; r : tregister;size:TCGSize); - - begin - { nothing to do, fpu stack management is handled by the load/ } - { store operations in cgcpu (JM) } - end; - - -{$ifdef SUPPORT_MMX} - procedure trgcpu.pushusedotherregisters(list:Taasmoutput; - var pushed:Tpushedsavedother; - const s:Totherregisterset); - -{ var r:Toldregister; - r2:Tregister; - hr:Treference;} - - begin -(* used_in_proc_other:=used_in_proc_other+s; - for r:=R_MM0 to R_MM6 do - begin - pushed[r].pushed:=false; - { if the register is used by the calling subroutine } - if not is_reg_var_other[r] and - (r in s) and - { and is present in use } - not(r in unusedregsmm) then - begin - r2.enum:=R_INTREGISTER; - r2.number:=NR_ESP; - list.concat(Taicpu.Op_const_reg(A_SUB,S_L,8,r2)); - reference_reset_base(hr,r2,0); - r2.enum:=r; - list.concat(Taicpu.Op_reg_ref(A_MOVQ,S_NO,r2,hr)); - include(unusedregsmm,r); - pushed[r].pushed:=true; - end; - end;*) -{$ifdef TEMPREGDEBUG} - testregisters; -{$endif TEMPREGDEBUG} - end; -{$endif SUPPORT_MMX} - - -{$ifdef SUPPORT_MMX} - procedure trgcpu.popusedotherregisters(list:Taasmoutput; - const pushed:Tpushedsavedother); - -{ var r:Toldregister; - r2,r3:Tregister; - hr:Treference;} - - begin - { restore in reverse order: } -{ for r:=R_MM6 downto R_MM0 do - if pushed[r].pushed then - begin - r2.enum:=R_INTREGISTER; - r2.number:=NR_ESP; - reference_reset_base(hr,r2,0); - r3.enum:=r; - list.concat(Taicpu.op_ref_reg(A_MOVQ,S_NO,hr,r3)); - list.concat(Taicpu.op_const_reg(A_ADD,S_L,8,r2)); - exclude(unusedregsmm,r); - end;} -{$ifdef TEMPREGDEBUG} - testregisters; -{$endif TEMPREGDEBUG} - end; -{$endif SUPPORT_MMX} - - - - procedure trgcpu.saveusedotherregisters(list:Taasmoutput;var saved:Tpushedsavedother; - const s:totherregisterset); - - begin -{$ifdef SUPPORT_MMX} - if (aktoptprocessor in [class386,classP5]) or - (CS_LittleSize in aktglobalswitches) then - pushusedotherregisters(list,saved,s) - else -{$endif SUPPORT_MMX} - inherited saveusedotherregisters(list,saved,s); - end; - - - procedure trgcpu.restoreusedotherregisters(list:Taasmoutput; - const saved:tpushedsavedother); - - begin -{$ifdef SUPPORT_MMX} - if (aktoptprocessor in [class386,classP5]) or - (CS_LittleSize in aktglobalswitches) then - popusedotherregisters(list,saved) - else -{$endif SUPPORT_MMX} - inherited restoreusedotherregisters(list,saved); - end; - - - procedure trgcpu.resetusableregisters; - - begin - inherited resetusableregisters; - fpuvaroffset := 0; - end; - - - function trgcpu.correct_fpuregister(r : tregister;ofs : byte) : tregister; - - begin - correct_fpuregister:=r; - setsupreg(correct_fpuregister,ofs); - end; - - - function trgcpu.makeregsize(reg: tregister; size: tcgsize): tregister; - var - subreg : tsubregister; - begin - if getregtype(reg)<>R_INTREGISTER then - internalerror(200306032); - subreg:=cgsize2subreg(size); - result:=reg; - setsubreg(result,subreg); - add_constraints(result); - end; - end. + { $Log$ - Revision 1.6 2003-09-24 17:12:02 florian - * several fixes for new reg allocator - - Revision 1.5 2003/06/13 21:19:33 peter - * current_procdef removed, use current_procinfo.procdef instead - - Revision 1.4 2002/04/25 20:15:40 florian - * block nodes within expressions shouldn't release the used registers, - fixed using a flag till the new rg is ready - - Revision 1.3 2003/01/05 13:36:54 florian - * x86-64 compiles - + very basic support for float128 type (x86-64 only) - - Revision 1.2 2002/07/25 22:55:34 florian - * several fixes, small test units can be compiled - - Revision 1.1 2002/07/24 22:38:15 florian - + initial release of x86-64 target code - - Revision 1.8 2002/07/01 18:46:34 peter - * internal linker - * reorganized aasm layer - - Revision 1.7 2002/05/16 19:46:52 carl - + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand - + try to fix temp allocation (still in ifdef) - + generic constructor calls - + start of tassembler / tmodulebase class cleanup - - Revision 1.6 2002/05/12 16:53:18 peter - * moved entry and exitcode to ncgutil and cgobj - * foreach gets extra argument for passing local data to the - iterator function - * -CR checks also class typecasts at runtime by changing them - into as - * fixed compiler to cycle with the -CR option - * fixed stabs with elf writer, finally the global variables can - be watched - * removed a lot of routines from cga unit and replaced them by - calls to cgobj - * u32bit-s32bit updates for and,or,xor nodes. When one element is - u32bit then the other is typecasted also to u32bit without giving - a rangecheck warning/error. - * fixed pascal calling method with reversing also the high tree in - the parast, detected by tcalcst3 test - - Revision 1.5 2002/04/21 15:43:32 carl - * changeregsize -> rg.makeregsize - * changeregsize moved from cpubase to here - - Revision 1.4 2002/04/15 19:44:22 peter - * fixed stackcheck that would be called recursively when a stack - error was found - * generic changeregsize(reg,size) for i386 register resizing - * removed some more routines from cga unit - * fixed returnvalue handling - * fixed default stacksize of linux and go32v2, 8kb was a bit small :-) - - Revision 1.3 2002/04/04 19:06:13 peter - * removed unused units - * use tlocation.size in cg.a_*loc*() routines - - Revision 1.2 2002/04/02 17:11:39 peter - * tlocation,treference update - * LOC_CONSTANT added for better constant handling - * secondadd splitted in multiple routines - * location_force_reg added for loading a location to a register - of a specified size - * secondassignment parses now first the right and then the left node - (this is compatible with Kylix). This saves a lot of push/pop especially - with string operations - * adapted some routines to use the new cg methods - - Revision 1.1 2002/03/31 20:26:40 jonas - + a_loadfpu_* and a_loadmm_* methods in tcg - * register allocation is now handled by a class and is mostly processor - independent (+rgobj.pas and i386/rgcpu.pas) - * temp allocation is now handled by a class (+tgobj.pas, -i386\tgcpu.pas) - * some small improvements and fixes to the optimizer - * some register allocation fixes - * some fpuvaroffset fixes in the unary minus node - * push/popusedregisters is now called rg.save/restoreusedregisters and - (for i386) uses temps instead of push/pop's when using -Op3 (that code is - also better optimizable) - * fixed and optimized register saving/restoring for new/dispose nodes - * LOC_FPU locations now also require their "register" field to be set to - R_ST, not R_ST0 (the latter is used for LOC_CFPUREGISTER locations only) - - list field removed of the tnode class because it's not used currently - and can cause hard-to-find bugs - + Revision 1.7 2003-12-24 00:10:03 florian + - delete parameter in cg64 methods removed }