Skip to content

Commit

Permalink
Convert SelectionDAG::getNode methods to use ArrayRef<SDValue>.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207327 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
topperc committed Apr 26, 2014
1 parent 57d7597 commit 80d8db7
Show file tree
Hide file tree
Showing 32 changed files with 451 additions and 606 deletions.
25 changes: 14 additions & 11 deletions include/llvm/CodeGen/SelectionDAG.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,21 +496,23 @@ class SelectionDAG {
SDValue Glue) {
SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue };
return getNode(ISD::CopyToReg, dl, VTs, Ops, Glue.getNode() ? 4 : 3);
return getNode(ISD::CopyToReg, dl, VTs,
ArrayRef<SDValue>(Ops, Glue.getNode() ? 4 : 3));
}

// Similar to last getCopyToReg() except parameter Reg is a SDValue
SDValue getCopyToReg(SDValue Chain, SDLoc dl, SDValue Reg, SDValue N,
SDValue Glue) {
SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
SDValue Ops[] = { Chain, Reg, N, Glue };
return getNode(ISD::CopyToReg, dl, VTs, Ops, Glue.getNode() ? 4 : 3);
return getNode(ISD::CopyToReg, dl, VTs,
ArrayRef<SDValue>(Ops, Glue.getNode() ? 4 : 3));
}

SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT) {
SDVTList VTs = getVTList(VT, MVT::Other);
SDValue Ops[] = { Chain, getRegister(Reg, VT) };
return getNode(ISD::CopyFromReg, dl, VTs, Ops, 2);
return getNode(ISD::CopyFromReg, dl, VTs, Ops);
}

// This version of the getCopyFromReg method takes an extra operand, which
Expand All @@ -520,7 +522,8 @@ class SelectionDAG {
SDValue Glue) {
SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue);
SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue };
return getNode(ISD::CopyFromReg, dl, VTs, Ops, Glue.getNode() ? 3 : 2);
return getNode(ISD::CopyFromReg, dl, VTs,
ArrayRef<SDValue>(Ops, Glue.getNode() ? 3 : 2));
}

SDValue getCondCode(ISD::CondCode Cond);
Expand Down Expand Up @@ -563,7 +566,7 @@ class SelectionDAG {
SDValue getCALLSEQ_START(SDValue Chain, SDValue Op, SDLoc DL) {
SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
SDValue Ops[] = { Chain, Op };
return getNode(ISD::CALLSEQ_START, DL, VTs, Ops, 2);
return getNode(ISD::CALLSEQ_START, DL, VTs, Ops);
}

/// getCALLSEQ_END - Return a new CALLSEQ_END node, which always must have a
Expand All @@ -576,9 +579,9 @@ class SelectionDAG {
Ops.push_back(Chain);
Ops.push_back(Op1);
Ops.push_back(Op2);
Ops.push_back(InGlue);
return getNode(ISD::CALLSEQ_END, DL, NodeTys, &Ops[0],
(unsigned)Ops.size() - (InGlue.getNode()==nullptr ? 1 : 0));
if (InGlue.getNode())
Ops.push_back(InGlue);
return getNode(ISD::CALLSEQ_END, DL, NodeTys, Ops);
}

/// getUNDEF - Return an UNDEF node. UNDEF does not have a useful SDLoc.
Expand Down Expand Up @@ -607,12 +610,12 @@ class SelectionDAG {
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT,
const SDUse *Ops, unsigned NumOps);
SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT,
const SDValue *Ops, unsigned NumOps);
ArrayRef<SDValue> Ops);
SDValue getNode(unsigned Opcode, SDLoc DL,
ArrayRef<EVT> ResultTys,
const SDValue *Ops, unsigned NumOps);
ArrayRef<SDValue> Ops);
SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs,
const SDValue *Ops, unsigned NumOps);
ArrayRef<SDValue> Ops);
SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs);
SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs, SDValue N);
SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs,
Expand Down
64 changes: 24 additions & 40 deletions lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1402,8 +1402,7 @@ SDValue DAGCombiner::visitTokenFactor(SDNode *N) {
Result = DAG.getEntryNode();
} else {
// New and improved token factor.
Result = DAG.getNode(ISD::TokenFactor, SDLoc(N),
MVT::Other, &Ops[0], Ops.size());
Result = DAG.getNode(ISD::TokenFactor, SDLoc(N), MVT::Other, Ops);
}

