|
@@ -32,7 +32,7 @@ interface
|
|
tmoddivnode = class(tbinopnode)
|
|
tmoddivnode = class(tbinopnode)
|
|
function pass_1 : tnode;override;
|
|
function pass_1 : tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
- function simplify : tnode;override;
|
|
|
|
|
|
+ function simplify(forinline : boolean) : tnode;override;
|
|
protected
|
|
protected
|
|
{$ifndef cpu64bitalu}
|
|
{$ifndef cpu64bitalu}
|
|
{ override the following if you want to implement }
|
|
{ override the following if you want to implement }
|
|
@@ -47,7 +47,7 @@ interface
|
|
tshlshrnode = class(tbinopnode)
|
|
tshlshrnode = class(tbinopnode)
|
|
function pass_1 : tnode;override;
|
|
function pass_1 : tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
- function simplify : tnode;override;
|
|
|
|
|
|
+ function simplify(forinline : boolean) : tnode;override;
|
|
{$ifndef cpu64bitalu}
|
|
{$ifndef cpu64bitalu}
|
|
{ override the following if you want to implement }
|
|
{ override the following if you want to implement }
|
|
{ parts explicitely in the code generator (CEC)
|
|
{ parts explicitely in the code generator (CEC)
|
|
@@ -63,7 +63,7 @@ interface
|
|
constructor create(expr : tnode);virtual;
|
|
constructor create(expr : tnode);virtual;
|
|
function pass_1 : tnode;override;
|
|
function pass_1 : tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
- function simplify : tnode;override;
|
|
|
|
|
|
+ function simplify(forinline : boolean) : tnode;override;
|
|
end;
|
|
end;
|
|
tunaryminusnodeclass = class of tunaryminusnode;
|
|
tunaryminusnodeclass = class of tunaryminusnode;
|
|
|
|
|
|
@@ -71,7 +71,7 @@ interface
|
|
constructor create(expr : tnode);virtual;
|
|
constructor create(expr : tnode);virtual;
|
|
function pass_1 : tnode;override;
|
|
function pass_1 : tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
function pass_typecheck:tnode;override;
|
|
- function simplify : tnode;override;
|
|
|
|
|
|
+ function simplify(forinline : boolean) : tnode;override;
|
|
{$ifdef state_tracking}
|
|
{$ifdef state_tracking}
|
|
function track_state_pass(exec_known:boolean):boolean;override;
|
|
function track_state_pass(exec_known:boolean):boolean;override;
|
|
{$endif}
|
|
{$endif}
|
|
@@ -101,7 +101,7 @@ implementation
|
|
TMODDIVNODE
|
|
TMODDIVNODE
|
|
****************************************************************************}
|
|
****************************************************************************}
|
|
|
|
|
|
- function tmoddivnode.simplify:tnode;
|
|
|
|
|
|
+ function tmoddivnode.simplify(forinline : boolean):tnode;
|
|
var
|
|
var
|
|
t : tnode;
|
|
t : tnode;
|
|
rv,lv : tconstexprint;
|
|
rv,lv : tconstexprint;
|
|
@@ -135,9 +135,9 @@ implementation
|
|
|
|
|
|
case nodetype of
|
|
case nodetype of
|
|
modn:
|
|
modn:
|
|
- t:=genintconstnode(lv mod rv);
|
|
|
|
|
|
+ t:=create_simplified_ord_const(lv mod rv,resultdef,forinline);
|
|
divn:
|
|
divn:
|
|
- t:=genintconstnode(lv div rv);
|
|
|
|
|
|
+ t:=create_simplified_ord_const(lv div rv,resultdef,forinline);
|
|
end;
|
|
end;
|
|
result:=t;
|
|
result:=t;
|
|
exit;
|
|
exit;
|
|
@@ -162,7 +162,7 @@ implementation
|
|
maybe_call_procvar(left,true);
|
|
maybe_call_procvar(left,true);
|
|
maybe_call_procvar(right,true);
|
|
maybe_call_procvar(right,true);
|
|
|
|
|
|
- result:=simplify;
|
|
|
|
|
|
+ result:=simplify(false);
|
|
if assigned(result) then
|
|
if assigned(result) then
|
|
exit;
|
|
exit;
|
|
|
|
|
|
@@ -451,7 +451,7 @@ implementation
|
|
TSHLSHRNODE
|
|
TSHLSHRNODE
|
|
****************************************************************************}
|
|
****************************************************************************}
|
|
|
|
|
|
- function tshlshrnode.simplify:tnode;
|
|
|
|
|
|
+ function tshlshrnode.simplify(forinline : boolean):tnode;
|
|
var
|
|
var
|
|
t : tnode;
|
|
t : tnode;
|
|
begin
|
|
begin
|
|
@@ -461,9 +461,9 @@ implementation
|
|
begin
|
|
begin
|
|
case nodetype of
|
|
case nodetype of
|
|
shrn:
|
|
shrn:
|
|
- t:=genintconstnode(tordconstnode(left).value shr tordconstnode(right).value);
|
|
|
|
|
|
+ t:=create_simplified_ord_const(tordconstnode(left).value shr tordconstnode(right).value,resultdef,forinline);
|
|
shln:
|
|
shln:
|
|
- t:=genintconstnode(tordconstnode(left).value shl tordconstnode(right).value);
|
|
|
|
|
|
+ t:=create_simplified_ord_const(tordconstnode(left).value shl tordconstnode(right).value,resultdef,forinline);
|
|
end;
|
|
end;
|
|
result:=t;
|
|
result:=t;
|
|
exit;
|
|
exit;
|
|
@@ -488,7 +488,7 @@ implementation
|
|
maybe_call_procvar(left,true);
|
|
maybe_call_procvar(left,true);
|
|
maybe_call_procvar(right,true);
|
|
maybe_call_procvar(right,true);
|
|
|
|
|
|
- result:=simplify;
|
|
|
|
|
|
+ result:=simplify(false);
|
|
if assigned(result) then
|
|
if assigned(result) then
|
|
exit;
|
|
exit;
|
|
|
|
|
|
@@ -582,13 +582,13 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- function tunaryminusnode.simplify:tnode;
|
|
|
|
|
|
+ function tunaryminusnode.simplify(forinline : boolean):tnode;
|
|
begin
|
|
begin
|
|
result:=nil;
|
|
result:=nil;
|
|
{ constant folding }
|
|
{ constant folding }
|
|
if is_constintnode(left) then
|
|
if is_constintnode(left) then
|
|
begin
|
|
begin
|
|
- result:=genintconstnode(-tordconstnode(left).value);
|
|
|
|
|
|
+ result:=create_simplified_ord_const(-tordconstnode(left).value,resultdef,forinline);
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
if is_constrealnode(left) then
|
|
if is_constrealnode(left) then
|
|
@@ -612,7 +612,7 @@ implementation
|
|
if codegenerror then
|
|
if codegenerror then
|
|
exit;
|
|
exit;
|
|
|
|
|
|
- result:=simplify;
|
|
|
|
|
|
+ result:=simplify(false);
|
|
if assigned(result) then
|
|
if assigned(result) then
|
|
exit;
|
|
exit;
|
|
|
|
|
|
@@ -746,7 +746,7 @@ implementation
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- function tnotnode.simplify:tnode;
|
|
|
|
|
|
+ function tnotnode.simplify(forinline : boolean):tnode;
|
|
var
|
|
var
|
|
v : tconstexprint;
|
|
v : tconstexprint;
|
|
t : tnode;
|
|
t : tnode;
|
|
@@ -824,7 +824,10 @@ implementation
|
|
else
|
|
else
|
|
CGMessage(type_e_mismatch);
|
|
CGMessage(type_e_mismatch);
|
|
end;
|
|
end;
|
|
- t:=cordconstnode.create(v,def,false);
|
|
|
|
|
|
+ if not forinline then
|
|
|
|
+ t:=cordconstnode.create(v,def,false)
|
|
|
|
+ else
|
|
|
|
+ t:=create_simplified_ord_const(v,resultdef,true);
|
|
result:=t;
|
|
result:=t;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
@@ -846,7 +849,7 @@ implementation
|
|
|
|
|
|
resultdef:=left.resultdef;
|
|
resultdef:=left.resultdef;
|
|
|
|
|
|
- result:=simplify;
|
|
|
|
|
|
+ result:=simplify(false);
|
|
if assigned(result) then
|
|
if assigned(result) then
|
|
exit;
|
|
exit;
|
|
|
|
|