[SelectionDAG][X86][PowerPC][Mips] Replace the default implementation of LowerOperationWrapper with the X86 and PowerPC version.
The default version only works if the returned node has a single result. The X86 and PowerPC versions support multiple results and allow a single result to be returned from a node with multiple outputs. And allow a single result that is not result 0 of the node. Also replace the Mips version since the new version should work for it. The original version handled multiple results, but only if the new node and original node had the same number of results. Differential Revision: https://reviews.llvm.org/D91846
This commit is contained in:
@@ -9401,11 +9401,33 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
|
||||
return std::make_pair(Res, CLI.Chain);
|
||||
}
|
||||
|
||||
/// Places new result values for the node in Results (their number
|
||||
/// and types must exactly match those of the original return values of
|
||||
/// the node), or leaves Results empty, which indicates that the node is not
|
||||
/// to be custom lowered after all.
|
||||
void TargetLowering::LowerOperationWrapper(SDNode *N,
|
||||
SmallVectorImpl<SDValue> &Results,
|
||||
SelectionDAG &DAG) const {
|
||||
if (SDValue Res = LowerOperation(SDValue(N, 0), DAG))
|
||||
SDValue Res = LowerOperation(SDValue(N, 0), DAG);
|
||||
|
||||
if (!Res.getNode())
|
||||
return;
|
||||
|
||||
// If the original node has one result, take the return value from
|
||||
// LowerOperation as is. It might not be result number 0.
|
||||
if (N->getNumValues() == 1) {
|
||||
Results.push_back(Res);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the original node has multiple results, then the return node should
|
||||
// have the same number of results.
|
||||
assert((N->getNumValues() == Res->getNumValues()) &&
|
||||
"Lowering returned the wrong number of results!");
|
||||
|
||||
// Places new result values base on N result number.
|
||||
for (unsigned I = 0, E = N->getNumValues(); I != E; ++I)
|
||||
Results.push_back(Res.getValue(I));
|
||||
}
|
||||
|
||||
SDValue TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
|
||||
|
||||
@@ -1197,17 +1197,6 @@ bool MipsTargetLowering::shouldFoldConstantShiftPairToMask(
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
MipsTargetLowering::LowerOperationWrapper(SDNode *N,
|
||||
SmallVectorImpl<SDValue> &Results,
|
||||
SelectionDAG &DAG) const {
|
||||
SDValue Res = LowerOperation(SDValue(N, 0), DAG);
|
||||
|
||||
if (Res)
|
||||
for (unsigned I = 0, E = Res->getNumValues(); I != E; ++I)
|
||||
Results.push_back(Res.getValue(I));
|
||||
}
|
||||
|
||||
void
|
||||
MipsTargetLowering::ReplaceNodeResults(SDNode *N,
|
||||
SmallVectorImpl<SDValue> &Results,
|
||||
|
||||
@@ -314,10 +314,6 @@ class TargetRegisterClass;
|
||||
return ISD::SIGN_EXTEND;
|
||||
}
|
||||
|
||||
void LowerOperationWrapper(SDNode *N,
|
||||
SmallVectorImpl<SDValue> &Results,
|
||||
SelectionDAG &DAG) const override;
|
||||
|
||||
/// LowerOperation - Provide custom lowering hooks for some operations.
|
||||
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
||||
|
||||
|
||||
@@ -11031,28 +11031,6 @@ SDValue PPCTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
|
||||
}
|
||||
}
|
||||
|
||||
void PPCTargetLowering::LowerOperationWrapper(SDNode *N,
|
||||
SmallVectorImpl<SDValue> &Results,
|
||||
SelectionDAG &DAG) const {
|
||||
SDValue Res = LowerOperation(SDValue(N, 0), DAG);
|
||||
|
||||
if (!Res.getNode())
|
||||
return;
|
||||
|
||||
// Take the return value as-is if original node has only one result.
|
||||
if (N->getNumValues() == 1) {
|
||||
Results.push_back(Res);
|
||||
return;
|
||||
}
|
||||
|
||||
// New node should have the same number of results.
|
||||
assert((N->getNumValues() == Res->getNumValues()) &&
|
||||
"Lowering returned the wrong number of results!");
|
||||
|
||||
for (unsigned i = 0; i < N->getNumValues(); ++i)
|
||||
Results.push_back(Res.getValue(i));
|
||||
}
|
||||
|
||||
void PPCTargetLowering::ReplaceNodeResults(SDNode *N,
|
||||
SmallVectorImpl<SDValue>&Results,
|
||||
SelectionDAG &DAG) const {
|
||||
|
||||
@@ -788,12 +788,6 @@ namespace llvm {
|
||||
///
|
||||
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
||||
|
||||
/// LowerOperationWrapper - Place custom new result values for node in
|
||||
/// Results.
|
||||
void LowerOperationWrapper(SDNode *N,
|
||||
SmallVectorImpl<SDValue> &Results,
|
||||
SelectionDAG &DAG) const override;
|
||||
|
||||
/// ReplaceNodeResults - Replace the results of node with an illegal result
|
||||
/// type with new values built out of custom code.
|
||||
///
|
||||
|
||||
@@ -29840,35 +29840,6 @@ SDValue X86TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
|
||||
}
|
||||
}
|
||||
|
||||
/// Places new result values for the node in Results (their number
|
||||
/// and types must exactly match those of the original return values of
|
||||
/// the node), or leaves Results empty, which indicates that the node is not
|
||||
/// to be custom lowered after all.
|
||||
void X86TargetLowering::LowerOperationWrapper(SDNode *N,
|
||||
SmallVectorImpl<SDValue> &Results,
|
||||
SelectionDAG &DAG) const {
|
||||
SDValue Res = LowerOperation(SDValue(N, 0), DAG);
|
||||
|
||||
if (!Res.getNode())
|
||||
return;
|
||||
|
||||
// If the original node has one result, take the return value from
|
||||
// LowerOperation as is. It might not be result number 0.
|
||||
if (N->getNumValues() == 1) {
|
||||
Results.push_back(Res);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the original node has multiple results, then the return node should
|
||||
// have the same number of results.
|
||||
assert((N->getNumValues() == Res->getNumValues()) &&
|
||||
"Lowering returned the wrong number of results!");
|
||||
|
||||
// Places new result values base on N result number.
|
||||
for (unsigned I = 0, E = N->getNumValues(); I != E; ++I)
|
||||
Results.push_back(Res.getValue(I));
|
||||
}
|
||||
|
||||
/// Replace a node with an illegal result type with a new node built out of
|
||||
/// custom code.
|
||||
void X86TargetLowering::ReplaceNodeResults(SDNode *N,
|
||||
|
||||
@@ -925,14 +925,6 @@ namespace llvm {
|
||||
///
|
||||
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
||||
|
||||
/// Places new result values for the node in Results (their number
|
||||
/// and types must exactly match those of the original return values of
|
||||
/// the node), or leaves Results empty, which indicates that the node is not
|
||||
/// to be custom lowered after all.
|
||||
void LowerOperationWrapper(SDNode *N,
|
||||
SmallVectorImpl<SDValue> &Results,
|
||||
SelectionDAG &DAG) const override;
|
||||
|
||||
/// Replace the results of node with an illegal result
|
||||
/// type with new values built out of custom code.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user