// Don't add users to work list.
Expand Down Expand Up @@ -4762,7 +4761,7 @@ static SDNode *tryToFoldExtendOfConstant(SDNode *N, const TargetLowering &TLI,
SVT));
}

return DAG.getNode(ISD::BUILD_VECTOR, DL, VT, &Elts[0], NumElts).getNode();
return DAG.getNode(ISD::BUILD_VECTOR, DL, VT, Elts).getNode();
}

// ExtendUsesToFormExtLoad - Trying to extend uses of a load to enable this:
Expand Down Expand Up @@ -4846,8 +4845,7 @@ void DAGCombiner::ExtendSetCCUses(const SmallVectorImpl<SDNode *> &SetCCs,
}

Ops.push_back(SetCC->getOperand(2));
CombineTo(SetCC, DAG.getNode(ISD::SETCC, DL, SetCC->getValueType(0),
&Ops[0], Ops.size()));
CombineTo(SetCC, DAG.getNode(ISD::SETCC, DL, SetCC->getValueType(0), Ops));
}
}

Expand Down Expand Up @@ -5319,7 +5317,7 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
N0.getOperand(1),
cast<CondCodeSDNode>(N0.getOperand(2))->get()),
DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT,
&OneOps[0], OneOps.size()));
OneOps));

// If the desired elements are smaller or larger than the source
// elements we can use a matching integer vector type and then
Expand All @@ -5336,8 +5334,7 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
cast<CondCodeSDNode>(N0.getOperand(2))->get());
return DAG.getNode(ISD::AND, SDLoc(N), VT,
DAG.getSExtOrTrunc(VsetCC, SDLoc(N), VT),
DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT,
&OneOps[0], OneOps.size()));
DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT, OneOps));
}

// zext(setcc x,y,cc) -> select_cc x, y, 1, 0, cc
Expand Down Expand Up @@ -5865,7 +5862,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
Op.getValueType()));
}

return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT, &Elts[0], NumElts);
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT, Elts);
}

return SDValue();
Expand Down Expand Up @@ -5966,8 +5963,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
for (unsigned i = 0, e = BuildVecNumElts; i != e; i += TruncEltOffset)
Opnds.push_back(BuildVect.getOperand(i));

return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT, &Opnds[0],
Opnds.size());
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT, Opnds);
}
}

Expand Down Expand Up @@ -6042,8 +6038,7 @@ SDValue DAGCombiner::visitTRUNCATE(SDNode *N) {
AddToWorkList(NV.getNode());
Opnds.push_back(NV);
}
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), VT,
&Opnds[0], Opnds.size());
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), VT, Opnds);
}
}

Expand Down Expand Up @@ -6281,8 +6276,7 @@ ConstantFoldBITCASTofBUILD_VECTOR(SDNode *BV, EVT DstEltVT) {
DstEltVT, Op));
AddToWorkList(Ops.back().getNode());
}
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(BV), VT,
&Ops[0], Ops.size());
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(BV), VT, Ops);
}

// Otherwise, we're growing or shrinking the elements. To avoid having to
Expand Down Expand Up @@ -6338,8 +6332,7 @@ ConstantFoldBITCASTofBUILD_VECTOR(SDNode *BV, EVT DstEltVT) {
}

EVT VT = EVT::getVectorVT(*DAG.getContext(), DstEltVT, Ops.size());
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(BV), VT,
&Ops[0], Ops.size());
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(BV), VT, Ops);
}

// Finally, this must be the case where we are shrinking elements: each input
Expand Down Expand Up @@ -6375,8 +6368,7 @@ ConstantFoldBITCASTofBUILD_VECTOR(SDNode *BV, EVT DstEltVT) {
std::reverse(Ops.end()-NumOutputsPerInput, Ops.end());
}

return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(BV), VT,
&Ops[0], Ops.size());
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(BV), VT, Ops);
}

