mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-31 19:51:29 +02:00
* optimized the code generated by the a_op_const_* and a_op64_const
methods
This commit is contained in:
parent
1a6c7fc693
commit
36699776ee
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
}
|
}
|
||||||
|
|
||||||
unit cgcpu;
|
unit cgcpu;
|
||||||
|
|
||||||
{$i defines.inc}
|
{$i defines.inc}
|
||||||
@ -455,6 +456,18 @@ unit cgcpu;
|
|||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
list.concat(taicpu.op_const_reg(A_MOV,regsize(reg),0,reg))
|
list.concat(taicpu.op_const_reg(A_MOV,regsize(reg),0,reg))
|
||||||
|
else if (a = high(aword)) and
|
||||||
|
(op in [OP_AND,OP_OR,OP_XOR]) then
|
||||||
|
begin
|
||||||
|
case op of
|
||||||
|
OP_AND:
|
||||||
|
exit;
|
||||||
|
OP_OR:
|
||||||
|
list.concat(taicpu.op_const_reg(A_MOV,regsize(reg),high(aword),reg));
|
||||||
|
OP_XOR:
|
||||||
|
list.concat(taicpu.op_reg(A_NOT,regsize(reg),reg));
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
list.concat(taicpu.op_const_reg(TOpCG2AsmOp[op],regsize(reg),
|
list.concat(taicpu.op_const_reg(TOpCG2AsmOp[op],regsize(reg),
|
||||||
a,reg));
|
a,reg));
|
||||||
@ -527,6 +540,18 @@ unit cgcpu;
|
|||||||
exit
|
exit
|
||||||
else
|
else
|
||||||
a_load_const_ref(list,size,0,ref)
|
a_load_const_ref(list,size,0,ref)
|
||||||
|
else if (a = high(aword)) and
|
||||||
|
(op in [OP_AND,OP_OR,OP_XOR]) then
|
||||||
|
begin
|
||||||
|
case op of
|
||||||
|
OP_AND:
|
||||||
|
exit;
|
||||||
|
OP_OR:
|
||||||
|
list.concat(taicpu.op_const_ref(A_MOV,TCgSize2OpSize[size],high(aword),ref));
|
||||||
|
OP_XOR:
|
||||||
|
list.concat(taicpu.op_ref(A_NOT,TCgSize2OpSize[size],ref));
|
||||||
|
end
|
||||||
|
end
|
||||||
else
|
else
|
||||||
list.concat(taicpu.op_const_ref(TOpCG2AsmOp[op],
|
list.concat(taicpu.op_const_ref(TOpCG2AsmOp[op],
|
||||||
TCgSize2OpSize[size],a,ref));
|
TCgSize2OpSize[size],a,ref));
|
||||||
@ -763,8 +788,7 @@ unit cgcpu;
|
|||||||
l : tasmlabel);
|
l : tasmlabel);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if (a = 0) and
|
if (a = 0) then
|
||||||
(cmp_op in [OC_EQ,OC_NE]) then
|
|
||||||
list.concat(taicpu.op_reg_reg(A_TEST,regsize(reg),reg,reg))
|
list.concat(taicpu.op_reg_reg(A_TEST,regsize(reg),reg,reg))
|
||||||
else
|
else
|
||||||
list.concat(taicpu.op_const_reg(A_CMP,regsize(reg),a,reg));
|
list.concat(taicpu.op_const_reg(A_CMP,regsize(reg),a,reg));
|
||||||
@ -989,23 +1013,51 @@ unit cgcpu;
|
|||||||
var
|
var
|
||||||
op1,op2 : TAsmOp;
|
op1,op2 : TAsmOp;
|
||||||
begin
|
begin
|
||||||
|
case op of
|
||||||
|
OP_AND,OP_OR,OP_XOR:
|
||||||
|
begin
|
||||||
|
a_op_const_reg(list,op,valuelosrc,reglodst);
|
||||||
|
a_op_const_reg(list,op,valuehisrc,reghidst);
|
||||||
|
end;
|
||||||
|
OP_ADD, OP_SUB:
|
||||||
|
begin
|
||||||
|
// can't use a_op_const_ref because this may use dec/inc
|
||||||
get_64bit_ops(op,op1,op2);
|
get_64bit_ops(op,op1,op2);
|
||||||
list.concat(taicpu.op_const_reg(op1,S_L,valuelosrc,reglodst));
|
list.concat(taicpu.op_const_reg(op1,S_L,valuelosrc,reglodst));
|
||||||
list.concat(taicpu.op_const_reg(op2,S_L,valuehisrc,reghidst));
|
list.concat(taicpu.op_const_reg(op2,S_L,valuehisrc,reghidst));
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
internalerror(200204021);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure tcg386.a_op64_const_ref(list : taasmoutput;op:TOpCG;valuelosrc,valuehisrc:AWord;const ref : treference);
|
procedure tcg386.a_op64_const_ref(list : taasmoutput;op:TOpCG;valuelosrc,valuehisrc:AWord;const ref : treference);
|
||||||
var
|
var
|
||||||
op1,op2 : TAsmOp;
|
op1,op2 : TAsmOp;
|
||||||
tempref : treference;
|
tempref : treference;
|
||||||
|
begin
|
||||||
|
case op of
|
||||||
|
OP_AND,OP_OR,OP_XOR:
|
||||||
|
begin
|
||||||
|
a_op_const_ref(list,op,OS_32,valuelosrc,ref);
|
||||||
|
tempref:=ref;
|
||||||
|
inc(tempref.offset,4);
|
||||||
|
a_op_const_ref(list,op,OS_32,valuehisrc,tempref);
|
||||||
|
end;
|
||||||
|
OP_ADD, OP_SUB:
|
||||||
begin
|
begin
|
||||||
get_64bit_ops(op,op1,op2);
|
get_64bit_ops(op,op1,op2);
|
||||||
|
// can't use a_op_const_ref because this may use dec/inc
|
||||||
list.concat(taicpu.op_const_ref(op1,S_L,valuelosrc,ref));
|
list.concat(taicpu.op_const_ref(op1,S_L,valuelosrc,ref));
|
||||||
tempref:=ref;
|
tempref:=ref;
|
||||||
inc(tempref.offset,4);
|
inc(tempref.offset,4);
|
||||||
list.concat(taicpu.op_const_ref(op2,S_L,valuehisrc,tempref));
|
list.concat(taicpu.op_const_ref(op2,S_L,valuehisrc,tempref));
|
||||||
end;
|
end;
|
||||||
|
else
|
||||||
|
internalerror(200204022);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ ************* concatcopy ************ }
|
{ ************* concatcopy ************ }
|
||||||
@ -1159,7 +1211,11 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.9 2002-04-02 17:11:33 peter
|
Revision 1.10 2002-04-02 20:29:02 jonas
|
||||||
|
* optimized the code generated by the a_op_const_* and a_op64_const
|
||||||
|
methods
|
||||||
|
|
||||||
|
Revision 1.9 2002/04/02 17:11:33 peter
|
||||||
* tlocation,treference update
|
* tlocation,treference update
|
||||||
* LOC_CONSTANT added for better constant handling
|
* LOC_CONSTANT added for better constant handling
|
||||||
* secondadd splitted in multiple routines
|
* secondadd splitted in multiple routines
|
||||||
|
Loading…
Reference in New Issue
Block a user