mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-08-15 07:27:27 +00:00
Do quad add/subtract without loading operands on stack.
As with the previous support for bitwise ops, this applies if the operands are simple quad loads.
This commit is contained in:
73
Gen.pas
73
Gen.pas
@@ -47,6 +47,7 @@ const
|
|||||||
globalLabel = 16;
|
globalLabel = 16;
|
||||||
constant = 32;
|
constant = 32;
|
||||||
nowhere = 64;
|
nowhere = 64;
|
||||||
|
inStackLoc = 128;
|
||||||
|
|
||||||
{stack frame locations}
|
{stack frame locations}
|
||||||
{---------------------}
|
{---------------------}
|
||||||
@@ -403,6 +404,9 @@ case gQuad.preference of
|
|||||||
end; {else}
|
end; {else}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
inStackLoc:
|
||||||
|
GenNative(m_sta_s, direct, gQuad.disp+offset, nil, 0);
|
||||||
|
|
||||||
onStack:
|
onStack:
|
||||||
GenImplied(m_pha);
|
GenImplied(m_pha);
|
||||||
|
|
||||||
@@ -876,11 +880,36 @@ procedure GenAdqSbq (op: icptr);
|
|||||||
{ op - pc_adq or pc_sbq operation }
|
{ op - pc_adq or pc_sbq operation }
|
||||||
|
|
||||||
begin {GenAdqSbq}
|
begin {GenAdqSbq}
|
||||||
gQuad.preference := onStack;
|
|
||||||
GenTree(op^.right);
|
|
||||||
gQuad.preference := onStack;
|
|
||||||
GenTree(op^.left);
|
|
||||||
if op^.opcode = pc_adq then begin
|
if op^.opcode = pc_adq then begin
|
||||||
|
if SimpleQuadLoad(op^.left) and SimpleQuadLoad(op^.right) then begin
|
||||||
|
gQuad.where := gQuad.preference;
|
||||||
|
if gQuad.preference = onStack then begin
|
||||||
|
GenImplied(m_tsc);
|
||||||
|
GenImplied(m_sec);
|
||||||
|
GenNative(m_sbc_imm, immediate, 8, nil, 0);
|
||||||
|
GenImplied(m_tcs);
|
||||||
|
gQuad.preference := inStackLoc;
|
||||||
|
gQuad.disp := 1;
|
||||||
|
end; {if}
|
||||||
|
GenImplied(m_clc);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 0);
|
||||||
|
OpOnWordOfQuad(m_adc_imm, op^.right, 0);
|
||||||
|
StoreWordOfQuad(0);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 2);
|
||||||
|
OpOnWordOfQuad(m_adc_imm, op^.right, 2);
|
||||||
|
StoreWordOfQuad(2);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 4);
|
||||||
|
OpOnWordOfQuad(m_adc_imm, op^.right, 4);
|
||||||
|
StoreWordOfQuad(4);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 6);
|
||||||
|
OpOnWordOfQuad(m_adc_imm, op^.right, 6);
|
||||||
|
StoreWordOfQuad(6);
|
||||||
|
end {if}
|
||||||
|
else begin
|
||||||
|
gQuad.preference := onStack;
|
||||||
|
GenTree(op^.right);
|
||||||
|
gQuad.preference := onStack;
|
||||||
|
GenTree(op^.left);
|
||||||
GenImplied(m_clc);
|
GenImplied(m_clc);
|
||||||
GenImplied(m_pla);
|
GenImplied(m_pla);
|
||||||
GenNative(m_adc_s, direct, 7, nil, 0);
|
GenNative(m_adc_s, direct, 7, nil, 0);
|
||||||
@@ -894,8 +923,39 @@ if op^.opcode = pc_adq then begin
|
|||||||
GenImplied(m_pla);
|
GenImplied(m_pla);
|
||||||
GenNative(m_adc_s, direct, 7, nil, 0);
|
GenNative(m_adc_s, direct, 7, nil, 0);
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
end {else}
|
gQuad.where := onStack;
|
||||||
|
end; {else}
|
||||||
|
end {if}
|
||||||
else {if op^.opcode = pc_sbq then} begin
|
else {if op^.opcode = pc_sbq then} begin
|
||||||
|
if SimpleQuadLoad(op^.left) and SimpleQuadLoad(op^.right) then begin
|
||||||
|
gQuad.where := gQuad.preference;
|
||||||
|
if gQuad.preference = onStack then begin
|
||||||
|
GenImplied(m_tsc);
|
||||||
|
GenImplied(m_sec);
|
||||||
|
GenNative(m_sbc_imm, immediate, 8, nil, 0);
|
||||||
|
GenImplied(m_tcs);
|
||||||
|
gQuad.preference := inStackLoc;
|
||||||
|
gQuad.disp := 1;
|
||||||
|
end; {if}
|
||||||
|
GenImplied(m_sec);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 0);
|
||||||
|
OpOnWordOfQuad(m_sbc_imm, op^.right, 0);
|
||||||
|
StoreWordOfQuad(0);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 2);
|
||||||
|
OpOnWordOfQuad(m_sbc_imm, op^.right, 2);
|
||||||
|
StoreWordOfQuad(2);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 4);
|
||||||
|
OpOnWordOfQuad(m_sbc_imm, op^.right, 4);
|
||||||
|
StoreWordOfQuad(4);
|
||||||
|
OpOnWordOfQuad(m_lda_imm, op^.left, 6);
|
||||||
|
OpOnWordOfQuad(m_sbc_imm, op^.right, 6);
|
||||||
|
StoreWordOfQuad(6);
|
||||||
|
end {if}
|
||||||
|
else begin
|
||||||
|
gQuad.preference := onStack;
|
||||||
|
GenTree(op^.right);
|
||||||
|
gQuad.preference := onStack;
|
||||||
|
GenTree(op^.left);
|
||||||
GenImplied(m_sec);
|
GenImplied(m_sec);
|
||||||
GenImplied(m_pla);
|
GenImplied(m_pla);
|
||||||
GenNative(m_sbc_s, direct, 7, nil, 0);
|
GenNative(m_sbc_s, direct, 7, nil, 0);
|
||||||
@@ -909,8 +969,9 @@ else {if op^.opcode = pc_sbq then} begin
|
|||||||
GenImplied(m_pla);
|
GenImplied(m_pla);
|
||||||
GenNative(m_sbc_s, direct, 7, nil, 0);
|
GenNative(m_sbc_s, direct, 7, nil, 0);
|
||||||
GenNative(m_sta_s, direct, 7, nil, 0);
|
GenNative(m_sta_s, direct, 7, nil, 0);
|
||||||
|
gQuad.where := onStack;
|
||||||
|
end; {else}
|
||||||
end; {else}
|
end; {else}
|
||||||
gQuad.where := onStack;
|
|
||||||
end; {GenAdqSbq}
|
end; {GenAdqSbq}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user