|
@@ -79,6 +79,16 @@ interface
|
|
property VisibleCount:integer read FProcVisibleCnt;
|
|
property VisibleCount:integer read FProcVisibleCnt;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ type
|
|
|
|
+ tregableinfoflag = (
|
|
|
|
+ // can be put in a register if it's the address of a var/out/const parameter
|
|
|
|
+ ra_addr_regable,
|
|
|
|
+ // orthogonal to above flag: the address of the node is taken and may
|
|
|
|
+ // possibly escape the block in which this node is declared (e.g. a
|
|
|
|
+ // local variable is passed as var parameter to another procedure)
|
|
|
|
+ ra_addr_taken);
|
|
|
|
+ tregableinfoflags = set of tregableinfoflag;
|
|
|
|
+
|
|
const
|
|
const
|
|
tok2nodes=24;
|
|
tok2nodes=24;
|
|
tok2node:array[1..tok2nodes] of ttok2noderec=(
|
|
tok2node:array[1..tok2nodes] of ttok2noderec=(
|
|
@@ -123,7 +133,7 @@ interface
|
|
function isbinaryoverloaded(var t : tnode) : boolean;
|
|
function isbinaryoverloaded(var t : tnode) : boolean;
|
|
|
|
|
|
{ Register Allocation }
|
|
{ Register Allocation }
|
|
- procedure make_not_regable(p : tnode; how: tvarregable);
|
|
|
|
|
|
+ procedure make_not_regable(p : tnode; how: tregableinfoflags);
|
|
procedure calcregisters(p : tbinarynode;r32,fpu,mmx : word);
|
|
procedure calcregisters(p : tbinarynode;r32,fpu,mmx : word);
|
|
|
|
|
|
{ procvar handling }
|
|
{ procvar handling }
|
|
@@ -676,43 +686,68 @@ implementation
|
|
****************************************************************************}
|
|
****************************************************************************}
|
|
|
|
|
|
{ marks an lvalue as "unregable" }
|
|
{ marks an lvalue as "unregable" }
|
|
- procedure make_not_regable_intern(p : tnode; how: tvarregable; records_only: boolean);
|
|
|
|
|
|
+ procedure make_not_regable_intern(p : tnode; how: tregableinfoflags; records_only: boolean);
|
|
|
|
+ var
|
|
|
|
+ update_regable: boolean;
|
|
begin
|
|
begin
|
|
- case p.nodetype of
|
|
|
|
- subscriptn:
|
|
|
|
- make_not_regable_intern(tsubscriptnode(p).left,how,true);
|
|
|
|
|
|
+ update_regable:=true;
|
|
|
|
+ repeat
|
|
|
|
+ case p.nodetype of
|
|
|
|
+ subscriptn:
|
|
|
|
+ begin
|
|
|
|
+ records_only:=true;
|
|
|
|
+ p:=tsubscriptnode(p).left;
|
|
|
|
+ end;
|
|
|
|
+ vecn:
|
|
|
|
+ begin
|
|
|
|
+ { arrays are currently never regable and pointers indexed like }
|
|
|
|
+ { arrays do not have be made unregable, but we do need to }
|
|
|
|
+ { propagate the ra_addr_taken info }
|
|
|
|
+ update_regable:=false;
|
|
|
|
+ p:=tvecnode(p).left;
|
|
|
|
+ end;
|
|
typeconvn :
|
|
typeconvn :
|
|
- if (ttypeconvnode(p).resultdef.typ = recorddef) then
|
|
|
|
- make_not_regable_intern(ttypeconvnode(p).left,how,false)
|
|
|
|
- else
|
|
|
|
- make_not_regable_intern(ttypeconvnode(p).left,how,records_only);
|
|
|
|
|
|
+ begin
|
|
|
|
+ if (ttypeconvnode(p).resultdef.typ = recorddef) then
|
|
|
|
+ records_only:=false;
|
|
|
|
+ p:=ttypeconvnode(p).left;
|
|
|
|
+ end;
|
|
loadn :
|
|
loadn :
|
|
- if (tloadnode(p).symtableentry.typ in [staticvarsym,localvarsym,paravarsym]) then
|
|
|
|
- begin
|
|
|
|
- { this is overly conservative (make_not_regable is also called in }
|
|
|
|
- { other situations), but it avoids having to do this all over the }
|
|
|
|
- { the compiler }
|
|
|
|
- tabstractvarsym(tloadnode(p).symtableentry).addr_taken:=true;
|
|
|
|
- if (tabstractvarsym(tloadnode(p).symtableentry).varregable <> vr_none) and
|
|
|
|
- ((not records_only) or
|
|
|
|
- (tabstractvarsym(tloadnode(p).symtableentry).vardef.typ = recorddef)) then
|
|
|
|
- if (tloadnode(p).symtableentry.typ = paravarsym) then
|
|
|
|
- tabstractvarsym(tloadnode(p).symtableentry).varregable:=how
|
|
|
|
- else
|
|
|
|
- tabstractvarsym(tloadnode(p).symtableentry).varregable:=vr_none;
|
|
|
|
- end;
|
|
|
|
|
|
+ begin
|
|
|
|
+ if (tloadnode(p).symtableentry.typ in [staticvarsym,localvarsym,paravarsym]) then
|
|
|
|
+ begin
|
|
|
|
+ if (ra_addr_taken in how) then
|
|
|
|
+ tabstractvarsym(tloadnode(p).symtableentry).addr_taken:=true;
|
|
|
|
+ if update_regable and
|
|
|
|
+ (tabstractvarsym(tloadnode(p).symtableentry).varregable <> vr_none) and
|
|
|
|
+ ((not records_only) or
|
|
|
|
+ (tabstractvarsym(tloadnode(p).symtableentry).vardef.typ = recorddef)) then
|
|
|
|
+ if (tloadnode(p).symtableentry.typ = paravarsym) and
|
|
|
|
+ (ra_addr_regable in how) then
|
|
|
|
+ tabstractvarsym(tloadnode(p).symtableentry).varregable:=vr_addr
|
|
|
|
+ else
|
|
|
|
+ tabstractvarsym(tloadnode(p).symtableentry).varregable:=vr_none;
|
|
|
|
+ end;
|
|
|
|
+ break;
|
|
|
|
+ end;
|
|
temprefn :
|
|
temprefn :
|
|
begin
|
|
begin
|
|
- include(ttemprefnode(p).tempinfo^.flags,ti_addr_taken);
|
|
|
|
- if (ti_may_be_in_reg in ttemprefnode(p).tempinfo^.flags) and
|
|
|
|
|
|
+ if (ra_addr_taken in how) then
|
|
|
|
+ include(ttemprefnode(p).tempinfo^.flags,ti_addr_taken);
|
|
|
|
+ if update_regable and
|
|
|
|
+ (ti_may_be_in_reg in ttemprefnode(p).tempinfo^.flags) and
|
|
((not records_only) or
|
|
((not records_only) or
|
|
(ttemprefnode(p).tempinfo^.typedef.typ = recorddef)) then
|
|
(ttemprefnode(p).tempinfo^.typedef.typ = recorddef)) then
|
|
exclude(ttemprefnode(p).tempinfo^.flags,ti_may_be_in_reg);
|
|
exclude(ttemprefnode(p).tempinfo^.flags,ti_may_be_in_reg);
|
|
|
|
+ break;
|
|
end;
|
|
end;
|
|
- end;
|
|
|
|
|
|
+ else
|
|
|
|
+ break;
|
|
|
|
+ end;
|
|
|
|
+ until false;
|
|
end;
|
|
end;
|
|
|
|
|
|
- procedure make_not_regable(p : tnode; how: tvarregable);
|
|
|
|
|
|
+ procedure make_not_regable(p : tnode; how: tregableinfoflags);
|
|
begin
|
|
begin
|
|
make_not_regable_intern(p,how,false);
|
|
make_not_regable_intern(p,how,false);
|
|
end;
|
|
end;
|
|
@@ -1088,7 +1123,7 @@ implementation
|
|
be in a register }
|
|
be in a register }
|
|
if (m_tp7 in current_settings.modeswitches) or
|
|
if (m_tp7 in current_settings.modeswitches) or
|
|
(todef.size<fromdef.size) then
|
|
(todef.size<fromdef.size) then
|
|
- make_not_regable(hp,vr_addr)
|
|
|
|
|
|
+ make_not_regable(hp,[ra_addr_regable])
|
|
else
|
|
else
|
|
if report_errors then
|
|
if report_errors then
|
|
CGMessagePos2(hp.fileinfo,type_e_typecast_wrong_size_for_assignment,tostr(fromdef.size),tostr(todef.size));
|
|
CGMessagePos2(hp.fileinfo,type_e_typecast_wrong_size_for_assignment,tostr(fromdef.size),tostr(todef.size));
|