* changed tt_persistant to tt_persistent :)

* tempcreatenode now doesn't accept a boolean anymore for persistent
    temps, but a ttemptype, so you can also create ansistring temps etc
This commit is contained in:
Jonas Maebe 2003-05-17 13:30:08 +00:00
parent 900bceb0d9
commit cb279b2029
10 changed files with 94 additions and 48 deletions

View File

@ -30,6 +30,7 @@ interface
cpubase, cpubase,
aasmbase,aasmtai,aasmcpu, aasmbase,aasmtai,aasmcpu,
node, node,
tgobj,
symtype,symppu; symtype,symppu;
type type
@ -90,6 +91,7 @@ interface
hookoncopy : ptempinfo; hookoncopy : ptempinfo;
ref : treference; ref : treference;
restype : ttype; restype : ttype;
temptype : ttemptype;
valid : boolean; valid : boolean;
nextref_set_hookoncopy_nil : boolean; nextref_set_hookoncopy_nil : boolean;
end; end;
@ -98,8 +100,8 @@ interface
{ size (the size is separate to allow creating "void" temps with a custom size) } { size (the size is separate to allow creating "void" temps with a custom size) }
ttempcreatenode = class(tnode) ttempcreatenode = class(tnode)
size: longint; size: longint;
temptype: ttemptype;
tempinfo: ptempinfo; tempinfo: ptempinfo;
persistent: boolean;
{ * persistent temps are used in manually written code where the temp } { * persistent temps are used in manually written code where the temp }
{ be usable among different statements and where you can manually say } { be usable among different statements and where you can manually say }
{ when the temp has to be freed (using a ttempdeletenode) } { when the temp has to be freed (using a ttempdeletenode) }
@ -107,7 +109,7 @@ interface
{ where the node that receives the temp becomes responsible for } { where the node that receives the temp becomes responsible for }
{ freeing it. In this last case, you should use only one reference } { freeing it. In this last case, you should use only one reference }
{ to it and *not* generate a ttempdeletenode } { to it and *not* generate a ttempdeletenode }
constructor create(const _restype: ttype; _size: longint; _persistent: boolean); virtual; constructor create(const _restype: ttype; _size: longint; _temptype: ttemptype); virtual;
function getcopy: tnode; override; function getcopy: tnode; override;
function pass_1 : tnode; override; function pass_1 : tnode; override;
function det_resulttype: tnode; override; function det_resulttype: tnode; override;
@ -569,14 +571,14 @@ implementation
TEMPCREATENODE TEMPCREATENODE
*****************************************************************************} *****************************************************************************}
constructor ttempcreatenode.create(const _restype: ttype; _size: longint; _persistent: boolean); constructor ttempcreatenode.create(const _restype: ttype; _size: longint; _temptype: ttemptype);
begin begin
inherited create(tempcreaten); inherited create(tempcreaten);
size := _size; size := _size;
new(tempinfo); new(tempinfo);
fillchar(tempinfo^,sizeof(tempinfo^),0); fillchar(tempinfo^,sizeof(tempinfo^),0);
tempinfo^.restype := _restype; tempinfo^.restype := _restype;
persistent := _persistent; temptype := _temptype;
end; end;
function ttempcreatenode.getcopy: tnode; function ttempcreatenode.getcopy: tnode;
@ -585,7 +587,7 @@ implementation
begin begin
n := ttempcreatenode(inherited getcopy); n := ttempcreatenode(inherited getcopy);
n.size := size; n.size := size;
n.persistent := persistent; n.temptype := temptype;
new(n.tempinfo); new(n.tempinfo);
fillchar(n.tempinfo^,sizeof(n.tempinfo^),0); fillchar(n.tempinfo^,sizeof(n.tempinfo^),0);
@ -728,7 +730,7 @@ implementation
inherited create(tempdeleten); inherited create(tempdeleten);
tempinfo := temp.tempinfo; tempinfo := temp.tempinfo;
release_to_normal := true; release_to_normal := true;
if not temp.persistent then if temp.temptype <> tt_persistent then
internalerror(200204211); internalerror(200204211);
end; end;
@ -798,7 +800,12 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.50 2003-05-13 19:14:41 peter Revision 1.51 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.50 2003/05/13 19:14:41 peter
* failn removed * failn removed
* inherited result code check moven to pexpr * inherited result code check moven to pexpr

View File

