mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[SelectionDAG] Merge the two identical ExpandChainLibCall methods from LegalizeTypes and LegalizeDAG to one version in TaretLowering.
Reviewers: RKSimon, efriedma, spatel Reviewed By: efriedma Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70354
This commit is contained in:
parent
bd40a3935c
commit
36e4819159
@ -3031,6 +3031,11 @@ public:
|
||||
MakeLibCallOptions CallOptions,
|
||||
const SDLoc &dl) const;
|
||||
|
||||
std::pair<SDValue, SDValue> ExpandChainLibCall(SelectionDAG &DAG,
|
||||
RTLIB::Libcall LC,
|
||||
SDNode *Node,
|
||||
bool isSigned) const;
|
||||
|
||||
/// Check whether parameters to a call that are passed in callee saved
|
||||
/// registers are the same as from the calling function. This needs to be
|
||||
/// checked for tail call eligibility.
|
||||
|
@ -138,8 +138,6 @@ private:
|
||||
|
||||
SDValue ExpandLibCall(RTLIB::Libcall LC, SDNode *Node, bool isSigned);
|
||||
|
||||
std::pair<SDValue, SDValue> ExpandChainLibCall(RTLIB::Libcall LC,
|
||||
SDNode *Node, bool isSigned);
|
||||
void ExpandFPLibCall(SDNode *Node, RTLIB::Libcall Call_F32,
|
||||
RTLIB::Libcall Call_F64, RTLIB::Libcall Call_F80,
|
||||
RTLIB::Libcall Call_F128,
|
||||
@ -2082,43 +2080,6 @@ SDValue SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
|
||||
return CallInfo.first;
|
||||
}
|
||||
|
||||
// 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>
|
||||
SelectionDAGLegalize::ExpandChainLibCall(RTLIB::Libcall LC,
|
||||
SDNode *Node,
|
||||
bool isSigned) {
|
||||
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(TLI.getLibcallName(LC),
|
||||
TLI.getPointerTy(DAG.getDataLayout()));
|
||||
|
||||
Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
|
||||
|
||||
TargetLowering::CallLoweringInfo CLI(DAG);
|
||||
CLI.setDebugLoc(SDLoc(Node))
|
||||
.setChain(InChain)
|
||||
.setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
|
||||
std::move(Args))
|
||||
.setSExtResult(isSigned)
|
||||
.setZExtResult(!isSigned);
|
||||
|
||||
std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
|
||||
|
||||
return CallInfo;
|
||||
}
|
||||
|
||||
void SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node,
|
||||
RTLIB::Libcall Call_F32,
|
||||
RTLIB::Libcall Call_F64,
|
||||
@ -2138,7 +2099,8 @@ void SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node,
|
||||
|
||||
if (Node->isStrictFPOpcode()) {
|
||||
// FIXME: This doesn't support tail calls.
|
||||
std::pair<SDValue, SDValue> Tmp = ExpandChainLibCall(LC, Node, false);
|
||||
std::pair<SDValue, SDValue> Tmp = TLI.ExpandChainLibCall(DAG, LC, Node,
|
||||
false);
|
||||
Results.push_back(Tmp.first);
|
||||
Results.push_back(Tmp.second);
|
||||
} else {
|
||||
@ -2188,7 +2150,8 @@ void SelectionDAGLegalize::ExpandArgFPLibCall(SDNode* Node,
|
||||
|
||||
if (Node->isStrictFPOpcode()) {
|
||||
// FIXME: This doesn't support tail calls.
|
||||
std::pair<SDValue, SDValue> Tmp = ExpandChainLibCall(LC, Node, false);
|
||||
std::pair<SDValue, SDValue> Tmp = TLI.ExpandChainLibCall(DAG, LC, Node,
|
||||
false);
|
||||
Results.push_back(Tmp.first);
|
||||
Results.push_back(Tmp.second);
|
||||
} else {
|
||||
@ -3813,7 +3776,8 @@ 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 = ExpandChainLibCall(LC, Node, false);
|
||||
std::pair<SDValue, SDValue> Tmp = TLI.ExpandChainLibCall(DAG, LC, Node,
|
||||
false);
|
||||
Results.push_back(Tmp.first);
|
||||
Results.push_back(Tmp.second);
|
||||
break;
|
||||
|
@ -1818,7 +1818,7 @@ 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 ExpandChainLibCall(LC, Node, false);
|
||||
return TLI.ExpandChainLibCall(DAG, LC, Node, false);
|
||||
}
|
||||
|
||||
/// N is a shift by a value that needs to be expanded,
|
||||
@ -2629,7 +2629,7 @@ void DAGTypeLegalizer::ExpandIntRes_LLROUND_LLRINT(SDNode *N, SDValue &Lo,
|
||||
EVT RetVT = N->getValueType(0);
|
||||
|
||||
if (N->isStrictFPOpcode()) {
|
||||
std::pair<SDValue, SDValue> Tmp = ExpandChainLibCall(LC, N, true);
|
||||
std::pair<SDValue, SDValue> Tmp = TLI.ExpandChainLibCall(DAG, LC, N, true);
|
||||
SplitInteger(Tmp.first, Lo, Hi);
|
||||
ReplaceValueWith(SDValue(N, 1), Tmp.second);
|
||||
return;
|
||||
|
@ -1000,42 +1000,6 @@ SDValue DAGTypeLegalizer::LibCallify(RTLIB::Libcall LC, SDNode *N,
|
||||
return TLI.makeLibCall(DAG, LC, N->getValueType(0), Ops, CallOptions, dl).first;
|
||||
}
|
||||
|
||||
/// 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>
|
||||
DAGTypeLegalizer::ExpandChainLibCall(RTLIB::Libcall LC, SDNode *Node,
|
||||
bool isSigned) {
|
||||
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(TLI.getLibcallName(LC),
|
||||
TLI.getPointerTy(DAG.getDataLayout()));
|
||||
|
||||
Type *RetTy = Node->getValueType(0).getTypeForEVT(*DAG.getContext());
|
||||
|
||||
TargetLowering::CallLoweringInfo CLI(DAG);
|
||||
CLI.setDebugLoc(SDLoc(Node))
|
||||
.setChain(InChain)
|
||||
.setLibCallee(TLI.getLibcallCallingConv(LC), RetTy, Callee,
|
||||
std::move(Args))
|
||||
.setSExtResult(isSigned)
|
||||
.setZExtResult(!isSigned);
|
||||
|
||||
std::pair<SDValue, SDValue> CallInfo = TLI.LowerCallTo(CLI);
|
||||
|
||||
return CallInfo;
|
||||
}
|
||||
|
||||
/// Promote the given target boolean to a target boolean of the given type.
|
||||
/// A target boolean is an integer value, not necessarily of type i1, the bits
|
||||
/// of which conform to getBooleanContents.
|
||||
|
@ -217,8 +217,6 @@ private:
|
||||
SDValue JoinIntegers(SDValue Lo, SDValue Hi);
|
||||
SDValue LibCallify(RTLIB::Libcall LC, SDNode *N, bool isSigned);
|
||||
|
||||
std::pair<SDValue, SDValue> ExpandChainLibCall(RTLIB::Libcall LC,
|
||||
SDNode *Node, bool isSigned);
|
||||
std::pair<SDValue, SDValue> ExpandAtomic(SDNode *Node);
|
||||
|
||||
SDValue PromoteTargetBoolean(SDValue Bool, EVT ValVT);
|
||||
|
@ -168,6 +168,40 @@ 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,
|
||||
|
Loading…
Reference in New Issue
Block a user