Implement basic load/store ops for long long.

The following intermediate codes should now work:
pc_lod
pc_pop
pc_str
pc_cop
pc_sro
pc_cpo
This commit is contained in:
Stephen Heumann 2021-01-29 23:11:08 -06:00
parent 085cd7eb1b
commit fa835aca43
2 changed files with 139 additions and 0 deletions

View File

@ -166,6 +166,10 @@ else if (op1 <> nil) and (op2 <> nil) then
cgLong, cgULong: cgLong, cgULong:
if op1^.lval = op2^.lval then if op1^.lval = op2^.lval then
CodesMatch := true; CodesMatch := true;
cgQuad, cgUQuad:
if op1^.qval.low32 = op2^.qval.low32 then
if op1^.qval.high32 = op2^.qval.high32 then
CodesMatch := true;
cgReal, cgDouble, cgComp, cgExtended: cgReal, cgDouble, cgComp, cgExtended:
if op1^.rval = op2^.rval then if op1^.rval = op2^.rval then
CodesMatch := true; CodesMatch := true;

135
Gen.pas
View File

@ -3209,6 +3209,42 @@ case optype of
end; {case} end; {case}
end; {else} end; {else}
end; {case CGLong, cgULong} end; {case CGLong, cgULong}
cgQuad, cgUQuad: begin
GenTree(op^.left);
if opcode = pc_sro then
GenImplied(m_pla)
else {if opcode = pc_cpo then}
GenNative(m_lda_s, direct, 1, nil, 0);
if smallMemoryModel then
GenNative(m_sta_abs, absolute, q, lab, 0)
else
GenNative(m_sta_long, longabsolute, q, lab, 0);
if opcode = pc_sro then
GenImplied(m_pla)
else {if opcode = pc_cpo then}
GenNative(m_lda_s, direct, 3, nil, 0);
if smallMemoryModel then
GenNative(m_sta_abs, absolute, q+2, lab, 0)
else
GenNative(m_sta_long, longabsolute, q+2, lab, 0);
if opcode = pc_sro then
GenImplied(m_pla)
else {if opcode = pc_cpo then}
GenNative(m_lda_s, direct, 5, nil, 0);
if smallMemoryModel then
GenNative(m_sta_abs, absolute, q+4, lab, 0)
else
GenNative(m_sta_long, longabsolute, q+4, lab, 0);
if opcode = pc_sro then
GenImplied(m_pla)
else {if opcode = pc_cpo then}
GenNative(m_lda_s, direct, 7, nil, 0);
if smallMemoryModel then
GenNative(m_sta_abs, absolute, q+6, lab, 0)
else
GenNative(m_sta_long, longabsolute, q+6, lab, 0);
end; {case cgQuad, cgUQuad}
end; {case} end; {case}
end; {GenSroCpo} end; {GenSroCpo}
@ -3809,6 +3845,55 @@ case optype of
end; {else} end; {else}
end; end;
cgQuad, cgUQuad: begin
GenTree(op^.left);
if disp < 250 then begin
if op^.opcode = pc_str then
GenImplied(m_pla)
else {if op^.opcode = pc_cop then}
GenNative(m_lda_s, direct, 1, nil, 0);
GenNative(m_sta_dir, direct, disp, nil, 0);
if op^.opcode = pc_str then
GenImplied(m_pla)
else {if op^.opcode = pc_cop then}
GenNative(m_lda_s, direct, 3, nil, 0);
GenNative(m_sta_dir, direct, disp+2, nil, 0);
if op^.opcode = pc_str then
GenImplied(m_pla)
else {if op^.opcode = pc_cop then}
GenNative(m_lda_s, direct, 5, nil, 0);
GenNative(m_sta_dir, direct, disp+4, nil, 0);
if op^.opcode = pc_str then
GenImplied(m_pla)
else {if op^.opcode = pc_cop then}
GenNative(m_lda_s, direct, 7, nil, 0);
GenNative(m_sta_dir, direct, disp+6, nil, 0);
end {else if}
else begin
GenNative(m_ldx_imm, immediate, disp, nil, 0);
if op^.opcode = pc_str then
GenImplied(m_pla)
else {if op^.opcode = pc_cop then}
GenNative(m_lda_s, direct, 1, nil, 0);
GenNative(m_sta_dirX, direct, 0, nil, 0);
if op^.opcode = pc_str then
GenImplied(m_pla)
else {if op^.opcode = pc_cop then}
GenNative(m_lda_s, direct, 3, nil, 0);
GenNative(m_sta_dirX, direct, 2, nil, 0);
if op^.opcode = pc_str then
GenImplied(m_pla)
else {if op^.opcode = pc_cop then}
GenNative(m_lda_s, direct, 5, nil, 0);
GenNative(m_sta_dirX, direct, 4, nil, 0);
if op^.opcode = pc_str then
GenImplied(m_pla)
else {if op^.opcode = pc_cop then}
GenNative(m_lda_s, direct, 7, nil, 0);
GenNative(m_sta_dirX, direct, 6, nil, 0);
end; {else}
end;
otherwise: ; otherwise: ;
end; {case} end; {case}
@ -4579,6 +4664,29 @@ procedure GenTree {op: icptr};
end; {else} end; {else}
end; {case cgLong,cgULong} end; {case cgLong,cgULong}
cgQuad, cgUQuad: begin
if smallMemoryModel then begin
GenNative(m_lda_abs, absolute, op^.q+6, op^.lab, 0);
GenImplied(m_pha);
GenNative(m_lda_abs, absolute, op^.q+4, op^.lab, 0);
GenImplied(m_pha);
GenNative(m_lda_abs, absolute, op^.q+2, op^.lab, 0);
GenImplied(m_pha);
GenNative(m_lda_abs, absolute, op^.q, op^.lab, 0);
GenImplied(m_pha);
end {if}
else begin
GenNative(m_lda_long, longabsolute, op^.q+6, op^.lab, 0);
GenImplied(m_pha);
GenNative(m_lda_long, longabsolute, op^.q+4, op^.lab, 0);
GenImplied(m_pha);
GenNative(m_lda_long, longabsolute, op^.q+2, op^.lab, 0);
GenImplied(m_pha);
GenNative(m_lda_long, longabsolute, op^.q, op^.lab, 0);
GenImplied(m_pha);
end; {else}
end; {case cgQuad,cgUQuad}
otherwise: otherwise:
Error(cge1); Error(cge1);
end; {case} end; {case}
@ -4632,6 +4740,26 @@ procedure GenTree {op: icptr};
GenCall(71); GenCall(71);
end; end;
cgQuad, cgUQuad: begin
if disp >= 250 then begin
GenNative(m_ldx_imm, immediate, disp, nil, 0);
GenNative(m_lda_dirx, direct, 6, nil, 0);
GenImplied(m_pha);
GenNative(m_lda_dirx, direct, 4, nil, 0);
GenImplied(m_pha);
GenNative(m_lda_dirx, direct, 2, nil, 0);
GenImplied(m_pha);
GenNative(m_lda_dirx, direct, 0, nil, 0);
GenImplied(m_pha);
end {if}
else begin
GenNative(m_pei_dir, direct, disp+6, nil, 0);
GenNative(m_pei_dir, direct, disp+4, nil, 0);
GenNative(m_pei_dir, direct, disp+2, nil, 0);
GenNative(m_pei_dir, direct, disp, nil, 0);
end; {else}
end;
cgLong, cgULong: begin cgLong, cgULong: begin
if ((inPointer & gLong.preference) <> 0) and (disp < 254) then if ((inPointer & gLong.preference) <> 0) and (disp < 254) then
begin begin
@ -5008,6 +5136,13 @@ procedure GenTree {op: icptr};
end; {if} end; {if}
{else do nothing} {else do nothing}
cgQuad, cgUQuad: begin
GenImplied(m_tsc);
GenImplied(m_clc);
GenNative(m_adc_imm, immediate, 8, nil, 0);
GenImplied(m_tcs);
end;
cgReal, cgDouble, cgComp, cgExtended: begin cgReal, cgDouble, cgComp, cgExtended: begin
GenImplied(m_tsc); GenImplied(m_tsc);
GenImplied(m_clc); GenImplied(m_clc);