@ -191,7 +191,7 @@ implementation
htypechk,pass_1,cpubase, htypechk,pass_1,cpubase,
ncnv,nld,ninl,nadd,ncon,nmem, ncnv,nld,ninl,nadd,ncon,nmem,
nutils, nutils,
rgobj,cginfo,cgbase tgobj,rgobj,cginfo,cgbase
; ;
type type
@ -1773,7 +1773,7 @@ type
hiddentree:=internalstatements(newstatement,false); hiddentree:=internalstatements(newstatement,false);
{ need to use resulttype instead of procdefinition.rettype, { need to use resulttype instead of procdefinition.rettype,
because they can be different } because they can be different }
temp:=ctempcreatenode.create(resulttype,resulttype.def.size,true); temp:=ctempcreatenode.create(resulttype,resulttype.def.size,tt_persistent);
addstatement(newstatement,temp); addstatement(newstatement,temp);
addstatement(newstatement,ctempdeletenode.create_normal_temp(temp)); addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
addstatement(newstatement,ctemprefnode.create(temp)); addstatement(newstatement,ctemprefnode.create(temp));
@ -2212,10 +2212,10 @@ type
take_addr := (curparaitem.paratyp in [vs_var,vs_out]) or take_addr := (curparaitem.paratyp in [vs_var,vs_out]) or
((curparaitem.paratype.def.deftype = formaldef)); ((curparaitem.paratype.def.deftype = formaldef));
if not(take_addr) then if not(take_addr) then
temp := ctempcreatenode.create(curpara.left.resulttype,curpara.left.resulttype.def.size,true) temp := ctempcreatenode.create(curpara.left.resulttype,curpara.left.resulttype.def.size,tt_persistent)
else else
begin begin
temp := ctempcreatenode.create(voidpointertype,pointer_size,true); temp := ctempcreatenode.create(voidpointertype,pointer_size,tt_persistent);
orgtype := @curpara.left.resulttype; orgtype := @curpara.left.resulttype;
end; end;
addstatement(newstatement,temp); addstatement(newstatement,temp);
@ -2712,7 +2712,12 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.155 2003-05-16 14:33:31 peter Revision 1.156 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.155 2003/05/16 14:33:31 peter
* regvar fixes * regvar fixes
Revision 1.154 2003/05/14 19:35:50 jonas Revision 1.154 2003/05/14 19:35:50 jonas

View File

@ -256,8 +256,6 @@ interface
*****************************************************************************} *****************************************************************************}
procedure tcgtempcreatenode.pass_2; procedure tcgtempcreatenode.pass_2;
var
temptype : ttemptype;
begin begin
location_reset(location,LOC_VOID,OS_NO); location_reset(location,LOC_VOID,OS_NO);
@ -266,10 +264,6 @@ interface
internalerror(200108222); internalerror(200108222);
{ get a (persistent) temp } { get a (persistent) temp }
if persistent then
temptype:=tt_persistant
else
temptype:=tt_normal;
tg.GetTemp(exprasmlist,size,temptype,tempinfo^.ref); tg.GetTemp(exprasmlist,size,temptype,tempinfo^.ref);
tempinfo^.valid := true; tempinfo^.valid := true;
end; end;
@ -316,7 +310,12 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.33 2003-04-27 11:21:33 peter Revision 1.34 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.33 2003/04/27 11:21:33 peter
* aktprocdef renamed to current_procdef * aktprocdef renamed to current_procdef
* procinfo renamed to current_procinfo * procinfo renamed to current_procinfo
* procinfo will now be stored in current_module so it can be * procinfo will now be stored in current_module so it can be

View File

