mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-05-29 04:41:27 +00:00
Implement 64-bit shifts.
This commit is contained in:
parent
00d72f04d3
commit
8faafcc7c8
13
CGI.Comments
13
CGI.Comments
|
@ -576,25 +576,32 @@
|
||||||
{ }
|
{ }
|
||||||
{ pc_shl - shift left }
|
{ pc_shl - shift left }
|
||||||
{ pc_sll - shift left long }
|
{ pc_sll - shift left long }
|
||||||
|
{ pc_slq - shift left long long }
|
||||||
{ }
|
{ }
|
||||||
{ Gen0(pc_shl) cgByte,cgUByte,cgWord,cgUWord }
|
{ Gen0(pc_shl) cgByte,cgUByte,cgWord,cgUWord }
|
||||||
{ Gen0(pc_sll) cgLong,cgULong }
|
{ Gen0(pc_sll) cgLong,cgULong }
|
||||||
|
{ Gen0(pc_slq) cgQuad,cgUQuad (tos-1) / cgWord (tos) }
|
||||||
{ }
|
{ }
|
||||||
{ The value at tos-1 is shifted left by the number of bits }
|
{ The value at tos-1 is shifted left by the number of bits }
|
||||||
{ specified by tos. The result is an integer, which replaces }
|
{ specified by tos. The result is an integer, which replaces }
|
||||||
{ the operands on the stack. The right bit positions are }
|
{ the operands on the stack. The right bit positions are }
|
||||||
{ filled with zeros. }
|
{ filled with zeros. For pc_slq, only the value at tos-1 is }
|
||||||
|
{ cgQuad/cgUQuad; the shift count at tos is cgWord or cgUWord. }
|
||||||
{ }
|
{ }
|
||||||
{ }
|
{ }
|
||||||
{ pc_shr - shift right }
|
{ pc_shr - shift right }
|
||||||
{ pc_usr - unsigned shift right }
|
{ pc_usr - unsigned shift right }
|
||||||
{ pc_slr - long shift right }
|
{ pc_slr - long shift right }
|
||||||
{ pc_vsr - unsigned long shift right }
|
{ pc_vsr - unsigned long shift right }
|
||||||
|
{ pc_sqr - long long shift right }
|
||||||
|
{ pc_wsr - unsigned long long shift right }
|
||||||
{ }
|
{ }
|
||||||
{ Gen0(pc_shr) cgByte,cgWord }
|
{ Gen0(pc_shr) cgByte,cgWord }
|
||||||
{ Gen0(pc_usr) cgUByte,cgUWord }
|
{ Gen0(pc_usr) cgUByte,cgUWord }
|
||||||
{ Gen0(pc_slr) cgLong }
|
{ Gen0(pc_slr) cgLong }
|
||||||
{ Gen0(pc_vsr) cgULong }
|
{ Gen0(pc_vsr) cgULong }
|
||||||
|
{ Gen0(pc_sqr) cgQuad (tos-1) / cgWord (tos) }
|
||||||
|
{ Gen0(pc_wsr) cgUQuad (tos-1) / cgWord (tos) }
|
||||||
{ }
|
{ }
|
||||||
{ The value at tos-1 is shifted right by the number of bits }
|
{ The value at tos-1 is shifted right by the number of bits }
|
||||||
{ specified by tos. The result is an integer, which replaces }
|
{ specified by tos. The result is an integer, which replaces }
|
||||||
|
@ -604,7 +611,9 @@
|
||||||
{ }
|
{ }
|
||||||
{ Pc_usr is the unsigned form. The operation is the same, }
|
{ Pc_usr is the unsigned form. The operation is the same, }
|
||||||
{ except that the leftmost bit is replaced with a zero. }
|
{ except that the leftmost bit is replaced with a zero. }
|
||||||
{ Pc_vsr is used for unsigned long operations. }
|
{ Pc_vsr is used for unsigned long operations, and pc_wsr is }
|
||||||
|
{ used for unsigned long long operations. }
|
||||||
|
{ }
|
||||||
{ }
|
{ }
|
||||||
{ pc_stk - stack an operand }
|
{ pc_stk - stack an operand }
|
||||||
{ }
|
{ }
|
||||||
|
|
2
CGI.pas
2
CGI.pas
|
@ -230,7 +230,7 @@ type
|
||||||
pc_gli,pc_gdl,pc_gld,pc_cpi,pc_tri,pc_lbu,pc_lbf,pc_sbf,pc_cbf,dc_cns,
|
pc_gli,pc_gdl,pc_gld,pc_cpi,pc_tri,pc_lbu,pc_lbf,pc_sbf,pc_cbf,dc_cns,
|
||||||
dc_prm,pc_nat,pc_bno,pc_nop,pc_psh,pc_ili,pc_iil,pc_ild,pc_idl,
|
dc_prm,pc_nat,pc_bno,pc_nop,pc_psh,pc_ili,pc_iil,pc_ild,pc_idl,
|
||||||
pc_bqr,pc_bqx,pc_baq,pc_bnq,pc_ngq,pc_adq,pc_sbq,pc_mpq,pc_umq,pc_dvq,
|
pc_bqr,pc_bqx,pc_baq,pc_bnq,pc_ngq,pc_adq,pc_sbq,pc_mpq,pc_umq,pc_dvq,
|
||||||
pc_udq,pc_mdq,pc_uqm);
|
pc_udq,pc_mdq,pc_uqm,pc_slq,pc_sqr,pc_wsr);
|
||||||
|
|
||||||
{intermediate code}
|
{intermediate code}
|
||||||
{-----------------}
|
{-----------------}
|
||||||
|
|
8
DAG.pas
8
DAG.pas
|
@ -2385,9 +2385,12 @@ case op^.opcode of
|
||||||
TypeOf := cgULong;
|
TypeOf := cgULong;
|
||||||
|
|
||||||
pc_bnq, pc_ngq, pc_bqr, pc_bqx, pc_baq, pc_adq, pc_sbq, pc_mpq,
|
pc_bnq, pc_ngq, pc_bqr, pc_bqx, pc_baq, pc_adq, pc_sbq, pc_mpq,
|
||||||
pc_umq, pc_dvq, pc_udq, pc_mdq, pc_uqm:
|
pc_dvq, pc_mdq, pc_slq, pc_sqr:
|
||||||
TypeOf := cgQuad;
|
TypeOf := cgQuad;
|
||||||
|
|
||||||
|
pc_umq, pc_udq, pc_uqm, pc_wsr:
|
||||||
|
TypeOf := cgUQuad;
|
||||||
|
|
||||||
pc_ngr, pc_adr, pc_dvr, pc_mpr, pc_sbr:
|
pc_ngr, pc_adr, pc_dvr, pc_mpr, pc_sbr:
|
||||||
TypeOf := cgExtended;
|
TypeOf := cgExtended;
|
||||||
|
|
||||||
|
@ -5063,7 +5066,8 @@ case code^.opcode of
|
||||||
pc_ulm, pc_mpi, pc_umi, pc_mpl, pc_uml, pc_mpr, pc_psh, pc_sbi,
|
pc_ulm, pc_mpi, pc_umi, pc_mpl, pc_uml, pc_mpr, pc_psh, pc_sbi,
|
||||||
pc_sbl, pc_sbr, pc_shl, pc_sll, pc_shr, pc_usr, pc_slr, pc_vsr,
|
pc_sbl, pc_sbr, pc_shl, pc_sll, pc_shr, pc_usr, pc_slr, pc_vsr,
|
||||||
pc_tri, pc_sbf, pc_sto, pc_cui, pc_bqr, pc_bqx, pc_baq, pc_adq,
|
pc_tri, pc_sbf, pc_sto, pc_cui, pc_bqr, pc_bqx, pc_baq, pc_adq,
|
||||||
pc_sbq, pc_mpq, pc_umq, pc_dvq, pc_udq, pc_mdq, pc_uqm:
|
pc_sbq, pc_mpq, pc_umq, pc_dvq, pc_udq, pc_mdq, pc_uqm, pc_slq,
|
||||||
|
pc_sqr, pc_wsr:
|
||||||
begin
|
begin
|
||||||
code^.right := Pop;
|
code^.right := Pop;
|
||||||
code^.left := Pop;
|
code^.left := Pop;
|
||||||
|
|
|
@ -3090,10 +3090,17 @@ case tree^.token.kind of
|
||||||
[cgReal,cgDouble,cgComp,cgExtended,cgVoid] then
|
[cgReal,cgDouble,cgComp,cgExtended,cgVoid] then
|
||||||
Error(66);
|
Error(66);
|
||||||
et := UsualUnaryConversions;
|
et := UsualUnaryConversions;
|
||||||
if et <> Unary(ltype^.baseType) then begin
|
if ltype^.baseType in [cgQuad,cgUQuad] then begin
|
||||||
Gen2(pc_cnv, et, ord(Unary(ltype^.baseType)));
|
if not (et in [cgWord,cgUWord]) then begin
|
||||||
|
Gen2(pc_cnv, et, ord(cgWord));
|
||||||
|
end; {if}
|
||||||
expressionType := lType;
|
expressionType := lType;
|
||||||
end; {if}
|
end {if}
|
||||||
|
else
|
||||||
|
if et <> Unary(ltype^.baseType) then begin
|
||||||
|
Gen2(pc_cnv, et, ord(Unary(ltype^.baseType)));
|
||||||
|
expressionType := lType;
|
||||||
|
end; {if}
|
||||||
end; {if}
|
end; {if}
|
||||||
if kind <> pointerType then
|
if kind <> pointerType then
|
||||||
et := UsualBinaryConversions(lType)
|
et := UsualBinaryConversions(lType)
|
||||||
|
@ -3190,6 +3197,8 @@ case tree^.token.kind of
|
||||||
Gen0(pc_shl)
|
Gen0(pc_shl)
|
||||||
else if et in [cgLong,cgULong] then
|
else if et in [cgLong,cgULong] then
|
||||||
Gen0(pc_sll)
|
Gen0(pc_sll)
|
||||||
|
else if et in [cgQuad,cgUQuad] then
|
||||||
|
Gen0(pc_slq)
|
||||||
else
|
else
|
||||||
Error(66);
|
Error(66);
|
||||||
|
|
||||||
|
@ -3202,6 +3211,10 @@ case tree^.token.kind of
|
||||||
Gen0(pc_slr)
|
Gen0(pc_slr)
|
||||||
else if et = cgULong then
|
else if et = cgULong then
|
||||||
Gen0(pc_vsr)
|
Gen0(pc_vsr)
|
||||||
|
else if et = cgQuad then
|
||||||
|
Gen0(pc_sqr)
|
||||||
|
else if et = cgUQuad then
|
||||||
|
Gen0(pc_wsr)
|
||||||
else
|
else
|
||||||
Error(66);
|
Error(66);
|
||||||
|
|
||||||
|
@ -3399,15 +3412,22 @@ case tree^.token.kind of
|
||||||
GenerateCode(tree^.right);
|
GenerateCode(tree^.right);
|
||||||
if (expressionType^.kind <> scalarType)
|
if (expressionType^.kind <> scalarType)
|
||||||
or not (expressionType^.baseType in
|
or not (expressionType^.baseType in
|
||||||
[cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong]) then
|
[cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong,cgQuad,cgUQuad]) then
|
||||||
error(66);
|
error(66);
|
||||||
if expressionType^.baseType <> et then
|
if et in [cgQuad,cgUQuad] then begin
|
||||||
Gen2(pc_cnv, ord(expressionType^.baseType), ord(et));
|
if not (expressionType^.baseType in [cgWord,cgUWord]) then
|
||||||
|
Gen2(pc_cnv, ord(expressionType^.baseType), ord(cgWord));
|
||||||
|
end {if}
|
||||||
|
else
|
||||||
|
if expressionType^.baseType <> et then
|
||||||
|
Gen2(pc_cnv, ord(expressionType^.baseType), ord(et));
|
||||||
case et of
|
case et of
|
||||||
cgByte,cgUByte,cgWord,cgUWord:
|
cgByte,cgUByte,cgWord,cgUWord:
|
||||||
Gen0(pc_shl);
|
Gen0(pc_shl);
|
||||||
cgLong,cgULong:
|
cgLong,cgULong:
|
||||||
Gen0(pc_sll);
|
Gen0(pc_sll);
|
||||||
|
cgQuad,cgUQuad:
|
||||||
|
Gen0(pc_slq);
|
||||||
otherwise:
|
otherwise:
|
||||||
error(66);
|
error(66);
|
||||||
end; {case}
|
end; {case}
|
||||||
|
@ -3425,10 +3445,15 @@ case tree^.token.kind of
|
||||||
GenerateCode(tree^.right);
|
GenerateCode(tree^.right);
|
||||||
if (expressionType^.kind <> scalarType)
|
if (expressionType^.kind <> scalarType)
|
||||||
or not (expressionType^.baseType in
|
or not (expressionType^.baseType in
|
||||||
[cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong]) then
|
[cgByte,cgUByte,cgWord,cgUWord,cgLong,cgULong,cgQuad,cgUQuad]) then
|
||||||
error(66);
|
error(66);
|
||||||
if expressionType^.baseType <> et then
|
if et in [cgQuad,cgUQuad] then begin
|
||||||
Gen2(pc_cnv, ord(expressionType^.baseType), ord(et));
|
if not (expressionType^.baseType in [cgWord,cgUWord]) then
|
||||||
|
Gen2(pc_cnv, ord(expressionType^.baseType), ord(cgWord));
|
||||||
|
end {if}
|
||||||
|
else
|
||||||
|
if expressionType^.baseType <> et then
|
||||||
|
Gen2(pc_cnv, ord(expressionType^.baseType), ord(et));
|
||||||
case et of
|
case et of
|
||||||
cgByte,cgWord:
|
cgByte,cgWord:
|
||||||
Gen0(pc_shr);
|
Gen0(pc_shr);
|
||||||
|
@ -3438,6 +3463,10 @@ case tree^.token.kind of
|
||||||
Gen0(pc_slr);
|
Gen0(pc_slr);
|
||||||
cgULong:
|
cgULong:
|
||||||
Gen0(pc_vsr);
|
Gen0(pc_vsr);
|
||||||
|
cgQuad:
|
||||||
|
Gen0(pc_sqr);
|
||||||
|
cgUQuad:
|
||||||
|
Gen0(pc_wsr);
|
||||||
otherwise:
|
otherwise:
|
||||||
error(66);
|
error(66);
|
||||||
end; {case}
|
end; {case}
|
||||||
|
|
10
Gen.pas
10
Gen.pas
|
@ -4575,6 +4575,12 @@ procedure GenTree {op: icptr};
|
||||||
GenImplied(m_tcs);
|
GenImplied(m_tcs);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
pc_slq: GenCall(85);
|
||||||
|
|
||||||
|
pc_sqr: GenCall(86);
|
||||||
|
|
||||||
|
pc_wsr: GenCall(87);
|
||||||
|
|
||||||
otherwise: Error(cge1);
|
otherwise: Error(cge1);
|
||||||
end; {case}
|
end; {case}
|
||||||
end; {GenBinQuad}
|
end; {GenBinQuad}
|
||||||
|
@ -6263,8 +6269,8 @@ case op^.opcode of
|
||||||
pc_and,pc_bnd,pc_bor,pc_bxr,pc_ior: GenLogic(op);
|
pc_and,pc_bnd,pc_bor,pc_bxr,pc_ior: GenLogic(op);
|
||||||
pc_blr,pc_blx,pc_bal,pc_dvl,pc_mdl,pc_mpl,pc_sll,pc_slr,pc_udl,pc_ulm,
|
pc_blr,pc_blx,pc_bal,pc_dvl,pc_mdl,pc_mpl,pc_sll,pc_slr,pc_udl,pc_ulm,
|
||||||
pc_uml,pc_vsr: GenBinLong(op);
|
pc_uml,pc_vsr: GenBinLong(op);
|
||||||
pc_bqr,pc_bqx,pc_baq,pc_mpq,pc_umq,pc_dvq,pc_udq,pc_mdq,pc_uqm:
|
pc_bqr,pc_bqx,pc_baq,pc_mpq,pc_umq,pc_dvq,pc_udq,pc_mdq,pc_uqm,pc_slq,
|
||||||
GenBinQuad(op);
|
pc_sqr,pc_wsr: GenBinQuad(op);
|
||||||
pc_bnl,pc_ngl: GenUnaryLong(op);
|
pc_bnl,pc_ngl: GenUnaryLong(op);
|
||||||
pc_bnq,pc_ngq: GenUnaryQuad(op);
|
pc_bnq,pc_ngq: GenUnaryQuad(op);
|
||||||
pc_bno: GenBno(op);
|
pc_bno: GenBno(op);
|
||||||
|
|
|
@ -2039,6 +2039,9 @@ case callNum of
|
||||||
82: sp := @'~UDIV8';
|
82: sp := @'~UDIV8';
|
||||||
83: sp := @'~CNVLONGLONGREAL';
|
83: sp := @'~CNVLONGLONGREAL';
|
||||||
84: sp := @'~CNVULONGLONGREAL';
|
84: sp := @'~CNVULONGLONGREAL';
|
||||||
|
85: sp := @'~SHL8';
|
||||||
|
86: sp := @'~ASHR8';
|
||||||
|
87: sp := @'~LSHR8';
|
||||||
otherwise:
|
otherwise:
|
||||||
Error(cge1);
|
Error(cge1);
|
||||||
end; {case}
|
end; {case}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user