llvm.org GIT mirror llvm / 7d811a5
Convert more SelectionDAG functions to use ArrayRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207397 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 6 years ago
10 changed file(s) with 42 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
722722 /// getAtomic - Gets a node for an atomic op, produces result and chain and
723723 /// takes N operands.
724724 SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDVTList VTList,
725 const SDValue *Ops, unsigned NumOps, MachineMemOperand *MMO,
725 ArrayRef Ops, MachineMemOperand *MMO,
726726 AtomicOrdering SuccessOrdering,
727727 AtomicOrdering FailureOrdering,
728728 SynchronizationScope SynchScope);
729729 SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDVTList VTList,
730 const SDValue *Ops, unsigned NumOps, MachineMemOperand *MMO,
730 ArrayRef Ops, MachineMemOperand *MMO,
731731 AtomicOrdering Ordering, SynchronizationScope SynchScope);
732732
733733 /// getMemIntrinsicNode - Creates a MemIntrinsicNode that may produce a
825825 SDValue Op3, SDValue Op4);
826826 SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
827827 SDValue Op3, SDValue Op4, SDValue Op5);
828 SDNode *UpdateNodeOperands(SDNode *N,
829 const SDValue *Ops, unsigned NumOps);
828 SDNode *UpdateNodeOperands(SDNode *N, ArrayRef Ops);
830829
831830 /// SelectNodeTo - These are used for target selectors to *mutate* the
832831 /// specified node to have the specified return type, Target opcode, and
11631162 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos);
11641163 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2,
11651164 void *&InsertPos);
1166 SDNode *FindModifiedNodeSlot(SDNode *N, const SDValue *Ops, unsigned NumOps,
1165 SDNode *FindModifiedNodeSlot(SDNode *N, ArrayRef Ops,
11671166 void *&InsertPos);
11681167 SDNode *UpdadeSDLocOnMergedSDNode(SDNode *N, SDLoc loc);
11691168
932932 for (unsigned i = 0; i < NumElts; ++i)
933933 NewOps.push_back(GetPromotedInteger(N->getOperand(i)));
934934
935 return SDValue(DAG.UpdateNodeOperands(N, &NewOps[0], NumElts), 0);
935 return SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
936936 }
937937
938938 SDValue DAGTypeLegalizer::PromoteIntOp_CONVERT_RNDSAT(SDNode *N) {
489489
490490 // Some operands changed - update the node.
491491 if (!NewOps.empty()) {
492 SDNode *M = DAG.UpdateNodeOperands(N, &NewOps[0], NewOps.size());
492 SDNode *M = DAG.UpdateNodeOperands(N, NewOps);
493493 if (M != N) {
494494 // The node morphed into a different node. Normally for this to happen
495495 // the original node would have to be marked NewNode. However this can
151151 for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i)
152152 Ops.push_back(LegalizeOp(Node->getOperand(i)));
153153
154 SDValue Result =
155 SDValue(DAG.UpdateNodeOperands(Op.getNode(), Ops.data(), Ops.size()), 0);
154 SDValue Result = SDValue(DAG.UpdateNodeOperands(Op.getNode(), Ops), 0);
156155
157156 if (Op.getOpcode() == ISD::LOAD) {
158157 LoadSDNode *LD = cast(Op.getNode());
363363 /// AddNodeIDOperands - Various routines for adding operands to the NodeID data.
364364 ///
365365 static void AddNodeIDOperands(FoldingSetNodeID &ID,
366 const SDValue *Ops, unsigned NumOps) {
367 for (; NumOps; --NumOps, ++Ops) {
368 ID.AddPointer(Ops->getNode());
369 ID.AddInteger(Ops->getResNo());
366 ArrayRef Ops) {
367 for (auto& Op : Ops) {
368 ID.AddPointer(Op.getNode());
369 ID.AddInteger(Op.getResNo());
370370 }
371371 }
372372
373373 /// AddNodeIDOperands - Various routines for adding operands to the NodeID data.
374374 ///
375375 static void AddNodeIDOperands(FoldingSetNodeID &ID,
376 const SDUse *Ops, unsigned NumOps) {
377 for (; NumOps; --NumOps, ++Ops) {
378 ID.AddPointer(Ops->getNode());
379 ID.AddInteger(Ops->getResNo());
376 ArrayRef Ops) {
377 for (auto& Op : Ops) {
378 ID.AddPointer(Op.getNode());
379 ID.AddInteger(Op.getResNo());
380380 }
381381 }
382382
384384 SDVTList VTList, ArrayRef OpList) {
385385 AddNodeIDOpcode(ID, OpC);
386386 AddNodeIDValueTypes(ID, VTList);
387 AddNodeIDOperands(ID, OpList.data(), OpList.size());
387 AddNodeIDOperands(ID, OpList);
388388 }
389389
390390 /// AddNodeIDCustom - If this is an SDNode with special info, add this info to
526526 // Add the return value info.
527527 AddNodeIDValueTypes(ID, N->getVTList());
528528 // Add the operand info.
529 AddNodeIDOperands(ID, N->op_begin(), N->getNumOperands());
529 AddNodeIDOperands(ID, ArrayRef(N->op_begin(), N->op_end()));
530530
531531 // Handle SDNode leafs with special info.
532532 AddNodeIDCustom(ID, N);
796796 /// were replaced with those specified. If this node is never memoized,
797797 /// return null, otherwise return a pointer to the slot it would take. If a
798798 /// node already exists with these operands, the slot will be non-null.
799 SDNode *SelectionDAG::FindModifiedNodeSlot(SDNode *N,
800 const SDValue *Ops,unsigned NumOps,
799 SDNode *SelectionDAG::FindModifiedNodeSlot(SDNode *N, ArrayRef Ops,
801800 void *&InsertPos) {
802801 if (doNotCSE(N))
803802 return nullptr;
804803
805804 FoldingSetNodeID ID;
806 AddNodeIDNode(ID, N->getOpcode(), N->getVTList(),
807 ArrayRef(Ops, NumOps));
805 AddNodeIDNode(ID, N->getOpcode(), N->getVTList(), Ops);
808806 AddNodeIDCustom(ID, N);
809807 SDNode *Node = CSEMap.FindNodeOrInsertPos(ID, InsertPos);
810808 return Node;
42374235 }
42384236
42394237 SDValue SelectionDAG::getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT,
4240 SDVTList VTList, const SDValue *Ops, unsigned NumOps,
4238 SDVTList VTList, ArrayRef Ops,
42414239 MachineMemOperand *MMO,
42424240 AtomicOrdering SuccessOrdering,
42434241 AtomicOrdering FailureOrdering,
42444242 SynchronizationScope SynchScope) {
42454243 FoldingSetNodeID ID;
42464244 ID.AddInteger(MemVT.getRawBits());
4247 AddNodeIDNode(ID, Opcode, VTList, ArrayRef(Ops, NumOps));
4245 AddNodeIDNode(ID, Opcode, VTList, Ops);
42484246 ID.AddInteger(MMO->getPointerInfo().getAddrSpace());
42494247 void* IP = nullptr;
42504248 if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP)) {
42574255 // the node is deallocated, but recovered when the allocator is released.
42584256 // If the number of operands is less than 5 we use AtomicSDNode's internal
42594257 // storage.
4260 SDUse *DynOps = NumOps > 4 ? OperandAllocator.Allocate(NumOps) : nullptr;
4258 unsigned NumOps = Ops.size();
4259 SDUse *DynOps = NumOps > 4 ? OperandAllocator.Allocate(NumOps)
4260 : nullptr;
42614261
42624262 SDNode *N = new (NodeAllocator) AtomicSDNode(Opcode, dl.getIROrder(),
42634263 dl.getDebugLoc(), VTList, MemVT,
4264 Ops, DynOps, NumOps, MMO,
4264 Ops.data(), DynOps, NumOps, MMO,
42654265 SuccessOrdering, FailureOrdering,
42664266 SynchScope);
42674267 CSEMap.InsertNode(N, IP);
42704270 }
42714271
42724272 SDValue SelectionDAG::getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT,
4273 SDVTList VTList, const SDValue *Ops, unsigned NumOps,
4273 SDVTList VTList, ArrayRef Ops,
42744274 MachineMemOperand *MMO,
42754275 AtomicOrdering Ordering,
42764276 SynchronizationScope SynchScope) {
4277 return getAtomic(Opcode, dl, MemVT, VTList, Ops, NumOps, MMO, Ordering,
4277 return getAtomic(Opcode, dl, MemVT, VTList, Ops, MMO, Ordering,
42784278 Ordering, SynchScope);
42794279 }
42804280
43214321
43224322 SDVTList VTs = getVTList(VT, MVT::Other);
43234323 SDValue Ops[] = {Chain, Ptr, Cmp, Swp};
4324 return getAtomic(Opcode, dl, MemVT, VTs, Ops, 4, MMO, SuccessOrdering,
4324 return getAtomic(Opcode, dl, MemVT, VTs, Ops, MMO, SuccessOrdering,
43254325 FailureOrdering, SynchScope);
43264326 }
43274327
43814381 SDVTList VTs = Opcode == ISD::ATOMIC_STORE ? getVTList(MVT::Other) :
43824382 getVTList(VT, MVT::Other);
43834383 SDValue Ops[] = {Chain, Ptr, Val};
4384 return getAtomic(Opcode, dl, MemVT, VTs, Ops, 3, MMO, Ordering, SynchScope);
4384 return getAtomic(Opcode, dl, MemVT, VTs, Ops, MMO, Ordering, SynchScope);
43854385 }
43864386
43874387 SDValue SelectionDAG::getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT,
43944394
43954395 SDVTList VTs = getVTList(VT, MVT::Other);
43964396 SDValue Ops[] = {Chain, Ptr};
4397 return getAtomic(Opcode, dl, MemVT, VTs, Ops, 2, MMO, Ordering, SynchScope);
4397 return getAtomic(Opcode, dl, MemVT, VTs, Ops, MMO, Ordering, SynchScope);
43984398 }
43994399
44004400 /// getMergeValues - Create a MERGE_VALUES node from the given operands.
51355135 SDNode *SelectionDAG::
51365136 UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2, SDValue Op3) {
51375137 SDValue Ops[] = { Op1, Op2, Op3 };
5138 return UpdateNodeOperands(N, Ops, 3);
5138 return UpdateNodeOperands(N, Ops);
51395139 }
51405140
51415141 SDNode *SelectionDAG::
51425142 UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
51435143 SDValue Op3, SDValue Op4) {
51445144 SDValue Ops[] = { Op1, Op2, Op3, Op4 };
5145 return UpdateNodeOperands(N, Ops, 4);
5145 return UpdateNodeOperands(N, Ops);
51465146 }
51475147
51485148 SDNode *SelectionDAG::
51495149 UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
51505150 SDValue Op3, SDValue Op4, SDValue Op5) {
51515151 SDValue Ops[] = { Op1, Op2, Op3, Op4, Op5 };
5152 return UpdateNodeOperands(N, Ops, 5);
5152 return UpdateNodeOperands(N, Ops);
51535153 }
51545154
51555155 SDNode *SelectionDAG::
5156 UpdateNodeOperands(SDNode *N, const SDValue *Ops, unsigned NumOps) {
5156 UpdateNodeOperands(SDNode *N, ArrayRef Ops) {
5157 unsigned NumOps = Ops.size();
51575158 assert(N->getNumOperands() == NumOps &&
51585159 "Update with wrong number of operands");
51595160
51715172
51725173 // See if the modified node already exists.
51735174 void *InsertPos = nullptr;
5174 if (SDNode *Existing = FindModifiedNodeSlot(N, Ops, NumOps, InsertPos))
5175 if (SDNode *Existing = FindModifiedNodeSlot(N, Ops, InsertPos))
51755176 return Existing;
51765177
51775178 // Nope it doesn't. Remove the node from its current place in the maps.
33893389 // Update the original glue user.
33903390 std::vector Ops(GU->op_begin(), GU->op_end()-1);
33913391 Ops.push_back(T1.getValue(1));
3392 CurDAG->UpdateNodeOperands(GU, &Ops[0], Ops.size());
3392 CurDAG->UpdateNodeOperands(GU, Ops);
33933393 GU = T1.getNode();
33943394 }
33953395 else {
81588158 Ops.push_back(*O);
81598159 }
81608160
8161 DAG.UpdateNodeOperands(User, Ops.data(), Ops.size());
8161 DAG.UpdateNodeOperands(User, Ops);
81628162 }
81638163
81648164 return SDValue(N, 0);
506506 for (unsigned i = 1; i < (*I)->getNumOperands(); ++i) {
507507 Ops.push_back((*I)->getOperand(i));
508508 }
509 DAG.UpdateNodeOperands(*I, Ops.data(), Ops.size());
509 DAG.UpdateNodeOperands(*I, Ops);
510510 }
511511 return DAG.getZExtOrTrunc(InitPtr, SDLoc(Op),
512512 getPointerTy(AMDGPUAS::CONSTANT_ADDRESS));
14271427 Ops.push_back(DAG.getTargetConstant(NewDmask, MVT::i32));
14281428 for (unsigned i = 1, e = Node->getNumOperands(); i != e; ++i)
14291429 Ops.push_back(Node->getOperand(i));
1430 Node = (MachineSDNode*)DAG.UpdateNodeOperands(Node, Ops.data(), Ops.size());
1430 Node = (MachineSDNode*)DAG.UpdateNodeOperands(Node, Ops);
14311431
14321432 // If we only got one lane, replace it with a copy
14331433 // (if NewDmask has only one bit set...)
381381 }
382382 for (unsigned i = 1, e = OrigChain.getNumOperands(); i != e; ++i)
383383 Ops.push_back(OrigChain.getOperand(i));
384 CurDAG->UpdateNodeOperands(OrigChain.getNode(), &Ops[0], Ops.size());
384 CurDAG->UpdateNodeOperands(OrigChain.getNode(), Ops);
385385 CurDAG->UpdateNodeOperands(Load.getNode(), Call.getOperand(0),
386386 Load.getOperand(1), Load.getOperand(2));
387387
390390 Ops.push_back(SDValue(Load.getNode(), 1));
391391 for (unsigned i = 1, e = NumOps; i != e; ++i)
392392 Ops.push_back(Call.getOperand(i));
393 CurDAG->UpdateNodeOperands(Call.getNode(), &Ops[0], NumOps);
393 CurDAG->UpdateNodeOperands(Call.getNode(), Ops);
394394 }
395395
396396 /// isCalleeLoad - Return true if call address is a load and it can be