@ -597,7 +597,7 @@ implementation
if assigned(left) then if assigned(left) then
begin begin
inlinecode.para_size:=tprocdef(procdefinition).para_size(para_alignment); inlinecode.para_size:=tprocdef(procdefinition).para_size(para_alignment);
tg.GetTemp(exprasmlist,inlinecode.para_size,tt_persistant,pararef); tg.GetTemp(exprasmlist,inlinecode.para_size,tt_persistent,pararef);
inlinecode.para_offset:=pararef.offset; inlinecode.para_offset:=pararef.offset;
end; end;
store_parast_fixup:=tprocdef(procdefinition).parast.address_fixup; store_parast_fixup:=tprocdef(procdefinition).parast.address_fixup;
@ -742,7 +742,7 @@ implementation
if inlined and if inlined and
(resulttype.def.size>0) then (resulttype.def.size>0) then
begin begin
tg.GetTemp(exprasmlist,Align(resulttype.def.size,aktalignment.paraalign),tt_persistant,returnref); tg.GetTemp(exprasmlist,Align(resulttype.def.size,aktalignment.paraalign),tt_persistent,returnref);
inlinecode.retoffset:=returnref.offset; inlinecode.retoffset:=returnref.offset;
end; end;
@ -1017,7 +1017,7 @@ implementation
st.symtablelevel:=oldprocdef.localst.symtablelevel; st.symtablelevel:=oldprocdef.localst.symtablelevel;
if st.datasize>0 then if st.datasize>0 then
begin begin
tg.GetTemp(exprasmlist,st.datasize,tt_persistant,localsref); tg.GetTemp(exprasmlist,st.datasize,tt_persistent,localsref);
if tg.direction>0 then if tg.direction>0 then
st.address_fixup:=localsref.offset st.address_fixup:=localsref.offset
else else
@ -1128,7 +1128,12 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.66 2003-05-16 14:33:31 peter Revision 1.67 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.66 2003/05/16 14:33:31 peter
* regvar fixes * regvar fixes
Revision 1.65 2003/05/15 18:58:53 peter Revision 1.65 2003/05/15 18:58:53 peter

View File

@ -986,9 +986,9 @@ implementation
procedure try_new_exception(list : taasmoutput;var jmpbuf,envbuf, href : treference; procedure try_new_exception(list : taasmoutput;var jmpbuf,envbuf, href : treference;
a : aword; exceptlabel : tasmlabel); a : aword; exceptlabel : tasmlabel);
begin begin
tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistant,envbuf); tg.GetTemp(list,EXCEPT_BUF_SIZE,tt_persistent,envbuf);
tg.GetTemp(list,JMP_BUF_SIZE,tt_persistant,jmpbuf); tg.GetTemp(list,JMP_BUF_SIZE,tt_persistent,jmpbuf);
tg.GetTemp(list,sizeof(aword),tt_persistant,href); tg.GetTemp(list,sizeof(aword),tt_persistent,href);
new_exception(list, jmpbuf,envbuf, href, a, exceptlabel); new_exception(list, jmpbuf,envbuf, href, a, exceptlabel);
end; end;
@ -1554,7 +1554,12 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.61 2003-05-16 14:33:31 peter Revision 1.62 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.61 2003/05/16 14:33:31 peter
* regvar fixes * regvar fixes
Revision 1.60 2003/05/13 19:14:41 peter Revision 1.60 2003/05/13 19:14:41 peter

View File

