mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2025-01-03 10:29:41 +00:00
Compute how many bytes of arguments are passed to a function.
This is preparatory to supporting a new calling convention for functions returning long long.
This commit is contained in:
parent
05868667b2
commit
11938d51ff
30
Gen.pas
30
Gen.pas
@ -67,6 +67,7 @@ var
|
|||||||
namePushed: boolean; {has a name been pushed in this proc?}
|
namePushed: boolean; {has a name been pushed in this proc?}
|
||||||
skipLoad: boolean; {skip load for a pc_lli, etc?}
|
skipLoad: boolean; {skip load for a pc_lli, etc?}
|
||||||
stackSaveDepth: integer; {nesting depth of saved stack positions}
|
stackSaveDepth: integer; {nesting depth of saved stack positions}
|
||||||
|
argsSize: integer; {total size of argument to a function}
|
||||||
|
|
||||||
{stack frame locations}
|
{stack frame locations}
|
||||||
{---------------------}
|
{---------------------}
|
||||||
@ -4627,6 +4628,7 @@ procedure GenTree {op: icptr};
|
|||||||
var
|
var
|
||||||
lab1: integer; {return point}
|
lab1: integer; {return point}
|
||||||
lLong: longType; {used to reserve gLong}
|
lLong: longType; {used to reserve gLong}
|
||||||
|
lArgsSize: integer; {saved copy of argsSize}
|
||||||
|
|
||||||
begin {GenCui}
|
begin {GenCui}
|
||||||
{save the stack register}
|
{save the stack register}
|
||||||
@ -4640,6 +4642,9 @@ procedure GenTree {op: icptr};
|
|||||||
stackSaveDepth := stackSaveDepth + 1;
|
stackSaveDepth := stackSaveDepth + 1;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
|
||||||
|
lArgsSize := argsSize;
|
||||||
|
argsSize := 0;
|
||||||
|
|
||||||
{generate parameters}
|
{generate parameters}
|
||||||
{place the operands on the stack}
|
{place the operands on the stack}
|
||||||
lLong := gLong;
|
lLong := gLong;
|
||||||
@ -4697,6 +4702,7 @@ procedure GenTree {op: icptr};
|
|||||||
{save the returned value}
|
{save the returned value}
|
||||||
gLong.where := A_X;
|
gLong.where := A_X;
|
||||||
SaveRetValue(op^.optype);
|
SaveRetValue(op^.optype);
|
||||||
|
argsSize := lArgsSize;
|
||||||
end; {GenCui}
|
end; {GenCui}
|
||||||
|
|
||||||
|
|
||||||
@ -4706,6 +4712,7 @@ procedure GenTree {op: icptr};
|
|||||||
|
|
||||||
var
|
var
|
||||||
lLong: longType; {used to reserve gLong}
|
lLong: longType; {used to reserve gLong}
|
||||||
|
lArgsSize: integer; {saved copy of argsSize}
|
||||||
|
|
||||||
begin {GenCup}
|
begin {GenCup}
|
||||||
{save the stack register}
|
{save the stack register}
|
||||||
@ -4719,6 +4726,9 @@ procedure GenTree {op: icptr};
|
|||||||
stackSaveDepth := stackSaveDepth + 1;
|
stackSaveDepth := stackSaveDepth + 1;
|
||||||
end; {if}
|
end; {if}
|
||||||
|
|
||||||
|
lArgsSize := argsSize;
|
||||||
|
argsSize := 0;
|
||||||
|
|
||||||
{generate parameters}
|
{generate parameters}
|
||||||
lLong := gLong;
|
lLong := gLong;
|
||||||
GenTree(op^.left);
|
GenTree(op^.left);
|
||||||
@ -4755,6 +4765,7 @@ procedure GenTree {op: icptr};
|
|||||||
{save the returned value}
|
{save the returned value}
|
||||||
gLong.where := A_X;
|
gLong.where := A_X;
|
||||||
SaveRetValue(op^.optype);
|
SaveRetValue(op^.optype);
|
||||||
|
argsSize := lArgsSize;
|
||||||
end; {GenCup}
|
end; {GenCup}
|
||||||
|
|
||||||
|
|
||||||
@ -5949,6 +5960,25 @@ procedure GenTree {op: icptr};
|
|||||||
lab1: integer; {branch point}
|
lab1: integer; {branch point}
|
||||||
|
|
||||||
begin {GenStk}
|
begin {GenStk}
|
||||||
|
if op^.left^.opcode = pc_psh then begin
|
||||||
|
if (op^.left^.right^.opcode = pc_ldc) and
|
||||||
|
(op^.left^.right^.optype in [cgWord,cgUWord]) then
|
||||||
|
argsSize := argsSize + op^.left^.right^.q
|
||||||
|
else
|
||||||
|
Error(cge1);
|
||||||
|
end {if}
|
||||||
|
else
|
||||||
|
case op^.optype of
|
||||||
|
cgByte,cgUByte,cgWord,cgUWord:
|
||||||
|
argsSize := argsSize + cgWordSize;
|
||||||
|
cgReal,cgDouble,cgComp,cgExtended:
|
||||||
|
argsSize := argsSize + cgExtendedSize;
|
||||||
|
cgLong,cgULong:
|
||||||
|
argsSize := argsSize + cgLongSize;
|
||||||
|
cgQuad,cgUQuad:
|
||||||
|
argsSize := argsSize + cgQuadSize;
|
||||||
|
otherwise: Error(cge1);
|
||||||
|
end; {case}
|
||||||
glong.preference := onStack; {generate the operand}
|
glong.preference := onStack; {generate the operand}
|
||||||
GenTree(op^.left);
|
GenTree(op^.left);
|
||||||
if op^.optype in {do the stk}
|
if op^.optype in {do the stk}
|
||||||
|
Loading…
Reference in New Issue
Block a user