marked a few uses of TConstExprInt as const during parameter passing, to avoid a few unnecessary record copying

git-svn-id: trunk@35509 -
This commit is contained in:
Károly Balogh 2017-03-03 17:29:59 +00:00
parent ece13bcc5a
commit 5426c11611
7 changed files with 21 additions and 21 deletions

View File

@ -105,7 +105,7 @@ interface
exponent value is returned in power. exponent value is returned in power.
} }
function ispowerof2(value : int64;out power : longint) : boolean; function ispowerof2(value : int64;out power : longint) : boolean;
function ispowerof2(value : Tconstexprint;out power : longint) : boolean; function ispowerof2(const value : Tconstexprint;out power : longint) : boolean;
function nextpowerof2(value : int64; out power: longint) : int64; function nextpowerof2(value : int64; out power: longint) : int64;
{$ifdef VER2_6} { only 2.7.1+ has a popcnt function in the system unit } {$ifdef VER2_6} { only 2.7.1+ has a popcnt function in the system unit }
function PopCnt(AValue : Byte): Byte; function PopCnt(AValue : Byte): Byte;
@ -880,7 +880,7 @@ implementation
end; end;
function ispowerof2(value: Tconstexprint; out power: longint): boolean; function ispowerof2(const value: Tconstexprint; out power: longint): boolean;
begin begin
if value.signed or if value.signed or
(value.uvalue<=high(int64)) then (value.uvalue<=high(int64)) then

View File

@ -62,11 +62,11 @@ interface
function get_max_value(def : tdef) : TConstExprInt; function get_max_value(def : tdef) : TConstExprInt;
{# Returns basetype of the specified integer range } {# Returns basetype of the specified integer range }
function range_to_basetype(l,h:TConstExprInt):tordtype; function range_to_basetype(const l,h:TConstExprInt):tordtype;
procedure range_to_type(l,h:TConstExprInt;var def:tdef); procedure range_to_type(const l,h:TConstExprInt;var def:tdef);
procedure int_to_type(v:TConstExprInt;var def:tdef); procedure int_to_type(const v:TConstExprInt;var def:tdef);
{# Returns true, if definition defines an integer type } {# Returns true, if definition defines an integer type }
function is_integer(def : tdef) : boolean; function is_integer(def : tdef) : boolean;
@ -404,7 +404,7 @@ implementation
end; end;
function range_to_basetype(l,h:TConstExprInt):tordtype; function range_to_basetype(const l,h:TConstExprInt):tordtype;
begin begin
{ prefer signed over unsigned } { prefer signed over unsigned }
if (l>=int64(-128)) and (h<=127) then if (l>=int64(-128)) and (h<=127) then
@ -426,7 +426,7 @@ implementation
end; end;
procedure range_to_type(l,h:TConstExprInt;var def:tdef); procedure range_to_type(const l,h:TConstExprInt;var def:tdef);
begin begin
{ prefer signed over unsigned } { prefer signed over unsigned }
if (l>=int64(-128)) and (h<=127) then if (l>=int64(-128)) and (h<=127) then
@ -448,7 +448,7 @@ implementation
end; end;
procedure int_to_type(v:TConstExprInt;var def:tdef); procedure int_to_type(const v:TConstExprInt;var def:tdef);
begin begin
range_to_type(v,v,def); range_to_type(v,v,def);
end; end;

View File

@ -2500,7 +2500,7 @@ implementation
We do this on 64 bit CPUs as well, they benefit from it as well } We do this on 64 bit CPUs as well, they benefit from it as well }
function checkremovebiginttypeconvs(n: tnode; out gotsint: boolean;validints : tordtypeset;l,h : Tconstexprint): boolean; function checkremovebiginttypeconvs(n: tnode; out gotsint: boolean;validints : tordtypeset;const l,h : Tconstexprint): boolean;
var var
gotdivmod: boolean; gotdivmod: boolean;

View File

@ -61,7 +61,7 @@ interface
_rangecheck determines if the value of the ordinal should be checked _rangecheck determines if the value of the ordinal should be checked
against the ranges of the type definition. against the ranges of the type definition.
} }
constructor create(v : tconstexprint;def:tdef; _rangecheck : boolean);virtual; constructor create(const v : tconstexprint;def:tdef; _rangecheck : boolean);virtual;
constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override; constructor ppuload(t:tnodetype;ppufile:tcompilerppufile);override;
procedure ppuwrite(ppufile:tcompilerppufile);override; procedure ppuwrite(ppufile:tcompilerppufile);override;
procedure buildderefimpl;override; procedure buildderefimpl;override;
@ -173,7 +173,7 @@ interface
cguidconstnode : tguidconstnodeclass = tguidconstnode; cguidconstnode : tguidconstnodeclass = tguidconstnode;
cnilnode : tnilnodeclass=tnilnode; cnilnode : tnilnodeclass=tnilnode;
function genintconstnode(v : TConstExprInt) : tordconstnode; function genintconstnode(const v : TConstExprInt) : tordconstnode;
function genenumnode(v : tenumsym) : tordconstnode; function genenumnode(v : tenumsym) : tordconstnode;
{ some helper routines } { some helper routines }
@ -194,7 +194,7 @@ implementation
cpubase,cgbase, cpubase,cgbase,
nld; nld;
function genintconstnode(v : TConstExprInt) : tordconstnode; function genintconstnode(const v : TConstExprInt) : tordconstnode;
var var
htype : tdef; htype : tdef;
begin begin
@ -486,7 +486,7 @@ implementation
TORDCONSTNODE TORDCONSTNODE
*****************************************************************************} *****************************************************************************}
constructor tordconstnode.create(v : tconstexprint;def:tdef;_rangecheck : boolean); constructor tordconstnode.create(const v : tconstexprint;def:tdef;_rangecheck : boolean);
begin begin
inherited create(ordconstn); inherited create(ordconstn);

