Make several cleanups to Andrews varargs change:

1. Pass Value*'s into lowering methods so that the proper pointers can be
   added to load/stores from the valist
2. Intrinsics that return void should only return a token chain, not a token
   chain/retval pair.
3. Rename LowerVAArgNext -> LowerVAArg, because VANext is long gone.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22338 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-07-05 19:57:53 +00:00
parent f2eb1396b8
commit e64e72b794
2 changed files with 43 additions and 35 deletions

View File

@ -26,6 +26,7 @@
#include <vector> #include <vector>
namespace llvm { namespace llvm {
class Value;
class Function; class Function;
class TargetMachine; class TargetMachine;
class TargetData; class TargetData;
@ -266,25 +267,29 @@ public:
ArgListTy &Args, SelectionDAG &DAG) = 0; ArgListTy &Args, SelectionDAG &DAG) = 0;
/// LowerVAStart - This lowers the llvm.va_start intrinsic. If not /// LowerVAStart - This lowers the llvm.va_start intrinsic. If not
/// implemented, this method prints a message and aborts. /// implemented, this method prints a message and aborts. This method should
virtual std::pair<SDOperand, SDOperand> /// return the modified chain value. Note that VAListPtr* correspond to the
LowerVAStart(SDOperand Chain, SelectionDAG &DAG, SDOperand Dest); /// llvm.va_start operand.
virtual SDOperand LowerVAStart(SDOperand Chain, SDOperand VAListP,
Value *VAListV, SelectionDAG &DAG);
/// LowerVAEnd - This lowers llvm.va_end and returns the resultant chain. If /// LowerVAEnd - This lowers llvm.va_end and returns the resultant chain. If
/// not implemented, this defaults to a noop. /// not implemented, this defaults to a noop.
virtual SDOperand LowerVAEnd(SDOperand Chain, SDOperand L, SelectionDAG &DAG); virtual SDOperand LowerVAEnd(SDOperand Chain, SDOperand LP, Value *LV,
SelectionDAG &DAG);
/// LowerVACopy - This lowers llvm.va_copy and returns the resultant /// LowerVACopy - This lowers llvm.va_copy and returns the resultant chain.
/// value/chain pair. If not implemented, this defaults to returning the /// If not implemented, this defaults to loading a pointer from the input and
/// input operand. /// storing it to the output.
virtual std::pair<SDOperand,SDOperand> virtual SDOperand LowerVACopy(SDOperand Chain, SDOperand SrcP, Value *SrcV,
LowerVACopy(SDOperand Chain, SDOperand Src, SDOperand Dest, SelectionDAG &DAG); SDOperand DestP, Value *DestV,
SelectionDAG &DAG);
/// LowerVAArgNext - This lowers the instruction /// LowerVAArg - This lowers the vaarg instruction. If not implemented, this
/// If not implemented, this prints a message and aborts. /// prints a message and aborts.
virtual std::pair<SDOperand,SDOperand> virtual std::pair<SDOperand,SDOperand>
LowerVAArgNext(SDOperand Chain, SDOperand VAList, LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV,
const Type *ArgTy, SelectionDAG &DAG); const Type *ArgTy, SelectionDAG &DAG);
/// LowerFrameReturnAddress - This hook lowers a call to llvm.returnaddress or /// LowerFrameReturnAddress - This hook lowers a call to llvm.returnaddress or
/// llvm.frameaddress (depending on the value of the first argument). The /// llvm.frameaddress (depending on the value of the first argument). The

View File

