diff options
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeTypes.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp index 34f99da49f..c26656a867 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "LegalizeTypes.h" +#include "llvm/CallingConv.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Support/CommandLine.h" @@ -524,6 +525,29 @@ void DAGTypeLegalizer::SplitInteger(SDOperand Op, SplitInteger(Op, HalfVT, HalfVT, Lo, Hi); } +/// MakeLibCall - Expand a node into a libcall and return the result. +SDOperand DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, SDNode *N, + bool isSigned) { + TargetLowering::ArgListTy Args; + TargetLowering::ArgListEntry Entry; + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { + MVT::ValueType ArgVT = N->getOperand(i).getValueType(); + Entry.Node = N->getOperand(i); + Entry.Ty = MVT::getTypeForValueType(ArgVT); + Entry.isSExt = isSigned; + Entry.isZExt = !isSigned; + Args.push_back(Entry); + } + SDOperand Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC), + TLI.getPointerTy()); + + const Type *RetTy = MVT::getTypeForValueType(N->getValueType(0)); + std::pair<SDOperand,SDOperand> CallInfo = + TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false, + CallingConv::C, false, Callee, Args, DAG); + return CallInfo.first; +} + //===----------------------------------------------------------------------===// // Entry Point //===----------------------------------------------------------------------===// |