@ -376,7 +376,7 @@ implementation
{ since the input/output variables are threadvars loading them into { since the input/output variables are threadvars loading them into
a temp once is faster. Create a temp which will hold a pointer to the file } a temp once is faster. Create a temp which will hold a pointer to the file }
filetemp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,true); filetemp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,tt_persistent);
addstatement(newstatement,filetemp); addstatement(newstatement,filetemp);
{ make sure the resulttype of the temp (and as such of the } { make sure the resulttype of the temp (and as such of the }
@ -409,7 +409,7 @@ implementation
if (filepara.left.nodetype <> loadn) then if (filepara.left.nodetype <> loadn) then
begin begin
{ create a temp which will hold a pointer to the file } { create a temp which will hold a pointer to the file }
filetemp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,true); filetemp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,tt_persistent);
{ add it to the statements } { add it to the statements }
addstatement(newstatement,filetemp); addstatement(newstatement,filetemp);
@ -525,7 +525,7 @@ implementation
begin begin
{ create temp for result } { create temp for result }
temp := ctempcreatenode.create(para.left.resulttype, temp := ctempcreatenode.create(para.left.resulttype,
para.left.resulttype.def.size,true); para.left.resulttype.def.size,tt_persistent);
addstatement(newstatement,temp); addstatement(newstatement,temp);
{ assign result to temp } { assign result to temp }
addstatement(newstatement, addstatement(newstatement,
@ -753,7 +753,7 @@ implementation
restype := @u32bittype; restype := @u32bittype;
{ create the parameter list: the temp ... } { create the parameter list: the temp ... }
temp := ctempcreatenode.create(restype^,restype^.def.size,true); temp := ctempcreatenode.create(restype^,restype^.def.size,tt_persistent);
addstatement(newstatement,temp); addstatement(newstatement,temp);
{ ... and the file } { ... and the file }
@ -916,7 +916,7 @@ implementation
if not assigned(codepara) or if not assigned(codepara) or
(torddef(codepara.resulttype.def).typ in [u8bit,u16bit,s8bit,s16bit]) then (torddef(codepara.resulttype.def).typ in [u8bit,u16bit,s8bit,s16bit]) then
begin begin
tempcode := ctempcreatenode.create(s32bittype,4,true); tempcode := ctempcreatenode.create(s32bittype,4,tt_persistent);
addstatement(newstatement,tempcode); addstatement(newstatement,tempcode);
{ set the resulttype of the temp (needed to be able to get } { set the resulttype of the temp (needed to be able to get }
{ the resulttype of the tempref used in the new code para) } { the resulttype of the tempref used in the new code para) }
@ -2351,7 +2351,12 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.111 2003-05-11 21:37:03 peter Revision 1.112 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.111 2003/05/11 21:37:03 peter
* moved implicit exception frame from ncgutil to psub * moved implicit exception frame from ncgutil to psub
* constructor/destructor helpers moved from cobj/ncgutil to psub * constructor/destructor helpers moved from cobj/ncgutil to psub

View File

@ -60,7 +60,7 @@ implementation
scanner, scanner,
pbase,pexpr, pbase,pexpr,
{ codegen } { codegen }
cgbase tgobj,cgbase
; ;
@ -231,7 +231,7 @@ implementation
if is_new then if is_new then
begin begin
{ create temp for result } { create temp for result }
temp := ctempcreatenode.create(p.resulttype,p.resulttype.def.size,true); temp := ctempcreatenode.create(p.resulttype,p.resulttype.def.size,tt_persistent);
addstatement(newstatement,temp); addstatement(newstatement,temp);
{ create call to fpc_getmem } { create call to fpc_getmem }
@ -312,7 +312,7 @@ implementation
newblock:=internalstatements(newstatement,true); newblock:=internalstatements(newstatement,true);
{ create temp for result } { create temp for result }
temp := ctempcreatenode.create(p1.resulttype,p1.resulttype.def.size,true); temp := ctempcreatenode.create(p1.resulttype,p1.resulttype.def.size,tt_persistent);
addstatement(newstatement,temp); addstatement(newstatement,temp);
{ create call to fpc_getmem } { create call to fpc_getmem }
@ -475,7 +475,7 @@ implementation
newblock:=internalstatements(newstatement,true); newblock:=internalstatements(newstatement,true);
{ get temp for array of lengths } { get temp for array of lengths }
temp := ctempcreatenode.create(s32bittype,counter*s32bittype.def.size,true); temp := ctempcreatenode.create(s32bittype,counter*s32bittype.def.size,tt_persistent);
addstatement(newstatement,temp); addstatement(newstatement,temp);
{ load array of lengths } { load array of lengths }
@ -646,7 +646,7 @@ implementation
{ create temp for result, we've to use a temp because a dynarray { create temp for result, we've to use a temp because a dynarray
type is handled differently from a pointer so we can't type is handled differently from a pointer so we can't
use createinternres() and a function } use createinternres() and a function }
temp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,true); temp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,tt_persistent);
addstatement(newstatement,temp); addstatement(newstatement,temp);
{ create call to fpc_dynarray_copy } { create call to fpc_dynarray_copy }
@ -682,7 +682,12 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.14 2003-05-16 14:33:31 peter Revision 1.15 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.14 2003/05/16 14:33:31 peter
* regvar fixes * regvar fixes
Revision 1.13 2003/05/09 17:47:03 peter Revision 1.13 2003/05/09 17:47:03 peter

View File

