diff options
author | Craig Topper <craig.topper@intel.com> | 2019-11-25 10:48:28 -0800 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2019-11-25 10:52:49 -0800 |
commit | d6ec6e4bf6d87f35d83fccc631c5cf7a00ef1af5 (patch) | |
tree | d10134c16eb08b60f37dec5d47e3e9696dc685cc /llvm/lib | |
parent | 35827164c45ed11c279301a98df96dfa2747d8f7 (diff) | |
download | bcm5719-llvm-d6ec6e4bf6d87f35d83fccc631c5cf7a00ef1af5.tar.gz bcm5719-llvm-d6ec6e4bf6d87f35d83fccc631c5cf7a00ef1af5.zip |
[TargetLowering] Merge ExpandChainLibCall with makeLibCall
I need to be able to drop an operand for STRICT_FP_ROUND handling on X86. Merging these functions gives me the ArrayRef interface that passes the return type, operands, and debugloc instead of the Node.
Differential Revision: https://reviews.llvm.org/D70503
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 27 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 23 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 42 |
3 files changed, 40 insertions, 52 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index c3db6609f9d..17bb98bdddf 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -2098,9 +2098,14 @@ void SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node, } if (Node->isStrictFPOpcode()) { + EVT RetVT = Node->getValueType(0); + SmallVector<SDValue, 4> Ops(Node->op_begin() + 1, Node->op_end()); + TargetLowering::MakeLibCallOptions CallOptions; // FIXME: This doesn't support tail calls. - std::pair<SDValue, SDValue> Tmp = TLI.ExpandChainLibCall(DAG, LC, Node, - false); + std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT, + Ops, CallOptions, + SDLoc(Node), + Node->getOperand(0)); Results.push_back(Tmp.first); Results.push_back(Tmp.second); } else { @@ -2149,9 +2154,14 @@ void SelectionDAGLegalize::ExpandArgFPLibCall(SDNode* Node, } if (Node->isStrictFPOpcode()) { + EVT RetVT = Node->getValueType(0); + SmallVector<SDValue, 4> Ops(Node->op_begin() + 1, Node->op_end()); + TargetLowering::MakeLibCallOptions CallOptions; // FIXME: This doesn't support tail calls. - std::pair<SDValue, SDValue> Tmp = TLI.ExpandChainLibCall(DAG, LC, Node, - false); + std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT, + Ops, CallOptions, + SDLoc(Node), + Node->getOperand(0)); Results.push_back(Tmp.first); Results.push_back(Tmp.second); } else { @@ -3798,8 +3808,13 @@ void SelectionDAGLegalize::ConvertNodeToLibcall(SDNode *Node) { RTLIB::Libcall LC = RTLIB::getSYNC(Opc, VT); assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unexpected atomic op or value type!"); - std::pair<SDValue, SDValue> Tmp = TLI.ExpandChainLibCall(DAG, LC, Node, - false); + EVT RetVT = Node->getValueType(0); + SmallVector<SDValue, 4> Ops(Node->op_begin() + 1, Node->op_end()); + TargetLowering::MakeLibCallOptions CallOptions; + std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT, + Ops, CallOptions, + SDLoc(Node), + Node->getOperand(0)); Results.push_back(Tmp.first); Results.push_back(Tmp.second); break; diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index 2a6ec864118..56c13bb0753 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -1818,7 +1818,11 @@ std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(SDNode *Node) { RTLIB::Libcall LC = RTLIB::getSYNC(Opc, VT); assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unexpected atomic op or value type!"); - return TLI.ExpandChainLibCall(DAG, LC, Node, false); + EVT RetVT = Node->getValueType(0); + SmallVector<SDValue, 4> Ops(Node->op_begin() + 1, Node->op_end()); + TargetLowering::MakeLibCallOptions CallOptions; + return TLI.makeLibCall(DAG, LC, RetVT, Ops, CallOptions, SDLoc(Node), + Node->getOperand(0)); } /// N is a shift by a value that needs to be expanded, @@ -2627,18 +2631,17 @@ void DAGTypeLegalizer::ExpandIntRes_LLROUND_LLRINT(SDNode *N, SDValue &Lo, SDLoc dl(N); EVT RetVT = N->getValueType(0); - - if (N->isStrictFPOpcode()) { - std::pair<SDValue, SDValue> Tmp = TLI.ExpandChainLibCall(DAG, LC, N, true); - SplitInteger(Tmp.first, Lo, Hi); - ReplaceValueWith(SDValue(N, 1), Tmp.second); - return; - } + SDValue Chain = N->isStrictFPOpcode() ? N->getOperand(0) : SDValue(); TargetLowering::MakeLibCallOptions CallOptions; CallOptions.setSExt(true); - SplitInteger(TLI.makeLibCall(DAG, LC, RetVT, Op, CallOptions, dl).first, - Lo, Hi); + std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, RetVT, + Op, CallOptions, dl, + Chain); + SplitInteger(Tmp.first, Lo, Hi); + + if (N->isStrictFPOpcode()) + ReplaceValueWith(SDValue(N, 1), Tmp.second); } void DAGTypeLegalizer::ExpandIntRes_LOAD(LoadSDNode *N, diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 6f563c2a0ee..c24a3670c98 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -122,7 +122,11 @@ std::pair<SDValue, SDValue> TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, ArrayRef<SDValue> Ops, MakeLibCallOptions CallOptions, - const SDLoc &dl) const { + const SDLoc &dl, + SDValue InChain) const { + if (!InChain) + InChain = DAG.getEntryNode(); + TargetLowering::ArgListTy Args; Args.reserve(Ops.size()); @@ -158,7 +162,7 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, } CLI.setDebugLoc(dl) - .setChain(DAG.getEntryNode()) + .setChain(InChain) .setLibCallee(getLibcallCallingConv(LC), RetTy, Callee, std::move(Args)) .setNoReturn(CallOptions.DoesNotReturn) .setDiscardResult(!CallOptions.IsReturnValueUsed) @@ -168,40 +172,6 @@ TargetLowering::makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, return LowerCallTo(CLI); } -/// Expand a node into a call to a libcall. Similar to ExpandLibCall except that -/// the first operand is the in-chain. -std::pair<SDValue, SDValue> -TargetLowering::ExpandChainLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, - SDNode *Node, bool isSigned) const { - SDValue InChain = Node->getOperand(0); - - TargetLowering::ArgListTy Args; - TargetLowering::ArgListEntry Entry; - for (unsigned i = 1, e = Node->getNumOperands(); i != e; ++i) { - EVT ArgVT = Node->getOperand(i).getValueType(); - Type *ArgTy = ArgVT.getTypeForEVT(*DAG.getContext()); - Entry.Node = Node->getOperand(i); - Entry.Ty = ArgTy; - Entry.IsSExt = isSigned; - Entry.IsZExt = !isSigned; - Args.push_back(Entry); - } - SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC), - getPointerTy(DAG.getDataLayout())); - - Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext()); - - TargetLowering::CallLoweringInfo CLI(DAG); - CLI.setDebugLoc(SDLoc(Node)) - .setChain(InChain) - .setLibCallee(getLibcallCallingConv(LC), RetTy, Callee, - std::move(Args)) - .setSExtResult(isSigned) - .setZExtResult(!isSigned); - - return LowerCallTo(CLI); -} - bool TargetLowering::findOptimalMemOpLowering(std::vector<EVT> &MemOps, unsigned Limit, uint64_t Size, |