From e64e72b794cfa385372436b3c88460aeee0acbf6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 5 Jul 2005 19:57:53 +0000 Subject: [PATCH] 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 --- include/llvm/Target/TargetLowering.h | 31 +++++++----- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 47 ++++++++++--------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index b1ef3f1545b..d30d6c73747 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -26,6 +26,7 @@ #include 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 - 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 - 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 - 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 diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index fa6d6d4d14c..05d84609a0f 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -837,34 +837,37 @@ void SelectionDAGLowering::visitFree(FreeInst &I) { DAG.setRoot(Result.second); } -std::pair -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 -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 -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 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 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 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); }