mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-01 02:33:44 +00:00
3 changes, 2 of which are cleanup one of which changes codegen:
1. Rearrange code a bit so that the special case doesn't require indenting lots of code. 2. Add comments describing PPC calling convention. 3. Only round up to 56-bytes of stack space for an outgoing call if the callee is varargs. This saves a bit of stack space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28342 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c04ba7a97d
commit
c8b682ca19
@ -889,19 +889,26 @@ static SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG) {
|
||||
std::vector<SDOperand> args_to_use;
|
||||
|
||||
// Count how many bytes are to be pushed on the stack, including the linkage
|
||||
// area, and parameter passing area.
|
||||
// area, and parameter passing area. We start with 24 bytes, which is
|
||||
// prereserved space for [SP][CR][LR][3 x unused].
|
||||
unsigned NumBytes = 24;
|
||||
|
||||
if (Op.getNumOperands() == 5) {
|
||||
Chain = DAG.getCALLSEQ_START(Chain, DAG.getConstant(NumBytes, MVT::i32));
|
||||
} else {
|
||||
// Add up all the space actually used.
|
||||
for (unsigned i = 5, e = Op.getNumOperands(); i != e; ++i)
|
||||
NumBytes += MVT::getSizeInBits(Op.getOperand(i).getValueType())/8;
|
||||
|
||||
// Just to be safe, we'll always reserve the full 24 bytes of linkage area
|
||||
// plus 32 bytes of argument space in case any called code gets funky on us.
|
||||
// (Required by ABI to support var arg)
|
||||
if (NumBytes < 56) NumBytes = 56;
|
||||
// If we are calling what looks like a varargs function on the caller side,
|
||||
// there are two cases:
|
||||
// 1) The callee uses va_start.
|
||||
// 2) The callee doesn't use va_start.
|
||||
//
|
||||
// In the case of #1, the prolog code will store up to 8 GPR argument
|
||||
// registers to the stack, allowing va_start to index over them in memory.
|
||||
// Because we cannot tell the difference (on the caller side) between #1/#2,
|
||||
// we have to conservatively assume we have #1. As such, make sure we have
|
||||
// at least enough stack space for the caller to store the 8 GPRs.
|
||||
if (isVarArg && Op.getNumOperands() > 5 && NumBytes < 56)
|
||||
NumBytes = 56;
|
||||
|
||||
// Adjust the stack pointer for the new arguments...
|
||||
// These operations are automatically eliminated by the prolog/epilog pass
|
||||
@ -1002,7 +1009,6 @@ static SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG) {
|
||||
}
|
||||
if (!MemOps.empty())
|
||||
Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, MemOps);
|
||||
}
|
||||
|
||||
std::vector<MVT::ValueType> RetVals(Op.Val->value_begin(),
|
||||
Op.Val->value_end());
|
||||
|
Loading…
x
Reference in New Issue
Block a user