@ -434,7 +434,7 @@ implementation
htype:=p.resulttype htype:=p.resulttype
else else
htype.setdef(tpointerdef.create(p.resulttype)); htype.setdef(tpointerdef.create(p.resulttype));
loadp:=ctempcreatenode.create(htype,POINTER_SIZE,true); loadp:=ctempcreatenode.create(htype,POINTER_SIZE,tt_persistent);
resulttypepass(loadp); resulttypepass(loadp);
if hasimplicitderef then if hasimplicitderef then
begin begin
@ -1175,7 +1175,12 @@ implementation
end. end.
{ {
$Log$ $Log$
Revision 1.99 2003-05-15 18:58:53 peter Revision 1.100 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.99 2003/05/15 18:58:53 peter
* removed selfpointer_offset, vmtpointer_offset * removed selfpointer_offset, vmtpointer_offset
* tvarsym.adjusted_address * tvarsym.adjusted_address
* address in localsymtable is now in the real direction * address in localsymtable is now in the real direction

View File

@ -916,7 +916,7 @@ unit rgobj;
not(r in unusedregsint) then not(r in unusedregsint) then
begin begin
{ then save it } { then save it }
tg.GetTemp(list,sizeof(aword),tt_persistant,hr); tg.GetTemp(list,sizeof(aword),tt_persistent,hr);
saved[r].ofs:=hr.offset; saved[r].ofs:=hr.offset;
r2.enum:=R_INTREGISTER; r2.enum:=R_INTREGISTER;
r2.number:=r shl 8 or R_SUBWHOLE; r2.number:=r shl 8 or R_SUBWHOLE;
@ -957,7 +957,7 @@ unit rgobj;
not(r.enum in unusedregsfpu) then not(r.enum in unusedregsfpu) then
begin begin
{ then save it } { then save it }
tg.GetTemp(list,extended_size,tt_persistant,hr); tg.GetTemp(list,extended_size,tt_persistent,hr);
saved[r.enum].ofs:=hr.offset; saved[r.enum].ofs:=hr.offset;
cg.a_loadfpu_reg_ref(list,OS_FLOAT,r,hr); cg.a_loadfpu_reg_ref(list,OS_FLOAT,r,hr);
cg.a_reg_dealloc(list,r); cg.a_reg_dealloc(list,r);
@ -979,7 +979,7 @@ unit rgobj;
not(r.enum in unusedregsmm) then not(r.enum in unusedregsmm) then
begin begin
{ then save it } { then save it }
tg.GetTemp(list,mmreg_size,tt_persistant,hr); tg.GetTemp(list,mmreg_size,tt_persistent,hr);
saved[r.enum].ofs:=hr.offset; saved[r.enum].ofs:=hr.offset;
cg.a_loadmm_reg_ref(list,r,hr); cg.a_loadmm_reg_ref(list,r,hr);
cg.a_reg_dealloc(list,r); cg.a_reg_dealloc(list,r);
@ -2027,7 +2027,12 @@ end.
{ {
$Log$ $Log$
Revision 1.43 2003-05-16 14:33:31 peter Revision 1.44 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.43 2003/05/16 14:33:31 peter
* regvar fixes * regvar fixes
Revision 1.42 2003/04/26 20:03:49 daniel Revision 1.42 2003/04/26 20:03:49 daniel

View File

@ -40,7 +40,7 @@ unit tgobj;
type type
ttemptype = (tt_none, ttemptype = (tt_none,
tt_free,tt_normal,tt_persistant, tt_free,tt_normal,tt_persistent,
tt_noreuse,tt_freenoreuse, tt_noreuse,tt_freenoreuse,
tt_ansistring,tt_freeansistring, tt_ansistring,tt_freeansistring,
tt_widestring,tt_freewidestring, tt_widestring,tt_freewidestring,
@ -536,7 +536,7 @@ unit tgobj;
procedure ttgobj.UnGetTemp(list: taasmoutput; const ref : treference); procedure ttgobj.UnGetTemp(list: taasmoutput; const ref : treference);
begin begin
FreeTemp(list,ref.offset,[tt_normal,tt_noreuse,tt_persistant,tt_ansistring,tt_widestring,tt_interfacecom]); FreeTemp(list,ref.offset,[tt_normal,tt_noreuse,tt_persistent,tt_ansistring,tt_widestring,tt_interfacecom]);
end; end;
@ -554,7 +554,12 @@ finalization
end. end.
{ {
$Log$ $Log$
Revision 1.33 2003-05-13 20:13:41 florian Revision 1.34 2003-05-17 13:30:08 jonas
* changed tt_persistant to tt_persistent :)
* tempcreatenode now doesn't accept a boolean anymore for persistent
temps, but a ttemptype, so you can also create ansistring temps etc
Revision 1.33 2003/05/13 20:13:41 florian
* fixed temp. management for CPUs were the temp. space grows upwards * fixed temp. management for CPUs were the temp. space grows upwards
Revision 1.32 2003/05/12 21:29:59 peter Revision 1.32 2003/05/12 21:29:59 peter