diff options
| author | Nate Begeman <natebegeman@mac.com> | 2005-04-03 23:11:17 +0000 |
|---|---|---|
| committer | Nate Begeman <natebegeman@mac.com> | 2005-04-03 23:11:17 +0000 |
| commit | 629cdaea39d22e60da79f63e0818bb631434e5a4 (patch) | |
| tree | 0d819698340206eea44ba34e137c5bb4312ca5ba /llvm/lib/Target | |
| parent | 7a3e929efc1ed8aa1c3d710dff0d9942353a2ee8 (diff) | |
| download | bcm5719-llvm-629cdaea39d22e60da79f63e0818bb631434e5a4.tar.gz bcm5719-llvm-629cdaea39d22e60da79f63e0818bb631434e5a4.zip | |
Full varargs support. All of UnitTests now passes
llvm-svn: 21070
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp b/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp index 6d79c9c7a44..35be0a07259 100644 --- a/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp +++ b/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp @@ -194,12 +194,22 @@ PPC32TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG) { // the start of the first vararg value... for expansion of llvm.va_start. if (F.isVarArg()) { VarArgsFrameIndex = MFI->CreateFixedObject(4, ArgOffset); - // If this function is vararg, store r4-r10 to their spots on the stack so - // that they may be loaded by dereferencing va_next SDOperand FIN = DAG.getFrameIndex(VarArgsFrameIndex, MVT::i32); - SDOperand Val = DAG.getCopyFromReg(PPC::R4, MVT::i32, DAG.getRoot()); - SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1), Val, FIN); - DAG.setRoot(Store); + // If this function is vararg, store any remaining integer argument regs + // to their spots on the stack so that they may be loaded by deferencing the + // result of va_next. + std::vector<SDOperand> MemOps; + for (; GPR_remaining > 0; --GPR_remaining, ++GPR_idx) { + BuildMI(&BB, PPC::IMPLICIT_DEF, 0, GPR[GPR_idx]); + SDOperand Val = DAG.getCopyFromReg(GPR[GPR_idx], MVT::i32, DAG.getRoot()); + SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1), + Val, FIN); + MemOps.push_back(Store); + // Increment the address by four for the next argument to store + SDOperand PtrOff = DAG.getConstant(4, getPointerTy()); + FIN = DAG.getNode(ISD::ADD, MVT::i32, FIN, PtrOff); + } + DAG.setRoot(DAG.getNode(ISD::TokenFactor, MVT::Other, MemOps)); } return ArgValues; |