View File

@ -104,7 +104,7 @@ interface
function pass_1 : tnode;override; function pass_1 : tnode;override;
function simplify(forinline:boolean):tnode;override; function simplify(forinline:boolean):tnode;override;
function docompare(p: tnode): boolean; override; function docompare(p: tnode): boolean; override;
procedure addlabel(blockid:longint;l,h : TConstExprInt); overload; procedure addlabel(blockid:longint;const l,h : TConstExprInt); overload;
procedure addlabel(blockid:longint;l,h : tstringconstnode); overload; procedure addlabel(blockid:longint;l,h : tstringconstnode); overload;
procedure addblock(blockid:longint;instr:tnode); procedure addblock(blockid:longint;instr:tnode);
procedure addelseblock(instr:tnode); procedure addelseblock(instr:tnode);
@ -1032,7 +1032,7 @@ implementation
end; end;
procedure tcasenode.addlabel(blockid:longint;l,h : TConstExprInt); procedure tcasenode.addlabel(blockid:longint;const l,h : TConstExprInt);
var var
hcaselabel : pcaselabel; hcaselabel : pcaselabel;

View File

@ -93,7 +93,7 @@ interface
which was determined during an earlier typecheck pass (because the value which was determined during an earlier typecheck pass (because the value
may e.g. be a parameter to a call, which needs to be of the declared may e.g. be a parameter to a call, which needs to be of the declared
parameter type) } parameter type) }
function create_simplified_ord_const(value: tconstexprint; def: tdef; forinline: boolean): tnode; function create_simplified_ord_const(const value: tconstexprint; def: tdef; forinline: boolean): tnode;
{ returns true if n is only a tree of administrative nodes { returns true if n is only a tree of administrative nodes
containing no code } containing no code }
@ -1072,7 +1072,7 @@ implementation
end; end;
function create_simplified_ord_const(value: tconstexprint; def: tdef; forinline: boolean): tnode; function create_simplified_ord_const(const value: tconstexprint; def: tdef; forinline: boolean): tnode;
begin begin
if not forinline then if not forinline then
result:=genintconstnode(value) result:=genintconstnode(value)

View File

@ -175,10 +175,10 @@ interface
function empty:boolean; function empty:boolean;
function getcopy: tpropaccesslist; function getcopy: tpropaccesslist;
procedure addsym(slt:tsltype;p:tsym); procedure addsym(slt:tsltype;p:tsym);
procedure addconst(slt:tsltype;v:TConstExprInt;d:tdef); procedure addconst(slt:tsltype;const v:TConstExprInt;d:tdef);
procedure addtype(slt:tsltype;d:tdef); procedure addtype(slt:tsltype;d:tdef);
procedure addsymderef(slt:tsltype;d:tderef); procedure addsymderef(slt:tsltype;d:tderef);
procedure addconstderef(slt:tsltype;v:TConstExprInt;d:tderef); procedure addconstderef(slt:tsltype;const v:TConstExprInt;d:tderef);
procedure addtypederef(slt:tsltype;d:tderef); procedure addtypederef(slt:tsltype;d:tderef);
procedure clear; procedure clear;
procedure resolve; procedure resolve;
@ -609,7 +609,7 @@ implementation
end; end;
procedure tpropaccesslist.addconst(slt:tsltype;v:TConstExprInt;d:tdef); procedure tpropaccesslist.addconst(slt:tsltype;const v:TConstExprInt;d:tdef);
var var
hp : ppropaccesslistitem; hp : ppropaccesslistitem;
begin begin
@ -651,7 +651,7 @@ implementation
end; end;
procedure tpropaccesslist.addconstderef(slt:tsltype;v:TConstExprInt;d:tderef); procedure tpropaccesslist.addconstderef(slt:tsltype;const v:TConstExprInt;d:tderef);
begin begin
addconst(slt,v,nil); addconst(slt,v,nil);
lastsym^.valuedefderef:=d; lastsym^.valuedefderef:=d;