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>
namespace llvm {
class Value;
class Function;
class TargetMachine;
class TargetData;
@ -266,25 +267,29 @@ public:
ArgListTy &Args, SelectionDAG &DAG) = 0;
/// LowerVAStart - This lowers the llvm.va_start intrinsic. If not
/// implemented, this method prints a message and aborts.
virtual std::pair<SDOperand, SDOperand>
LowerVAStart(SDOperand Chain, SelectionDAG &DAG, SDOperand Dest);
/// implemented, this method prints a message and aborts. This method should
/// return the modified chain value. Note that VAListPtr* correspond to the
/// 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
/// 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
/// value/chain pair. If not implemented, this defaults to returning the
/// input operand.
virtual std::pair<SDOperand,SDOperand>
LowerVACopy(SDOperand Chain, SDOperand Src, SDOperand Dest, SelectionDAG &DAG);
/// LowerVACopy - This lowers llvm.va_copy and returns the resultant chain.
/// If not implemented, this defaults to loading a pointer from the input and
/// storing it to the output.
virtual SDOperand LowerVACopy(SDOperand Chain, SDOperand SrcP, Value *SrcV,
SDOperand DestP, Value *DestV,
SelectionDAG &DAG);
/// LowerVAArgNext - This lowers the instruction
/// If not implemented, this prints a message and aborts.
/// LowerVAArg - This lowers the vaarg instruction. If not implemented, this
/// prints a message and aborts.
virtual std::pair<SDOperand,SDOperand>
LowerVAArgNext(SDOperand Chain, SDOperand VAList,
const Type *ArgTy, SelectionDAG &DAG);
LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV,
const Type *ArgTy, SelectionDAG &DAG);
/// LowerFrameReturnAddress - This hook lowers a call to llvm.returnaddress or
/// 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);
}
std::pair<SDOperand, SDOperand>
TargetLowering::LowerVAStart(SDOperand Chain, SelectionDAG &DAG, SDOperand Dest) {
SDOperand TargetLowering::LowerVAStart(SDOperand Chain,
SDOperand VAListP, Value *VAListV,
SelectionDAG &DAG) {
// We have no sane default behavior, just emit a useful error message and bail
// out.
std::cerr << "Variable arguments handling not implemented on this target!\n";
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) {
// Default to a noop.
return Chain;
}
std::pair<SDOperand,SDOperand>
TargetLowering::LowerVACopy(SDOperand Chain, SDOperand Src, SDOperand Dest,
SelectionDAG &DAG) {
//Default to returning the input list
SDOperand Val = DAG.getLoad(getPointerTy(), Chain, Src, DAG.getSrcValue(NULL));
SDOperand TargetLowering::LowerVACopy(SDOperand Chain,
SDOperand SrcP, Value *SrcV,
SDOperand DestP, Value *DestV,
SelectionDAG &DAG) {
// 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),
Val, Dest, DAG.getSrcValue(NULL));
return std::make_pair(Result, Result);
Val, DestP, DAG.getSrcValue(DestV));
return Result;
}
std::pair<SDOperand,SDOperand>
TargetLowering::LowerVAArgNext(SDOperand Chain, SDOperand VAList,
const Type *ArgTy, SelectionDAG &DAG) {
TargetLowering::LowerVAArg(SDOperand Chain, SDOperand VAListP, Value *VAListV,
const Type *ArgTy, SelectionDAG &DAG) {
// We have no sane default behavior, just emit a useful error message and bail
// out.
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) {
std::pair<SDOperand,SDOperand> Result = TLI.LowerVAStart(getRoot(), DAG, getValue(I.getOperand(1)));
setValue(&I, Result.first);
DAG.setRoot(Result.second);
DAG.setRoot(TLI.LowerVAStart(getRoot(), getValue(I.getOperand(1)),
I.getOperand(1), DAG));
}
void SelectionDAGLowering::visitVAArg(VAArgInst &I) {
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);
setValue(&I, Result.first);
DAG.setRoot(Result.second);
}
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) {
std::pair<SDOperand,SDOperand> Result =
TLI.LowerVACopy(getRoot(), getValue(I.getOperand(2)), getValue(I.getOperand(1)), DAG);
setValue(&I, Result.first);
DAG.setRoot(Result.second);
SDOperand Result =
TLI.LowerVACopy(getRoot(), getValue(I.getOperand(2)), I.getOperand(2),
getValue(I.getOperand(1)), I.getOperand(1), DAG);
DAG.setRoot(Result);
}