mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-02 04:31:25 +00:00
Generate better code for && and ||.
This commit is contained in:
parent
312a3a09b9
commit
417fd1ad9c
26
Gen.pas
26
Gen.pas
@ -3796,7 +3796,7 @@ procedure GenLogic (op: icptr);
|
|||||||
{ generate a pc_and, pc_ior, pc_bnd, pc_bor or pc_bxr }
|
{ generate a pc_and, pc_ior, pc_bnd, pc_bor or pc_bxr }
|
||||||
|
|
||||||
var
|
var
|
||||||
lab1,lab2: integer; {label}
|
lab1,lab2,lab3: integer; {label}
|
||||||
nd: icptr; {temp node pointer}
|
nd: icptr; {temp node pointer}
|
||||||
opcode: pcodes; {operation code}
|
opcode: pcodes; {operation code}
|
||||||
|
|
||||||
@ -3805,19 +3805,23 @@ opcode := op^.opcode;
|
|||||||
if opcode in [pc_and,pc_ior] then begin
|
if opcode in [pc_and,pc_ior] then begin
|
||||||
lab1 := GenLabel;
|
lab1 := GenLabel;
|
||||||
GenTree(op^.left);
|
GenTree(op^.left);
|
||||||
GenNative(m_cmp_imm, immediate, 0, nil, 0);
|
GenImpliedForFlags(m_tax);
|
||||||
lab2 := GenLabel;
|
lab2 := GenLabel;
|
||||||
if opcode = pc_and then
|
if opcode = pc_and then begin
|
||||||
GenNative(m_bne, relative, lab2, nil, 0)
|
GenNative(m_bne, relative, lab2, nil, 0);
|
||||||
|
GenNative(m_brl, longrelative, lab1, nil, 0);
|
||||||
|
end {if}
|
||||||
else begin
|
else begin
|
||||||
|
lab3 := GenLabel;
|
||||||
GenNative(m_beq, relative, lab2, nil, 0);
|
GenNative(m_beq, relative, lab2, nil, 0);
|
||||||
GenNative(m_lda_imm, immediate, 1, nil, 0);
|
GenNative(m_brl, longrelative, lab3, nil, 0);
|
||||||
end; {else}
|
end; {else}
|
||||||
GenNative(m_brl, longrelative, lab1, nil, 0);
|
|
||||||
GenLab(lab2);
|
GenLab(lab2);
|
||||||
GenTree(op^.right);
|
GenTree(op^.right);
|
||||||
GenNative(m_cmp_imm, immediate, 0, nil, 0);
|
GenImpliedForFlags(m_tax);
|
||||||
GenNative(m_beq, relative, lab1, nil, 0);
|
GenNative(m_beq, relative, lab1, nil, 0);
|
||||||
|
if opcode = pc_ior then
|
||||||
|
GenLab(lab3);
|
||||||
GenNative(m_lda_imm, immediate, 1, nil, 0);
|
GenNative(m_lda_imm, immediate, 1, nil, 0);
|
||||||
GenLab(lab1);
|
GenLab(lab1);
|
||||||
end {if}
|
end {if}
|
||||||
@ -3833,8 +3837,8 @@ else begin
|
|||||||
GenImplied(m_pha);
|
GenImplied(m_pha);
|
||||||
GenTree(op^.right);
|
GenTree(op^.right);
|
||||||
case opcode of
|
case opcode of
|
||||||
pc_and,pc_bnd: GenNative(m_and_s, direct, 1, nil, 0);
|
pc_bnd: GenNative(m_and_s, direct, 1, nil, 0);
|
||||||
pc_ior,pc_bor: GenNative(m_ora_s, direct, 1, nil, 0);
|
pc_bor: GenNative(m_ora_s, direct, 1, nil, 0);
|
||||||
pc_bxr: GenNative(m_eor_s, direct, 1, nil, 0);
|
pc_bxr: GenNative(m_eor_s, direct, 1, nil, 0);
|
||||||
otherwise:
|
otherwise:
|
||||||
Error(cge1);
|
Error(cge1);
|
||||||
@ -3844,8 +3848,8 @@ else begin
|
|||||||
end {if}
|
end {if}
|
||||||
else
|
else
|
||||||
case opcode of
|
case opcode of
|
||||||
pc_and,pc_bnd: OperA(m_and_imm, op^.right);
|
pc_bnd: OperA(m_and_imm, op^.right);
|
||||||
pc_ior,pc_bor: OperA(m_ora_imm, op^.right);
|
pc_bor: OperA(m_ora_imm, op^.right);
|
||||||
pc_bxr: OperA(m_eor_imm, op^.right);
|
pc_bxr: OperA(m_eor_imm, op^.right);
|
||||||
otherwise:
|
otherwise:
|
||||||
Error(cge1);
|
Error(cge1);
|
||||||
|
Loading…
Reference in New Issue
Block a user