[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp PPC64ISelPattern.cpp
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Sat Jun 18 11:35:10 PDT 2005
Changes in directory llvm/lib/Target/PowerPC:
PPC32ISelSimple.cpp updated: 1.141 -> 1.142
PPC64ISelPattern.cpp updated: 1.21 -> 1.22
---
Log message:
core changes for varargs
---
Diffs of the changes: (+41 -43)
PPC32ISelSimple.cpp | 44 ++++++++++++++------------------------------
PPC64ISelPattern.cpp | 40 +++++++++++++++++++++++++++-------------
2 files changed, 41 insertions(+), 43 deletions(-)
Index: llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.141 llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.142
--- llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp:1.141 Fri Apr 22 12:54:30 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp Sat Jun 18 13:34:52 2005
@@ -310,7 +310,6 @@
void visitShiftInst(ShiftInst &I);
void visitPHINode(PHINode &I) {} // PHI nodes handled by second pass
void visitCastInst(CastInst &I);
- void visitVANextInst(VANextInst &I);
void visitVAArgInst(VAArgInst &I);
void visitInstruction(Instruction &I) {
@@ -1978,6 +1977,7 @@
unsigned TmpReg1, TmpReg2, TmpReg3;
switch (ID) {
case Intrinsic::vastart:
+ //FIXME: need to store, not return a value
// Get the address of the first vararg value...
TmpReg1 = getReg(CI);
addFrameReference(BuildMI(BB, PPC::ADDI, 2, TmpReg1), VarArgsFrameIndex,
@@ -1985,6 +1985,7 @@
return;
case Intrinsic::vacopy:
+ //FIXME: need to store into first arg the value of the second
TmpReg1 = getReg(CI);
TmpReg2 = getReg(CI.getOperand(1));
BuildMI(BB, PPC::OR, 2, TmpReg1).addReg(TmpReg2).addReg(TmpReg2);
@@ -3679,37 +3680,12 @@
abort();
}
-/// visitVANextInst - Implement the va_next instruction...
-///
-void PPC32ISel::visitVANextInst(VANextInst &I) {
- unsigned VAList = getReg(I.getOperand(0));
- unsigned DestReg = getReg(I);
-
- unsigned Size;
- switch (I.getArgType()->getTypeID()) {
- default:
- std::cerr << I;
- assert(0 && "Error: bad type for va_next instruction!");
- return;
- case Type::PointerTyID:
- case Type::UIntTyID:
- case Type::IntTyID:
- Size = 4;
- break;
- case Type::ULongTyID:
- case Type::LongTyID:
- case Type::DoubleTyID:
- Size = 8;
- break;
- }
-
- // Increment the VAList pointer...
- BuildMI(BB, PPC::ADDI, 2, DestReg).addReg(VAList).addSImm(Size);
-}
-
void PPC32ISel::visitVAArgInst(VAArgInst &I) {
- unsigned VAList = getReg(I.getOperand(0));
+ unsigned VAListPtr = getReg(I.getOperand(0));
unsigned DestReg = getReg(I);
+ unsigned VAList = makeAnotherReg(Type::IntTy);
+ BuildMI(BB, PPC::LWZ, 2, VAList).addSImm(0).addReg(VAListPtr);
+ int Size;
switch (I.getType()->getTypeID()) {
default:
@@ -3719,20 +3695,28 @@
case Type::PointerTyID:
case Type::UIntTyID:
case Type::IntTyID:
+ Size = 4;
BuildMI(BB, PPC::LWZ, 2, DestReg).addSImm(0).addReg(VAList);
break;
case Type::ULongTyID:
case Type::LongTyID:
+ Size = 8;
BuildMI(BB, PPC::LWZ, 2, DestReg).addSImm(0).addReg(VAList);
BuildMI(BB, PPC::LWZ, 2, DestReg+1).addSImm(4).addReg(VAList);
break;
case Type::FloatTyID:
+ Size = 4; //?? Bad value?
BuildMI(BB, PPC::LFS, 2, DestReg).addSImm(0).addReg(VAList);
break;
case Type::DoubleTyID:
+ Size = 8;
BuildMI(BB, PPC::LFD, 2, DestReg).addSImm(0).addReg(VAList);
break;
}
+ // Increment the VAList pointer...
+ unsigned NP = makeAnotherReg(Type::IntTy);
+ BuildMI(BB, PPC::ADDI, 2, NP).addReg(VAList).addSImm(Size);
+ BuildMI(BB, PPC::STW, 3).addReg(NP).addSImm(0).addReg(VAListPtr);
}
/// visitGetElementPtrInst - instruction-select GEP instructions
Index: llvm/lib/Target/PowerPC/PPC64ISelPattern.cpp
diff -u llvm/lib/Target/PowerPC/PPC64ISelPattern.cpp:1.21 llvm/lib/Target/PowerPC/PPC64ISelPattern.cpp:1.22
--- llvm/lib/Target/PowerPC/PPC64ISelPattern.cpp:1.21 Sun May 15 14:54:37 2005
+++ llvm/lib/Target/PowerPC/PPC64ISelPattern.cpp Sat Jun 18 13:34:52 2005
@@ -98,12 +98,16 @@
SelectionDAG &DAG);
virtual std::pair<SDOperand, SDOperand>
- LowerVAStart(SDOperand Chain, SelectionDAG &DAG);
+ LowerVAStart(SDOperand Chain, SelectionDAG &DAG, SDOperand Dest);
virtual std::pair<SDOperand,SDOperand>
- LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList,
+ LowerVAArgNext(SDOperand Chain, SDOperand VAList,
const Type *ArgTy, SelectionDAG &DAG);
+ virtual std::pair<SDOperand,SDOperand>
+ LowerVACopy(SDOperand Chain, SDOperand Src, SDOperand Dest,
+ SelectionDAG &DAG);
+
virtual std::pair<SDOperand, SDOperand>
LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain, unsigned Depth,
SelectionDAG &DAG);
@@ -365,26 +369,36 @@
}
std::pair<SDOperand, SDOperand>
-PPC64TargetLowering::LowerVAStart(SDOperand Chain, SelectionDAG &DAG) {
- //vastart just returns the address of the VarArgsFrameIndex slot.
- return std::make_pair(DAG.getFrameIndex(VarArgsFrameIndex, MVT::i64), Chain);
+PPC64TargetLowering::LowerVAStart(SDOperand Chain, SelectionDAG &DAG, SDOperand Dest) {
+ // vastart just stores the address of the VarArgsFrameIndex slot.
+ SDOperand FR = DAG.getFrameIndex(VarArgsFrameIndex, MVT::i64);
+ SDOperand Result = DAG.getNode(ISD::STORE, MVT::Other, Chain, FR, Dest, DAG.getSrcValue(NULL));
+ return std::make_pair(Result, Result);
}
std::pair<SDOperand,SDOperand> PPC64TargetLowering::
-LowerVAArgNext(bool isVANext, SDOperand Chain, SDOperand VAList,
+LowerVAArgNext(SDOperand Chain, SDOperand VAList,
const Type *ArgTy, SelectionDAG &DAG) {
MVT::ValueType ArgVT = getValueType(ArgTy);
SDOperand Result;
- if (!isVANext) {
- Result = DAG.getLoad(ArgVT, DAG.getEntryNode(), VAList,
- DAG.getSrcValue(NULL));
- } else {
- Result = DAG.getNode(ISD::ADD, VAList.getValueType(), VAList,
- DAG.getConstant(8, VAList.getValueType()));
- }
+ SDOperand Val = DAG.getLoad(MVT::i64, Chain, VAList, DAG.getSrcValue(NULL));
+ Result = DAG.getLoad(ArgVT, Val.getValue(1), Val, DAG.getSrcValue(NULL));
+ Val = DAG.getNode(ISD::ADD, VAList.getValueType(), Val,
+ DAG.getConstant(8, VAList.getValueType()));
+ Chain = DAG.getNode(ISD::STORE, MVT::Other, Chain,
+ Val, VAList, DAG.getSrcValue(NULL));
return std::make_pair(Result, Chain);
}
+std::pair<SDOperand,SDOperand>
+PPC64TargetLowering::LowerVACopy(SDOperand Chain, SDOperand Src,
+ SDOperand Dest, SelectionDAG &DAG)
+{
+ SDOperand Result = DAG.getNode(ISD::STORE, MVT::Other, Chain,
+ Src, Dest, DAG.getSrcValue(NULL));
+ return std::make_pair(Result, Result);
+}
+
std::pair<SDOperand, SDOperand> PPC64TargetLowering::
LowerFrameReturnAddress(bool isFrameAddress, SDOperand Chain, unsigned Depth,
More information about the llvm-commits
mailing list