mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-08 09:06:06 +02:00
Fix comparisons (aka usage of flag/CCR register)
m68k/aasmcpu.pas, taicpu.spilling_get_operation_type: * add all Sxx instructions as "operand_write" instructions m68k/n68kadd.pas, t68kaddnode.getresflags: * use the correct operation in case of swapped nodes m68k/cgcpu.pas, tcg68k.g_flags2reg: - don't move a 0 to the register, because this will CLR it and thus the flags won't be valid anymore... - NEG would have been the wrong operation (NOT would have been correct), but it isn't needed anyway... * simplify the method by handling the address register case only when necessary git-svn-id: trunk@23383 -
This commit is contained in:
parent
741992bae4
commit
ccecf2c13c
@ -528,7 +528,8 @@ type
|
|||||||
end;
|
end;
|
||||||
A_TST,A_CMP,A_CMPI:
|
A_TST,A_CMP,A_CMPI:
|
||||||
result:=operand_read;
|
result:=operand_read;
|
||||||
A_CLR, A_SXX:
|
A_CLR, A_SXX, A_SEQ, A_SNE, A_SLT, A_SLE, A_SGT, A_SGE, A_SCS, A_SCC,
|
||||||
|
A_SMI, A_SPL, A_SF, A_ST, A_SVS, A_SVC, A_SHI, A_SLS:
|
||||||
result:=operand_write;
|
result:=operand_write;
|
||||||
A_NEG, A_EXT, A_EXTB, A_NOT, A_NEGX:
|
A_NEG, A_EXT, A_EXTB, A_NOT, A_NEGX:
|
||||||
result:=operand_readwrite;
|
result:=operand_readwrite;
|
||||||
|
@ -1449,50 +1449,21 @@ unit cgcpu;
|
|||||||
begin
|
begin
|
||||||
{ move to a Dx register? }
|
{ move to a Dx register? }
|
||||||
if (isaddressregister(reg)) then
|
if (isaddressregister(reg)) then
|
||||||
begin
|
hreg:=getintregister(list,OS_INT)
|
||||||
hreg := getintregister(list,OS_INT);
|
else
|
||||||
a_load_const_reg(list,size,0,hreg);
|
hreg:=reg;
|
||||||
|
|
||||||
ai:=Taicpu.Op_reg(A_Sxx,S_B,hreg);
|
ai:=Taicpu.Op_reg(A_Sxx,S_B,hreg);
|
||||||
ai.SetCondition(flags_to_cond(f));
|
ai.SetCondition(flags_to_cond(f));
|
||||||
list.concat(ai);
|
list.concat(ai);
|
||||||
|
|
||||||
if (current_settings.cputype = cpu_ColdFire) then
|
|
||||||
begin
|
|
||||||
{ neg.b does not exist on the Coldfire
|
|
||||||
so we need to sign extend the value
|
|
||||||
before doing a neg.l
|
|
||||||
}
|
|
||||||
list.concat(taicpu.op_reg(A_EXTB,S_L,hreg));
|
list.concat(taicpu.op_reg(A_EXTB,S_L,hreg));
|
||||||
list.concat(taicpu.op_reg(A_NEG,S_L,hreg));
|
|
||||||
end
|
if hreg<>reg then
|
||||||
else
|
|
||||||
begin
|
begin
|
||||||
list.concat(taicpu.op_reg(A_NEG,S_B,hreg));
|
|
||||||
end;
|
|
||||||
instr:=taicpu.op_reg_reg(A_MOVE,S_L,hreg,reg);
|
instr:=taicpu.op_reg_reg(A_MOVE,S_L,hreg,reg);
|
||||||
add_move_instruction(instr);
|
add_move_instruction(instr);
|
||||||
list.concat(instr);
|
list.concat(instr);
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
a_load_const_reg(list,size,0,reg);
|
|
||||||
ai:=Taicpu.Op_reg(A_Sxx,S_B,reg);
|
|
||||||
ai.SetCondition(flags_to_cond(f));
|
|
||||||
list.concat(ai);
|
|
||||||
|
|
||||||
if (current_settings.cputype = cpu_ColdFire) then
|
|
||||||
begin
|
|
||||||
{ neg.b does not exist on the Coldfire
|
|
||||||
so we need to sign extend the value
|
|
||||||
before doing a neg.l
|
|
||||||
}
|
|
||||||
list.concat(taicpu.op_reg(A_EXTB,S_L,reg));
|
|
||||||
list.concat(taicpu.op_reg(A_NEG,S_L,reg));
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
list.concat(taicpu.op_reg(A_NEG,S_B,reg));
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -267,10 +267,10 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if nf_swapped in flags then
|
if nf_swapped in flags then
|
||||||
case nodetype of
|
case nodetype of
|
||||||
ltn : getresflags:=F_G;
|
ltn : getresflags:=F_GE;
|
||||||
lten : getresflags:=F_GE;
|
lten : getresflags:=F_G;
|
||||||
gtn : getresflags:=F_L;
|
gtn : getresflags:=F_LE;
|
||||||
gten : getresflags:=F_LE;
|
gten : getresflags:=F_L;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
case nodetype of
|
case nodetype of
|
||||||
@ -284,10 +284,10 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if nf_swapped in flags then
|
if nf_swapped in flags then
|
||||||
case nodetype of
|
case nodetype of
|
||||||
ltn : getresflags:=F_A;
|
ltn : getresflags:=F_AE;
|
||||||
lten : getresflags:=F_AE;
|
lten : getresflags:=F_A;
|
||||||
gtn : getresflags:=F_B;
|
gtn : getresflags:=F_BE;
|
||||||
gten : getresflags:=F_BE;
|
gten : getresflags:=F_B;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
case nodetype of
|
case nodetype of
|
||||||
|
Loading…
Reference in New Issue
Block a user