SDValue DAGCombiner::visitFADD(SDNode *N) {
Expand Down Expand Up @@ -6974,7 +6966,7 @@ SDValue DAGCombiner::visitSINT_TO_FP(SDNode *N) {
{ N0.getOperand(0), N0.getOperand(1),
DAG.getConstantFP(-1.0, VT) , DAG.getConstantFP(0.0, VT),
N0.getOperand(2) };
return DAG.getNode(ISD::SELECT_CC, SDLoc(N), VT, Ops, 5);
return DAG.getNode(ISD::SELECT_CC, SDLoc(N), VT, Ops);
}

// fold (sint_to_fp (zext (setcc x, y, cc))) ->
Expand All @@ -6987,7 +6979,7 @@ SDValue DAGCombiner::visitSINT_TO_FP(SDNode *N) {
{ N0.getOperand(0).getOperand(0), N0.getOperand(0).getOperand(1),
DAG.getConstantFP(1.0, VT) , DAG.getConstantFP(0.0, VT),
N0.getOperand(0).getOperand(2) };
return DAG.getNode(ISD::SELECT_CC, SDLoc(N), VT, Ops, 5);
return DAG.getNode(ISD::SELECT_CC, SDLoc(N), VT, Ops);
}
}

Expand Down Expand Up @@ -7031,7 +7023,7 @@ SDValue DAGCombiner::visitUINT_TO_FP(SDNode *N) {
{ N0.getOperand(0), N0.getOperand(1),
DAG.getConstantFP(1.0, VT), DAG.getConstantFP(0.0, VT),
N0.getOperand(2) };
return DAG.getNode(ISD::SELECT_CC, SDLoc(N), VT, Ops, 5);
return DAG.getNode(ISD::SELECT_CC, SDLoc(N), VT, Ops);
}
}

Expand Down Expand Up @@ -8523,7 +8515,7 @@ bool DAGCombiner::SliceUpLoad(SDNode *N) {
}

SDValue Chain = DAG.getNode(ISD::TokenFactor, SDLoc(LD), MVT::Other,
&ArgChains[0], ArgChains.size());
ArgChains);
DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1), Chain);
return true;
}
Expand Down Expand Up @@ -9677,8 +9669,7 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) {
}

// Return the new vector
return DAG.getNode(ISD::BUILD_VECTOR, dl,
VT, &Ops[0], Ops.size());
return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, Ops);
}

SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
Expand Down Expand Up @@ -10010,7 +10001,7 @@ SDValue DAGCombiner::reduceBuildVecExtToExtBuildVec(SDNode *N) {
if (!isTypeLegal(VecVT)) return SDValue();

// Make the new BUILD_VECTOR.
SDValue BV = DAG.getNode(ISD::BUILD_VECTOR, dl, VecVT, &Ops[0], Ops.size());
SDValue BV = DAG.getNode(ISD::BUILD_VECTOR, dl, VecVT, Ops);

// The new BUILD_VECTOR node has the potential to be further optimized.
AddToWorkList(BV.getNode());
Expand Down Expand Up @@ -10078,8 +10069,7 @@ SDValue DAGCombiner::reduceBuildVecConvertToConvertBuildVec(SDNode *N) {
else
Opnds.push_back(In.getOperand(0));
}
SDValue BV = DAG.getNode(ISD::BUILD_VECTOR, dl, NVT,
&Opnds[0], Opnds.size());
SDValue BV = DAG.getNode(ISD::BUILD_VECTOR, dl, NVT, Opnds);
AddToWorkList(BV.getNode());

return DAG.getNode(Opcode, dl, VT, BV);
Expand Down Expand Up @@ -10269,8 +10259,7 @@ SDValue DAGCombiner::visitCONCAT_VECTORS(SDNode *N) {
for (unsigned i = 0; i != BuildVecNumElts; ++i)
Opnds.push_back(N1.getOperand(i));

return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT, &Opnds[0],
Opnds.size());
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), VT, Opnds);
}

// Type legalization of vectors and DAG canonicalization of SHUFFLE_VECTOR
Expand Down Expand Up @@ -10427,8 +10416,7 @@ static SDValue partitionShuffleOfConcats(SDNode *N, SelectionDAG &DAG) {
}
}

return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), VT, Ops.data(),
Ops.size());
return DAG.getNode(ISD::CONCAT_VECTORS, SDLoc(N), VT, Ops);
}

SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) {
Expand Down Expand Up @@ -10643,8 +10631,7 @@ SDValue DAGCombiner::XformToShuffleWithZero(SDNode *N) {
EVT EltVT = RVT.getVectorElementType();
SmallVector<SDValue,8> ZeroOps(RVT.getVectorNumElements(),
DAG.getConstant(0, EltVT));
SDValue Zero = DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N),
RVT, &ZeroOps[0], ZeroOps.size());
SDValue Zero = DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), RVT, ZeroOps);
LHS = DAG.getNode(ISD::BITCAST, dl, RVT, LHS);
SDValue Shuf = DAG.getVectorShuffle(RVT, dl, LHS, Zero, &Indices[0]);
return DAG.getNode(ISD::BITCAST, dl, VT, Shuf);
Expand Down Expand Up @@ -10713,8 +10700,7 @@ SDValue DAGCombiner::SimplifyVBinOp(SDNode *N) {
}

if (Ops.size() == LHS.getNumOperands())
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N),
LHS.getValueType(), &Ops[0], Ops.size());
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), LHS.getValueType(), Ops);
}

return SDValue();
Expand Down Expand Up @@ -10749,8 +10735,7 @@ SDValue DAGCombiner::SimplifyVUnaryOp(SDNode *N) {
if (Ops.size() != N0.getNumOperands())
return SDValue();

return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N),
N0.getValueType(), &Ops[0], Ops.size());
return DAG.getNode(ISD::BUILD_VECTOR, SDLoc(N), N0.getValueType(), Ops);
}

SDValue DAGCombiner::SimplifySelect(SDLoc DL, SDValue N0,
Expand Down Expand Up @@ -11544,8 +11529,7 @@ SDValue DAGCombiner::FindBetterChain(SDNode *N, SDValue OldChain) {
return Aliases[0];

// Construct a custom tailored token factor.
return DAG.getNode(ISD::TokenFactor, SDLoc(N), MVT::Other,
&Aliases[0], Aliases.size());
return DAG.getNode(ISD::TokenFactor, SDLoc(N), MVT::Other, Aliases);
}

// SelectionDAG::Combine - This is the entry point for the file.
Expand Down
15 changes: 5 additions & 10 deletions lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,7 @@ static void ExpandUnalignedStore(StoreSDNode *ST, SelectionDAG &DAG,
MinAlign(ST->getAlignment(), Offset),
ST->getTBAAInfo()));
// The order of the stores doesn't matter - say it with a TokenFactor.
SDValue Result =
DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &Stores[0],
Stores.size());
SDValue Result = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Stores);
DAGLegalize->ReplaceNode(SDValue(ST, 0), Result);
return;
}
Expand Down Expand Up @@ -506,8 +504,7 @@ ExpandUnalignedLoad(LoadSDNode *LD, SelectionDAG &DAG,
false, false, 0));

// The order of the stores doesn't matter - say it with a TokenFactor.
SDValue TF = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &Stores[0],
Stores.size());
SDValue TF = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Stores);

// Finally, perform the original load only redirected to the stack slot.
Load = DAG.getExtLoad(LD->getExtensionType(), dl, VT, TF, StackBase,
Expand Down Expand Up @@ -1528,8 +1525,7 @@ SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) {

SDValue StoreChain;
if (!Stores.empty()) // Not all undef elements?
StoreChain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other,
&Stores[0], Stores.size());
StoreChain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, Stores);
else
StoreChain = DAG.getEntryNode();

Expand Down Expand Up @@ -3304,7 +3300,7 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node) {
TLI.getVectorIdxTy())));
}

Tmp1 = DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Ops[0], Ops.size());
Tmp1 = DAG.getNode(ISD::BUILD_VECTOR, dl, VT, Ops);
// We may have changed the BUILD_VECTOR type. Cast it back to the Node type.
Tmp1 = DAG.getNode(ISD::BITCAST, dl, Node->getValueType(0), Tmp1);
Results.push_back(Tmp1);
Expand Down Expand Up @@ -4011,8 +4007,7 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node) {
VT.getScalarType(), Ex, Sh));
}
SDValue Result =
DAG.getNode(ISD::BUILD_VECTOR, dl, Node->getValueType(0),
&Scalars[0], Scalars.size());
DAG.getNode(ISD::BUILD_VECTOR, dl, Node->getValueType(0), Scalars);
ReplaceNode(SDValue(Node, 0), Result);
break;
}
Expand Down
Loading

0 comments on commit 80d8db7

Please sign in to comment.