diff options
author | Duncan Sands <baldrick@free.fr> | 2008-04-14 06:48:48 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2008-04-14 06:48:48 +0000 |
commit | ddc016cc8592fe5c9379feb42a1fb4fb63164a91 (patch) | |
tree | f1bed018d7e455f6921a374fb1a240095de80b7b /lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | |
parent | 75caee241955fdcd9942c42be8b77ba9996e94d6 (diff) |
Initial libcall support for LegalizeTypes. This is
much simpler than in LegalizeDAG because calls are
not yet expanded into call sequences: that happens
after type legalization has finished.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49634 91177308-0d34-0410-b5e6-96231b3b80d8
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 //===----------------------------------------------------------------------===// |