@ -837,34 +837,37 @@ void SelectionDAGLowering::visitFree(FreeInst &I) {
DAG.setRoot(Result.second); DAG.setRoot(Result.second);
} }
std::pair<SDOperand, SDOperand> SDOperand TargetLowering::LowerVAStart(SDOperand Chain,
TargetLowering::LowerVAStart(SDOperand Chain, SelectionDAG &DAG, SDOperand Dest) { SDOperand VAListP, Value *VAListV,
SelectionDAG &DAG) {
// We have no sane default behavior, just emit a useful error message and bail // We have no sane default behavior, just emit a useful error message and bail
// out. // out.
std::cerr << "Variable arguments handling not implemented on this target!\n"; std::cerr << "Variable arguments handling not implemented on this target!\n";
abort(); abort();
return std::make_pair(SDOperand(), SDOperand()); return SDOperand();
} }
SDOperand TargetLowering::LowerVAEnd(SDOperand Chain, SDOperand L, SDOperand TargetLowering::LowerVAEnd(SDOperand Chain, SDOperand LP, Value *LV,
SelectionDAG &DAG) { SelectionDAG &DAG) {
// Default to a noop. // Default to a noop.
return Chain; return Chain;
} }
std::pair<SDOperand,SDOperand> SDOperand TargetLowering::LowerVACopy(SDOperand Chain,
TargetLowering::LowerVACopy(SDOperand Chain, SDOperand Src, SDOperand Dest, SDOperand SrcP, Value *SrcV,
SelectionDAG &DAG) { SDOperand DestP, Value *DestV,
//Default to returning the input list SelectionDAG &DAG) {
SDOperand Val = DAG.getLoad(getPointerTy(), Chain, Src, DAG.getSrcValue(NULL)); // Default to copying the input list.
SDOperand Val = DAG.getLoad(getPointerTy(), Chain,
SrcP, DAG.getSrcValue(SrcV));
SDOperand Result = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1), SDOperand Result = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1),
Val, Dest, DAG.getSrcValue(NULL)); Val, DestP, DAG.getSrcValue(DestV));
return std::make_pair(Result, Result); return Result;
} }
std::pair<SDOperand,SDOperand> std::pair<SDOperand,SDOperand>
TargetLowering::LowerVAArgNext(SDOperand Chain, SDOperand VAList, TargetLowering::LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV,
const Type *ArgTy, SelectionDAG &DAG) { const Type *ArgTy, SelectionDAG &DAG) {
// We have no sane default behavior, just emit a useful error message and bail // We have no sane default behavior, just emit a useful error message and bail
// out. // out.
std::cerr << "Variable arguments handling not implemented on this target!\n"; std::cerr << "Variable arguments handling not implemented on this target!\n";
@ -874,28 +877,28 @@ TargetLowering::LowerVAArgNext(SDOperand Chain, SDOperand VAList,
void SelectionDAGLowering::visitVAStart(CallInst &I) { void SelectionDAGLowering::visitVAStart(CallInst &I) {
std::pair<SDOperand,SDOperand> Result = TLI.LowerVAStart(getRoot(), DAG, getValue(I.getOperand(1))); DAG.setRoot(TLI.LowerVAStart(getRoot(), getValue(I.getOperand(1)),
setValue(&I, Result.first); I.getOperand(1), DAG));
DAG.setRoot(Result.second);
} }
void SelectionDAGLowering::visitVAArg(VAArgInst &I) { void SelectionDAGLowering::visitVAArg(VAArgInst &I) {
std::pair<SDOperand,SDOperand> Result = std::pair<SDOperand,SDOperand> Result =
TLI.LowerVAArgNext(getRoot(), getValue(I.getOperand(0)), TLI.LowerVAArg(getRoot(), getValue(I.getOperand(0)), I.getOperand(0),
I.getType(), DAG); I.getType(), DAG);
setValue(&I, Result.first); setValue(&I, Result.first);
DAG.setRoot(Result.second); DAG.setRoot(Result.second);
} }
void SelectionDAGLowering::visitVAEnd(CallInst &I) { void SelectionDAGLowering::visitVAEnd(CallInst &I) {
DAG.setRoot(TLI.LowerVAEnd(getRoot(), getValue(I.getOperand(1)), DAG)); DAG.setRoot(TLI.LowerVAEnd(getRoot(), getValue(I.getOperand(1)),
I.getOperand(1), DAG));
} }
void SelectionDAGLowering::visitVACopy(CallInst &I) { void SelectionDAGLowering::visitVACopy(CallInst &I) {
std::pair<SDOperand,SDOperand> Result = SDOperand Result =
TLI.LowerVACopy(getRoot(), getValue(I.getOperand(2)), getValue(I.getOperand(1)), DAG); TLI.LowerVACopy(getRoot(), getValue(I.getOperand(2)), I.getOperand(2),
setValue(&I, Result.first); getValue(I.getOperand(1)), I.getOperand(1), DAG);
DAG.setRoot(Result.second); DAG.setRoot(Result);
} }