1 //===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the SDNode class and derived classes, which are used to
11 // represent the nodes and operations present in a SelectionDAG. These nodes
12 // and operations are machine code level operations, with some similarities to
13 // the GCC RTL representation.
15 // Clients should include the SelectionDAG.h file instead of this file directly.
17 //===----------------------------------------------------------------------===//
19 #ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
20 #define LLVM_CODEGEN_SELECTIONDAGNODES_H
22 #include "llvm/ADT/iterator_range.h"
23 #include "llvm/ADT/FoldingSet.h"
24 #include "llvm/ADT/GraphTraits.h"
25 #include "llvm/ADT/STLExtras.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/ilist_node.h"
29 #include "llvm/CodeGen/ISDOpcodes.h"
30 #include "llvm/CodeGen/MachineMemOperand.h"
31 #include "llvm/CodeGen/ValueTypes.h"
32 #include "llvm/IR/Constants.h"
33 #include "llvm/IR/DebugLoc.h"
34 #include "llvm/IR/Instructions.h"
35 #include "llvm/Support/DataTypes.h"
36 #include "llvm/Support/MathExtras.h"
43 class MachineBasicBlock;
44 class MachineConstantPoolValue;
48 template <typename T> struct DenseMapInfo;
49 template <typename T> struct simplify_type;
50 template <typename T> struct ilist_traits;
52 /// isBinOpWithFlags - Returns true if the opcode is a binary operation
54 static bool isBinOpWithFlags(unsigned Opcode) {
70 void checkForCycles(const SDNode *N, const SelectionDAG *DAG = nullptr,
73 /// SDVTList - This represents a list of ValueType's that has been intern'd by
74 /// a SelectionDAG. Instances of this simple value class are returned by
75 /// SelectionDAG::getVTList(...).
85 /// isBuildVectorAllOnes - Return true if the specified node is a
86 /// BUILD_VECTOR where all of the elements are ~0 or undef.
87 bool isBuildVectorAllOnes(const SDNode *N);
89 /// isBuildVectorAllZeros - Return true if the specified node is a
90 /// BUILD_VECTOR where all of the elements are 0 or undef.
91 bool isBuildVectorAllZeros(const SDNode *N);
93 /// \brief Return true if the specified node is a BUILD_VECTOR node of
94 /// all ConstantSDNode or undef.
95 bool isBuildVectorOfConstantSDNodes(const SDNode *N);
97 /// isScalarToVector - Return true if the specified node is a
98 /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
99 /// element is not an undef.
100 bool isScalarToVector(const SDNode *N);
102 /// allOperandsUndef - Return true if the node has at least one operand
103 /// and all operands of the specified node are ISD::UNDEF.
104 bool allOperandsUndef(const SDNode *N);
105 } // end llvm:ISD namespace
107 //===----------------------------------------------------------------------===//
108 /// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple
109 /// values as the result of a computation. Many nodes return multiple values,
110 /// from loads (which define a token and a return value) to ADDC (which returns
111 /// a result and a carry value), to calls (which may return an arbitrary number
114 /// As such, each use of a SelectionDAG computation must indicate the node that
115 /// computes it as well as which return value to use from that node. This pair
116 /// of information is represented with the SDValue value type.
119 SDNode *Node; // The node defining the value we are using.
120 unsigned ResNo; // Which return value of the node we are using.
122 SDValue() : Node(nullptr), ResNo(0) {}
123 SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {}
125 /// get the index which selects a specific result in the SDNode
126 unsigned getResNo() const { return ResNo; }
128 /// get the SDNode which holds the desired result
129 SDNode *getNode() const { return Node; }
132 void setNode(SDNode *N) { Node = N; }
134 inline SDNode *operator->() const { return Node; }
136 bool operator==(const SDValue &O) const {
137 return Node == O.Node && ResNo == O.ResNo;
139 bool operator!=(const SDValue &O) const {
140 return !operator==(O);
142 bool operator<(const SDValue &O) const {
143 return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo);
145 LLVM_EXPLICIT operator bool() const {
146 return Node != nullptr;
149 SDValue getValue(unsigned R) const {
150 return SDValue(Node, R);
153 // isOperandOf - Return true if this node is an operand of N.
154 bool isOperandOf(SDNode *N) const;
156 /// getValueType - Return the ValueType of the referenced return value.
158 inline EVT getValueType() const;
160 /// Return the simple ValueType of the referenced return value.
161 MVT getSimpleValueType() const {
162 return getValueType().getSimpleVT();
165 /// getValueSizeInBits - Returns the size of the value in bits.
167 unsigned getValueSizeInBits() const {
168 return getValueType().getSizeInBits();
171 unsigned getScalarValueSizeInBits() const {
172 return getValueType().getScalarType().getSizeInBits();
175 // Forwarding methods - These forward to the corresponding methods in SDNode.
176 inline unsigned getOpcode() const;
177 inline unsigned getNumOperands() const;
178 inline const SDValue &getOperand(unsigned i) const;
179 inline uint64_t getConstantOperandVal(unsigned i) const;
180 inline bool isTargetMemoryOpcode() const;
181 inline bool isTargetOpcode() const;
182 inline bool isMachineOpcode() const;
183 inline unsigned getMachineOpcode() const;
184 inline const DebugLoc getDebugLoc() const;
185 inline void dump() const;
186 inline void dumpr() const;
188 /// reachesChainWithoutSideEffects - Return true if this operand (which must
189 /// be a chain) reaches the specified operand without crossing any
190 /// side-effecting instructions. In practice, this looks through token
191 /// factors and non-volatile loads. In order to remain efficient, this only
192 /// looks a couple of nodes in, it does not do an exhaustive search.
193 bool reachesChainWithoutSideEffects(SDValue Dest,
194 unsigned Depth = 2) const;
196 /// use_empty - Return true if there are no nodes using value ResNo
199 inline bool use_empty() const;
201 /// hasOneUse - Return true if there is exactly one node using value
204 inline bool hasOneUse() const;
208 template<> struct DenseMapInfo<SDValue> {
209 static inline SDValue getEmptyKey() {
210 return SDValue((SDNode*)-1, -1U);
212 static inline SDValue getTombstoneKey() {
213 return SDValue((SDNode*)-1, 0);
215 static unsigned getHashValue(const SDValue &Val) {
216 return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
217 (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
219 static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
223 template <> struct isPodLike<SDValue> { static const bool value = true; };
226 /// simplify_type specializations - Allow casting operators to work directly on
227 /// SDValues as if they were SDNode*'s.
228 template<> struct simplify_type<SDValue> {
229 typedef SDNode* SimpleType;
230 static SimpleType getSimplifiedValue(SDValue &Val) {
231 return Val.getNode();
234 template<> struct simplify_type<const SDValue> {
235 typedef /*const*/ SDNode* SimpleType;
236 static SimpleType getSimplifiedValue(const SDValue &Val) {
237 return Val.getNode();
241 /// SDUse - Represents a use of a SDNode. This class holds an SDValue,
242 /// which records the SDNode being used and the result number, a
243 /// pointer to the SDNode using the value, and Next and Prev pointers,
244 /// which link together all the uses of an SDNode.
247 /// Val - The value being used.
249 /// User - The user of this value.
251 /// Prev, Next - Pointers to the uses list of the SDNode referred by
255 SDUse(const SDUse &U) LLVM_DELETED_FUNCTION;
256 void operator=(const SDUse &U) LLVM_DELETED_FUNCTION;
259 SDUse() : Val(), User(nullptr), Prev(nullptr), Next(nullptr) {}
261 /// Normally SDUse will just implicitly convert to an SDValue that it holds.
262 operator const SDValue&() const { return Val; }
264 /// If implicit conversion to SDValue doesn't work, the get() method returns
266 const SDValue &get() const { return Val; }
268 /// getUser - This returns the SDNode that contains this Use.
269 SDNode *getUser() { return User; }
271 /// getNext - Get the next SDUse in the use list.
272 SDUse *getNext() const { return Next; }
274 /// getNode - Convenience function for get().getNode().
275 SDNode *getNode() const { return Val.getNode(); }
276 /// getResNo - Convenience function for get().getResNo().
277 unsigned getResNo() const { return Val.getResNo(); }
278 /// getValueType - Convenience function for get().getValueType().
279 EVT getValueType() const { return Val.getValueType(); }
281 /// operator== - Convenience function for get().operator==
282 bool operator==(const SDValue &V) const {
286 /// operator!= - Convenience function for get().operator!=
287 bool operator!=(const SDValue &V) const {
291 /// operator< - Convenience function for get().operator<
292 bool operator<(const SDValue &V) const {
297 friend class SelectionDAG;
300 void setUser(SDNode *p) { User = p; }
302 /// set - Remove this use from its existing use list, assign it the
303 /// given value, and add it to the new value's node's use list.
304 inline void set(const SDValue &V);
305 /// setInitial - like set, but only supports initializing a newly-allocated
306 /// SDUse with a non-null value.
307 inline void setInitial(const SDValue &V);
308 /// setNode - like set, but only sets the Node portion of the value,
309 /// leaving the ResNo portion unmodified.
310 inline void setNode(SDNode *N);
312 void addToList(SDUse **List) {
314 if (Next) Next->Prev = &Next;
319 void removeFromList() {
321 if (Next) Next->Prev = Prev;
325 /// simplify_type specializations - Allow casting operators to work directly on
326 /// SDValues as if they were SDNode*'s.
327 template<> struct simplify_type<SDUse> {
328 typedef SDNode* SimpleType;
329 static SimpleType getSimplifiedValue(SDUse &Val) {
330 return Val.getNode();
335 /// SDNode - Represents one node in the SelectionDAG.
337 class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
339 /// NodeType - The operation that this node performs.
343 /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true,
344 /// then they will be delete[]'d when the node is destroyed.
345 uint16_t OperandsNeedDelete : 1;
347 /// HasDebugValue - This tracks whether this node has one or more dbg_value
348 /// nodes corresponding to it.
349 uint16_t HasDebugValue : 1;
352 /// SubclassData - This member is defined by this class, but is not used for
353 /// anything. Subclasses can use it to hold whatever state they find useful.
354 /// This field is initialized to zero by the ctor.
355 uint16_t SubclassData : 14;
358 /// NodeId - Unique id per SDNode in the DAG.
361 /// OperandList - The values that are used by this operation.
365 /// ValueList - The types of the values this node defines. SDNode's may
366 /// define multiple values simultaneously.
367 const EVT *ValueList;
369 /// UseList - List of uses for this SDNode.
372 /// NumOperands/NumValues - The number of entries in the Operand/Value list.
373 unsigned short NumOperands, NumValues;
375 /// debugLoc - source line information.
378 // The ordering of the SDNodes. It roughly corresponds to the ordering of the
379 // original LLVM instructions.
380 // This is used for turning off scheduling, because we'll forgo
381 // the normal scheduling algorithms and output the instructions according to
385 /// getValueTypeList - Return a pointer to the specified value type.
386 static const EVT *getValueTypeList(EVT VT);
388 friend class SelectionDAG;
389 friend struct ilist_traits<SDNode>;
392 //===--------------------------------------------------------------------===//
396 /// getOpcode - Return the SelectionDAG opcode value for this node. For
397 /// pre-isel nodes (those for which isMachineOpcode returns false), these
398 /// are the opcode values in the ISD and <target>ISD namespaces. For
399 /// post-isel opcodes, see getMachineOpcode.
400 unsigned getOpcode() const { return (unsigned short)NodeType; }
402 /// isTargetOpcode - Test if this node has a target-specific opcode (in the
403 /// \<target\>ISD namespace).
404 bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
406 /// isTargetMemoryOpcode - Test if this node has a target-specific
407 /// memory-referencing opcode (in the \<target\>ISD namespace and
408 /// greater than FIRST_TARGET_MEMORY_OPCODE).
409 bool isTargetMemoryOpcode() const {
410 return NodeType >= ISD::FIRST_TARGET_MEMORY_OPCODE;
413 /// isMachineOpcode - Test if this node has a post-isel opcode, directly
414 /// corresponding to a MachineInstr opcode.
415 bool isMachineOpcode() const { return NodeType < 0; }
417 /// getMachineOpcode - This may only be called if isMachineOpcode returns
418 /// true. It returns the MachineInstr opcode value that the node's opcode
420 unsigned getMachineOpcode() const {
421 assert(isMachineOpcode() && "Not a MachineInstr opcode!");
425 /// getHasDebugValue - get this bit.
426 bool getHasDebugValue() const { return HasDebugValue; }
428 /// setHasDebugValue - set this bit.
429 void setHasDebugValue(bool b) { HasDebugValue = b; }
431 /// use_empty - Return true if there are no uses of this node.
433 bool use_empty() const { return UseList == nullptr; }
435 /// hasOneUse - Return true if there is exactly one use of this node.
437 bool hasOneUse() const {
438 return !use_empty() && std::next(use_begin()) == use_end();
441 /// use_size - Return the number of uses of this node. This method takes
442 /// time proportional to the number of uses.
444 size_t use_size() const { return std::distance(use_begin(), use_end()); }
446 /// getNodeId - Return the unique node id.
448 int getNodeId() const { return NodeId; }
450 /// setNodeId - Set unique node id.
451 void setNodeId(int Id) { NodeId = Id; }
453 /// getIROrder - Return the node ordering.
455 unsigned getIROrder() const { return IROrder; }
457 /// setIROrder - Set the node ordering.
459 void setIROrder(unsigned Order) { IROrder = Order; }
461 /// getDebugLoc - Return the source location info.
462 const DebugLoc getDebugLoc() const { return debugLoc; }
464 /// setDebugLoc - Set source location info. Try to avoid this, putting
465 /// it in the constructor is preferable.
466 void setDebugLoc(const DebugLoc dl) { debugLoc = dl; }
468 /// use_iterator - This class provides iterator support for SDUse
469 /// operands that use a specific SDNode.
471 : public std::iterator<std::forward_iterator_tag, SDUse, ptrdiff_t> {
473 explicit use_iterator(SDUse *op) : Op(op) {
477 typedef std::iterator<std::forward_iterator_tag,
478 SDUse, ptrdiff_t>::reference reference;
479 typedef std::iterator<std::forward_iterator_tag,
480 SDUse, ptrdiff_t>::pointer pointer;
482 use_iterator(const use_iterator &I) : Op(I.Op) {}
483 use_iterator() : Op(nullptr) {}
485 bool operator==(const use_iterator &x) const {
488 bool operator!=(const use_iterator &x) const {
489 return !operator==(x);
492 /// atEnd - return true if this iterator is at the end of uses list.
493 bool atEnd() const { return Op == nullptr; }
495 // Iterator traversal: forward iteration only.
496 use_iterator &operator++() { // Preincrement
497 assert(Op && "Cannot increment end iterator!");
502 use_iterator operator++(int) { // Postincrement
503 use_iterator tmp = *this; ++*this; return tmp;
506 /// Retrieve a pointer to the current user node.
507 SDNode *operator*() const {
508 assert(Op && "Cannot dereference end iterator!");
509 return Op->getUser();
512 SDNode *operator->() const { return operator*(); }
514 SDUse &getUse() const { return *Op; }
516 /// getOperandNo - Retrieve the operand # of this use in its user.
518 unsigned getOperandNo() const {
519 assert(Op && "Cannot dereference end iterator!");
520 return (unsigned)(Op - Op->getUser()->OperandList);
524 /// use_begin/use_end - Provide iteration support to walk over all uses
527 use_iterator use_begin() const {
528 return use_iterator(UseList);
531 static use_iterator use_end() { return use_iterator(nullptr); }
533 inline iterator_range<use_iterator> uses() {
534 return iterator_range<use_iterator>(use_begin(), use_end());
536 inline iterator_range<use_iterator> uses() const {
537 return iterator_range<use_iterator>(use_begin(), use_end());
540 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
541 /// indicated value. This method ignores uses of other values defined by this
543 bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
545 /// hasAnyUseOfValue - Return true if there are any use of the indicated
546 /// value. This method ignores uses of other values defined by this operation.
547 bool hasAnyUseOfValue(unsigned Value) const;
549 /// isOnlyUserOf - Return true if this node is the only use of N.
551 bool isOnlyUserOf(SDNode *N) const;
553 /// isOperandOf - Return true if this node is an operand of N.
555 bool isOperandOf(SDNode *N) const;
557 /// isPredecessorOf - Return true if this node is a predecessor of N.
558 /// NOTE: Implemented on top of hasPredecessor and every bit as
559 /// expensive. Use carefully.
560 bool isPredecessorOf(const SDNode *N) const {
561 return N->hasPredecessor(this);
564 /// hasPredecessor - Return true if N is a predecessor of this node.
565 /// N is either an operand of this node, or can be reached by recursively
566 /// traversing up the operands.
567 /// NOTE: This is an expensive method. Use it carefully.
568 bool hasPredecessor(const SDNode *N) const;
570 /// hasPredecesorHelper - Return true if N is a predecessor of this node.
571 /// N is either an operand of this node, or can be reached by recursively
572 /// traversing up the operands.
573 /// In this helper the Visited and worklist sets are held externally to
574 /// cache predecessors over multiple invocations. If you want to test for
575 /// multiple predecessors this method is preferable to multiple calls to
576 /// hasPredecessor. Be sure to clear Visited and Worklist if the DAG
578 /// NOTE: This is still very expensive. Use carefully.
579 bool hasPredecessorHelper(const SDNode *N,
580 SmallPtrSet<const SDNode *, 32> &Visited,
581 SmallVectorImpl<const SDNode *> &Worklist) const;
583 /// getNumOperands - Return the number of values used by this operation.
585 unsigned getNumOperands() const { return NumOperands; }
587 /// getConstantOperandVal - Helper method returns the integer value of a
588 /// ConstantSDNode operand.
589 uint64_t getConstantOperandVal(unsigned Num) const;
591 const SDValue &getOperand(unsigned Num) const {
592 assert(Num < NumOperands && "Invalid child # of SDNode!");
593 return OperandList[Num];
596 typedef SDUse* op_iterator;
597 op_iterator op_begin() const { return OperandList; }
598 op_iterator op_end() const { return OperandList+NumOperands; }
599 ArrayRef<SDUse> ops() const { return makeArrayRef(op_begin(), op_end()); }
601 SDVTList getVTList() const {
602 SDVTList X = { ValueList, NumValues };
606 /// getGluedNode - If this node has a glue operand, return the node
607 /// to which the glue operand points. Otherwise return NULL.
608 SDNode *getGluedNode() const {
609 if (getNumOperands() != 0 &&
610 getOperand(getNumOperands()-1).getValueType() == MVT::Glue)
611 return getOperand(getNumOperands()-1).getNode();
615 // If this is a pseudo op, like copyfromreg, look to see if there is a
616 // real target node glued to it. If so, return the target node.
617 const SDNode *getGluedMachineNode() const {
618 const SDNode *FoundNode = this;
620 // Climb up glue edges until a machine-opcode node is found, or the
621 // end of the chain is reached.
622 while (!FoundNode->isMachineOpcode()) {
623 const SDNode *N = FoundNode->getGluedNode();
631 /// getGluedUser - If this node has a glue value with a user, return
632 /// the user (there is at most one). Otherwise return NULL.
633 SDNode *getGluedUser() const {
634 for (use_iterator UI = use_begin(), UE = use_end(); UI != UE; ++UI)
635 if (UI.getUse().get().getValueType() == MVT::Glue)
640 /// getNumValues - Return the number of values defined/returned by this
643 unsigned getNumValues() const { return NumValues; }
645 /// getValueType - Return the type of a specified result.
647 EVT getValueType(unsigned ResNo) const {
648 assert(ResNo < NumValues && "Illegal result number!");
649 return ValueList[ResNo];
652 /// Return the type of a specified result as a simple type.
654 MVT getSimpleValueType(unsigned ResNo) const {
655 return getValueType(ResNo).getSimpleVT();
658 /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
660 unsigned getValueSizeInBits(unsigned ResNo) const {
661 return getValueType(ResNo).getSizeInBits();
664 typedef const EVT* value_iterator;
665 value_iterator value_begin() const { return ValueList; }
666 value_iterator value_end() const { return ValueList+NumValues; }
668 /// getOperationName - Return the opcode of this operation for printing.
670 std::string getOperationName(const SelectionDAG *G = nullptr) const;
671 static const char* getIndexedModeName(ISD::MemIndexedMode AM);
672 void print_types(raw_ostream &OS, const SelectionDAG *G) const;
673 void print_details(raw_ostream &OS, const SelectionDAG *G) const;
674 void print(raw_ostream &OS, const SelectionDAG *G = nullptr) const;
675 void printr(raw_ostream &OS, const SelectionDAG *G = nullptr) const;
677 /// printrFull - Print a SelectionDAG node and all children down to
678 /// the leaves. The given SelectionDAG allows target-specific nodes
679 /// to be printed in human-readable form. Unlike printr, this will
680 /// print the whole DAG, including children that appear multiple
683 void printrFull(raw_ostream &O, const SelectionDAG *G = nullptr) const;
685 /// printrWithDepth - Print a SelectionDAG node and children up to
686 /// depth "depth." The given SelectionDAG allows target-specific
687 /// nodes to be printed in human-readable form. Unlike printr, this
688 /// will print children that appear multiple times wherever they are
691 void printrWithDepth(raw_ostream &O, const SelectionDAG *G = nullptr,
692 unsigned depth = 100) const;
695 /// dump - Dump this node, for debugging.
698 /// dumpr - Dump (recursively) this node and its use-def subgraph.
701 /// dump - Dump this node, for debugging.
702 /// The given SelectionDAG allows target-specific nodes to be printed
703 /// in human-readable form.
704 void dump(const SelectionDAG *G) const;
706 /// dumpr - Dump (recursively) this node and its use-def subgraph.
707 /// The given SelectionDAG allows target-specific nodes to be printed
708 /// in human-readable form.
709 void dumpr(const SelectionDAG *G) const;
711 /// dumprFull - printrFull to dbgs(). The given SelectionDAG allows
712 /// target-specific nodes to be printed in human-readable form.
713 /// Unlike dumpr, this will print the whole DAG, including children
714 /// that appear multiple times.
716 void dumprFull(const SelectionDAG *G = nullptr) const;
718 /// dumprWithDepth - printrWithDepth to dbgs(). The given
719 /// SelectionDAG allows target-specific nodes to be printed in
720 /// human-readable form. Unlike dumpr, this will print children
721 /// that appear multiple times wherever they are used.
723 void dumprWithDepth(const SelectionDAG *G = nullptr,
724 unsigned depth = 100) const;
726 /// Profile - Gather unique data for the node.
728 void Profile(FoldingSetNodeID &ID) const;
730 /// addUse - This method should only be used by the SDUse class.
732 void addUse(SDUse &U) { U.addToList(&UseList); }
735 static SDVTList getSDVTList(EVT VT) {
736 SDVTList Ret = { getValueTypeList(VT), 1 };
740 SDNode(unsigned Opc, unsigned Order, const DebugLoc dl, SDVTList VTs,
741 ArrayRef<SDValue> Ops)
742 : NodeType(Opc), OperandsNeedDelete(true), HasDebugValue(false),
743 SubclassData(0), NodeId(-1),
744 OperandList(Ops.size() ? new SDUse[Ops.size()] : nullptr),
745 ValueList(VTs.VTs), UseList(nullptr),
746 NumOperands(Ops.size()), NumValues(VTs.NumVTs),
747 debugLoc(dl), IROrder(Order) {
748 for (unsigned i = 0; i != Ops.size(); ++i) {
749 OperandList[i].setUser(this);
750 OperandList[i].setInitial(Ops[i]);
752 checkForCycles(this);
755 /// This constructor adds no operands itself; operands can be
756 /// set later with InitOperands.
757 SDNode(unsigned Opc, unsigned Order, const DebugLoc dl, SDVTList VTs)
758 : NodeType(Opc), OperandsNeedDelete(false), HasDebugValue(false),
759 SubclassData(0), NodeId(-1), OperandList(nullptr), ValueList(VTs.VTs),
760 UseList(nullptr), NumOperands(0), NumValues(VTs.NumVTs), debugLoc(dl),
763 /// InitOperands - Initialize the operands list of this with 1 operand.
764 void InitOperands(SDUse *Ops, const SDValue &Op0) {
765 Ops[0].setUser(this);
766 Ops[0].setInitial(Op0);
769 checkForCycles(this);
772 /// InitOperands - Initialize the operands list of this with 2 operands.
773 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) {
774 Ops[0].setUser(this);
775 Ops[0].setInitial(Op0);
776 Ops[1].setUser(this);
777 Ops[1].setInitial(Op1);
780 checkForCycles(this);
783 /// InitOperands - Initialize the operands list of this with 3 operands.
784 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
785 const SDValue &Op2) {
786 Ops[0].setUser(this);
787 Ops[0].setInitial(Op0);
788 Ops[1].setUser(this);
789 Ops[1].setInitial(Op1);
790 Ops[2].setUser(this);
791 Ops[2].setInitial(Op2);
794 checkForCycles(this);
797 /// InitOperands - Initialize the operands list of this with 4 operands.
798 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
799 const SDValue &Op2, const SDValue &Op3) {
800 Ops[0].setUser(this);
801 Ops[0].setInitial(Op0);
802 Ops[1].setUser(this);
803 Ops[1].setInitial(Op1);
804 Ops[2].setUser(this);
805 Ops[2].setInitial(Op2);
806 Ops[3].setUser(this);
807 Ops[3].setInitial(Op3);
810 checkForCycles(this);
813 /// InitOperands - Initialize the operands list of this with N operands.
814 void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) {
815 for (unsigned i = 0; i != N; ++i) {
816 Ops[i].setUser(this);
817 Ops[i].setInitial(Vals[i]);
821 checkForCycles(this);
824 /// DropOperands - Release the operands and set this node to have
829 /// Wrapper class for IR location info (IR ordering and DebugLoc) to be passed
830 /// into SDNode creation functions.
831 /// When an SDNode is created from the DAGBuilder, the DebugLoc is extracted
832 /// from the original Instruction, and IROrder is the ordinal position of
834 /// When an SDNode is created after the DAG is being built, both DebugLoc and
835 /// the IROrder are propagated from the original SDNode.
836 /// So SDLoc class provides two constructors besides the default one, one to
837 /// be used by the DAGBuilder, the other to be used by others.
840 // Ptr could be used for either Instruction* or SDNode*. It is used for
841 // Instruction* if IROrder is not -1.
846 SDLoc() : Ptr(nullptr), IROrder(0) {}
847 SDLoc(const SDNode *N) : Ptr(N), IROrder(-1) {
848 assert(N && "null SDNode");
850 SDLoc(const SDValue V) : Ptr(V.getNode()), IROrder(-1) {
851 assert(Ptr && "null SDNode");
853 SDLoc(const Instruction *I, int Order) : Ptr(I), IROrder(Order) {
854 assert(Order >= 0 && "bad IROrder");
856 unsigned getIROrder() {
857 if (IROrder >= 0 || Ptr == nullptr) {
858 return (unsigned)IROrder;
860 const SDNode *N = (const SDNode*)(Ptr);
861 return N->getIROrder();
863 DebugLoc getDebugLoc() {
868 const Instruction *I = (const Instruction*)(Ptr);
869 return I->getDebugLoc();
871 const SDNode *N = (const SDNode*)(Ptr);
872 return N->getDebugLoc();
877 // Define inline functions from the SDValue class.
879 inline unsigned SDValue::getOpcode() const {
880 return Node->getOpcode();
882 inline EVT SDValue::getValueType() const {
883 return Node->getValueType(ResNo);
885 inline unsigned SDValue::getNumOperands() const {
886 return Node->getNumOperands();
888 inline const SDValue &SDValue::getOperand(unsigned i) const {
889 return Node->getOperand(i);
891 inline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
892 return Node->getConstantOperandVal(i);
894 inline bool SDValue::isTargetOpcode() const {
895 return Node->isTargetOpcode();
897 inline bool SDValue::isTargetMemoryOpcode() const {
898 return Node->isTargetMemoryOpcode();
900 inline bool SDValue::isMachineOpcode() const {
901 return Node->isMachineOpcode();
903 inline unsigned SDValue::getMachineOpcode() const {
904 return Node->getMachineOpcode();
906 inline bool SDValue::use_empty() const {
907 return !Node->hasAnyUseOfValue(ResNo);
909 inline bool SDValue::hasOneUse() const {
910 return Node->hasNUsesOfValue(1, ResNo);
912 inline const DebugLoc SDValue::getDebugLoc() const {
913 return Node->getDebugLoc();
915 inline void SDValue::dump() const {
918 inline void SDValue::dumpr() const {
919 return Node->dumpr();
921 // Define inline functions from the SDUse class.
923 inline void SDUse::set(const SDValue &V) {
924 if (Val.getNode()) removeFromList();
926 if (V.getNode()) V.getNode()->addUse(*this);
929 inline void SDUse::setInitial(const SDValue &V) {
931 V.getNode()->addUse(*this);
934 inline void SDUse::setNode(SDNode *N) {
935 if (Val.getNode()) removeFromList();
937 if (N) N->addUse(*this);
940 /// UnarySDNode - This class is used for single-operand SDNodes. This is solely
941 /// to allow co-allocation of node operands with the node itself.
942 class UnarySDNode : public SDNode {
945 UnarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
947 : SDNode(Opc, Order, dl, VTs) {
948 InitOperands(&Op, X);
952 /// BinarySDNode - This class is used for two-operand SDNodes. This is solely
953 /// to allow co-allocation of node operands with the node itself.
954 class BinarySDNode : public SDNode {
957 BinarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
958 SDValue X, SDValue Y)
959 : SDNode(Opc, Order, dl, VTs) {
960 InitOperands(Ops, X, Y);
964 /// BinaryWithFlagsSDNode - This class is an extension of BinarySDNode
965 /// used from those opcodes that have associated extra flags.
966 class BinaryWithFlagsSDNode : public BinarySDNode {
967 enum { NUW = (1 << 0), NSW = (1 << 1), EXACT = (1 << 2) };
970 BinaryWithFlagsSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
971 SDValue X, SDValue Y)
972 : BinarySDNode(Opc, Order, dl, VTs, X, Y) {}
973 /// getRawSubclassData - Return the SubclassData value, which contains an
974 /// encoding of the flags.
975 /// This function should be used to add subclass data to the NodeID value.
976 unsigned getRawSubclassData() const { return SubclassData; }
977 void setHasNoUnsignedWrap(bool b) {
978 SubclassData = (SubclassData & ~NUW) | (b ? NUW : 0);
980 void setHasNoSignedWrap(bool b) {
981 SubclassData = (SubclassData & ~NSW) | (b ? NSW : 0);
983 void setIsExact(bool b) {
984 SubclassData = (SubclassData & ~EXACT) | (b ? EXACT : 0);
986 bool hasNoUnsignedWrap() const { return SubclassData & NUW; }
987 bool hasNoSignedWrap() const { return SubclassData & NSW; }
988 bool isExact() const { return SubclassData & EXACT; }
989 static bool classof(const SDNode *N) {
990 return isBinOpWithFlags(N->getOpcode());
994 /// TernarySDNode - This class is used for three-operand SDNodes. This is solely
995 /// to allow co-allocation of node operands with the node itself.
996 class TernarySDNode : public SDNode {
999 TernarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1000 SDValue X, SDValue Y, SDValue Z)
1001 : SDNode(Opc, Order, dl, VTs) {
1002 InitOperands(Ops, X, Y, Z);
1007 /// HandleSDNode - This class is used to form a handle around another node that
1008 /// is persistent and is updated across invocations of replaceAllUsesWith on its
1009 /// operand. This node should be directly created by end-users and not added to
1010 /// the AllNodes list.
1011 class HandleSDNode : public SDNode {
1014 explicit HandleSDNode(SDValue X)
1015 : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) {
1016 InitOperands(&Op, X);
1019 const SDValue &getValue() const { return Op; }
1022 class AddrSpaceCastSDNode : public UnarySDNode {
1024 unsigned SrcAddrSpace;
1025 unsigned DestAddrSpace;
1028 AddrSpaceCastSDNode(unsigned Order, DebugLoc dl, EVT VT, SDValue X,
1029 unsigned SrcAS, unsigned DestAS);
1031 unsigned getSrcAddressSpace() const { return SrcAddrSpace; }
1032 unsigned getDestAddressSpace() const { return DestAddrSpace; }
1034 static bool classof(const SDNode *N) {
1035 return N->getOpcode() == ISD::ADDRSPACECAST;
1039 /// Abstact virtual class for operations for memory operations
1040 class MemSDNode : public SDNode {
1042 // MemoryVT - VT of in-memory value.
1046 /// MMO - Memory reference information.
1047 MachineMemOperand *MMO;
1050 MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1051 EVT MemoryVT, MachineMemOperand *MMO);
1053 MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1054 ArrayRef<SDValue> Ops, EVT MemoryVT, MachineMemOperand *MMO);
1056 bool readMem() const { return MMO->isLoad(); }
1057 bool writeMem() const { return MMO->isStore(); }
1059 /// Returns alignment and volatility of the memory access
1060 unsigned getOriginalAlignment() const {
1061 return MMO->getBaseAlignment();
1063 unsigned getAlignment() const {
1064 return MMO->getAlignment();
1067 /// getRawSubclassData - Return the SubclassData value, which contains an
1068 /// encoding of the volatile flag, as well as bits used by subclasses. This
1069 /// function should only be used to compute a FoldingSetNodeID value.
1070 unsigned getRawSubclassData() const {
1071 return SubclassData;
1074 // We access subclass data here so that we can check consistency
1075 // with MachineMemOperand information.
1076 bool isVolatile() const { return (SubclassData >> 5) & 1; }
1077 bool isNonTemporal() const { return (SubclassData >> 6) & 1; }
1078 bool isInvariant() const { return (SubclassData >> 7) & 1; }
1080 AtomicOrdering getOrdering() const {
1081 return AtomicOrdering((SubclassData >> 8) & 15);
1083 SynchronizationScope getSynchScope() const {
1084 return SynchronizationScope((SubclassData >> 12) & 1);
1087 // Returns the offset from the location of the access.
1088 int64_t getSrcValueOffset() const { return MMO->getOffset(); }
1090 /// Returns the TBAAInfo that describes the dereference.
1091 const MDNode *getTBAAInfo() const { return MMO->getTBAAInfo(); }
1093 /// Returns the Ranges that describes the dereference.
1094 const MDNode *getRanges() const { return MMO->getRanges(); }
1096 /// getMemoryVT - Return the type of the in-memory value.
1097 EVT getMemoryVT() const { return MemoryVT; }
1099 /// getMemOperand - Return a MachineMemOperand object describing the memory
1100 /// reference performed by operation.
1101 MachineMemOperand *getMemOperand() const { return MMO; }
1103 const MachinePointerInfo &getPointerInfo() const {
1104 return MMO->getPointerInfo();
1107 /// getAddressSpace - Return the address space for the associated pointer
1108 unsigned getAddressSpace() const {
1109 return getPointerInfo().getAddrSpace();
1112 /// refineAlignment - Update this MemSDNode's MachineMemOperand information
1113 /// to reflect the alignment of NewMMO, if it has a greater alignment.
1114 /// This must only be used when the new alignment applies to all users of
1115 /// this MachineMemOperand.
1116 void refineAlignment(const MachineMemOperand *NewMMO) {
1117 MMO->refineAlignment(NewMMO);
1120 const SDValue &getChain() const { return getOperand(0); }
1121 const SDValue &getBasePtr() const {
1122 return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
1125 // Methods to support isa and dyn_cast
1126 static bool classof(const SDNode *N) {
1127 // For some targets, we lower some target intrinsics to a MemIntrinsicNode
1128 // with either an intrinsic or a target opcode.
1129 return N->getOpcode() == ISD::LOAD ||
1130 N->getOpcode() == ISD::STORE ||
1131 N->getOpcode() == ISD::PREFETCH ||
1132 N->getOpcode() == ISD::ATOMIC_CMP_SWAP ||
1133 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS ||
1134 N->getOpcode() == ISD::ATOMIC_SWAP ||
1135 N->getOpcode() == ISD::ATOMIC_LOAD_ADD ||
1136 N->getOpcode() == ISD::ATOMIC_LOAD_SUB ||
1137 N->getOpcode() == ISD::ATOMIC_LOAD_AND ||
1138 N->getOpcode() == ISD::ATOMIC_LOAD_OR ||
1139 N->getOpcode() == ISD::ATOMIC_LOAD_XOR ||
1140 N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1141 N->getOpcode() == ISD::ATOMIC_LOAD_MIN ||
1142 N->getOpcode() == ISD::ATOMIC_LOAD_MAX ||
1143 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1144 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX ||
1145 N->getOpcode() == ISD::ATOMIC_LOAD ||
1146 N->getOpcode() == ISD::ATOMIC_STORE ||
1147 N->isTargetMemoryOpcode();
1151 /// AtomicSDNode - A SDNode reprenting atomic operations.
1153 class AtomicSDNode : public MemSDNode {
1156 /// For cmpxchg instructions, the ordering requirements when a store does not
1158 AtomicOrdering FailureOrdering;
1160 void InitAtomic(AtomicOrdering SuccessOrdering,
1161 AtomicOrdering FailureOrdering,
1162 SynchronizationScope SynchScope) {
1163 // This must match encodeMemSDNodeFlags() in SelectionDAG.cpp.
1164 assert((SuccessOrdering & 15) == SuccessOrdering &&
1165 "Ordering may not require more than 4 bits!");
1166 assert((FailureOrdering & 15) == FailureOrdering &&
1167 "Ordering may not require more than 4 bits!");
1168 assert((SynchScope & 1) == SynchScope &&
1169 "SynchScope may not require more than 1 bit!");
1170 SubclassData |= SuccessOrdering << 8;
1171 SubclassData |= SynchScope << 12;
1172 this->FailureOrdering = FailureOrdering;
1173 assert(getSuccessOrdering() == SuccessOrdering &&
1174 "Ordering encoding error!");
1175 assert(getFailureOrdering() == FailureOrdering &&
1176 "Ordering encoding error!");
1177 assert(getSynchScope() == SynchScope && "Synch-scope encoding error!");
1181 // Opc: opcode for atomic
1182 // VTL: value type list
1183 // Chain: memory chain for operaand
1184 // Ptr: address to update as a SDValue
1185 // Cmp: compare value
1187 // SrcVal: address to update as a Value (used for MemOperand)
1188 // Align: alignment of memory
1189 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1190 EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp,
1191 MachineMemOperand *MMO, AtomicOrdering Ordering,
1192 SynchronizationScope SynchScope)
1193 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1194 InitAtomic(Ordering, Ordering, SynchScope);
1195 InitOperands(Ops, Chain, Ptr, Cmp, Swp);
1197 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1199 SDValue Chain, SDValue Ptr,
1200 SDValue Val, MachineMemOperand *MMO,
1201 AtomicOrdering Ordering, SynchronizationScope SynchScope)
1202 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1203 InitAtomic(Ordering, Ordering, SynchScope);
1204 InitOperands(Ops, Chain, Ptr, Val);
1206 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1208 SDValue Chain, SDValue Ptr,
1209 MachineMemOperand *MMO,
1210 AtomicOrdering Ordering, SynchronizationScope SynchScope)
1211 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1212 InitAtomic(Ordering, Ordering, SynchScope);
1213 InitOperands(Ops, Chain, Ptr);
1215 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT,
1216 const SDValue* AllOps, SDUse *DynOps, unsigned NumOps,
1217 MachineMemOperand *MMO,
1218 AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
1219 SynchronizationScope SynchScope)
1220 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1221 InitAtomic(SuccessOrdering, FailureOrdering, SynchScope);
1222 assert((DynOps || NumOps <= array_lengthof(Ops)) &&
1223 "Too many ops for internal storage!");
1224 InitOperands(DynOps ? DynOps : Ops, AllOps, NumOps);
1227 const SDValue &getBasePtr() const { return getOperand(1); }
1228 const SDValue &getVal() const { return getOperand(2); }
1230 AtomicOrdering getSuccessOrdering() const {
1231 return getOrdering();
1234 // Not quite enough room in SubclassData for everything, so failure gets its
1236 AtomicOrdering getFailureOrdering() const {
1237 return FailureOrdering;
1240 bool isCompareAndSwap() const {
1241 unsigned Op = getOpcode();
1242 return Op == ISD::ATOMIC_CMP_SWAP || Op == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS;
1245 // Methods to support isa and dyn_cast
1246 static bool classof(const SDNode *N) {
1247 return N->getOpcode() == ISD::ATOMIC_CMP_SWAP ||
1248 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS ||
1249 N->getOpcode() == ISD::ATOMIC_SWAP ||
1250 N->getOpcode() == ISD::ATOMIC_LOAD_ADD ||
1251 N->getOpcode() == ISD::ATOMIC_LOAD_SUB ||
1252 N->getOpcode() == ISD::ATOMIC_LOAD_AND ||
1253 N->getOpcode() == ISD::ATOMIC_LOAD_OR ||
1254 N->getOpcode() == ISD::ATOMIC_LOAD_XOR ||
1255 N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1256 N->getOpcode() == ISD::ATOMIC_LOAD_MIN ||
1257 N->getOpcode() == ISD::ATOMIC_LOAD_MAX ||
1258 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1259 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX ||
1260 N->getOpcode() == ISD::ATOMIC_LOAD ||
1261 N->getOpcode() == ISD::ATOMIC_STORE;
1265 /// MemIntrinsicSDNode - This SDNode is used for target intrinsics that touch
1266 /// memory and need an associated MachineMemOperand. Its opcode may be
1267 /// INTRINSIC_VOID, INTRINSIC_W_CHAIN, PREFETCH, or a target-specific opcode
1268 /// with a value not less than FIRST_TARGET_MEMORY_OPCODE.
1269 class MemIntrinsicSDNode : public MemSDNode {
1271 MemIntrinsicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1272 ArrayRef<SDValue> Ops, EVT MemoryVT,
1273 MachineMemOperand *MMO)
1274 : MemSDNode(Opc, Order, dl, VTs, Ops, MemoryVT, MMO) {
1277 // Methods to support isa and dyn_cast
1278 static bool classof(const SDNode *N) {
1279 // We lower some target intrinsics to their target opcode
1280 // early a node with a target opcode can be of this class
1281 return N->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1282 N->getOpcode() == ISD::INTRINSIC_VOID ||
1283 N->getOpcode() == ISD::PREFETCH ||
1284 N->isTargetMemoryOpcode();
1288 /// ShuffleVectorSDNode - This SDNode is used to implement the code generator
1289 /// support for the llvm IR shufflevector instruction. It combines elements
1290 /// from two input vectors into a new input vector, with the selection and
1291 /// ordering of elements determined by an array of integers, referred to as
1292 /// the shuffle mask. For input vectors of width N, mask indices of 0..N-1
1293 /// refer to elements from the LHS input, and indices from N to 2N-1 the RHS.
1294 /// An index of -1 is treated as undef, such that the code generator may put
1295 /// any value in the corresponding element of the result.
1296 class ShuffleVectorSDNode : public SDNode {
1299 // The memory for Mask is owned by the SelectionDAG's OperandAllocator, and
1300 // is freed when the SelectionDAG object is destroyed.
1303 friend class SelectionDAG;
1304 ShuffleVectorSDNode(EVT VT, unsigned Order, DebugLoc dl, SDValue N1,
1305 SDValue N2, const int *M)
1306 : SDNode(ISD::VECTOR_SHUFFLE, Order, dl, getSDVTList(VT)), Mask(M) {
1307 InitOperands(Ops, N1, N2);
1311 ArrayRef<int> getMask() const {
1312 EVT VT = getValueType(0);
1313 return makeArrayRef(Mask, VT.getVectorNumElements());
1315 int getMaskElt(unsigned Idx) const {
1316 assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!");
1320 bool isSplat() const { return isSplatMask(Mask, getValueType(0)); }
1321 int getSplatIndex() const {
1322 assert(isSplat() && "Cannot get splat index for non-splat!");
1323 EVT VT = getValueType(0);
1324 for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
1328 llvm_unreachable("Splat with all undef indices?");
1330 static bool isSplatMask(const int *Mask, EVT VT);
1332 static bool classof(const SDNode *N) {
1333 return N->getOpcode() == ISD::VECTOR_SHUFFLE;
1337 class ConstantSDNode : public SDNode {
1338 const ConstantInt *Value;
1339 friend class SelectionDAG;
1340 ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, EVT VT)
1341 : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant,
1342 0, DebugLoc(), getSDVTList(VT)), Value(val) {
1343 SubclassData |= (uint16_t)isOpaque;
1347 const ConstantInt *getConstantIntValue() const { return Value; }
1348 const APInt &getAPIntValue() const { return Value->getValue(); }
1349 uint64_t getZExtValue() const { return Value->getZExtValue(); }
1350 int64_t getSExtValue() const { return Value->getSExtValue(); }
1352 bool isOne() const { return Value->isOne(); }
1353 bool isNullValue() const { return Value->isNullValue(); }
1354 bool isAllOnesValue() const { return Value->isAllOnesValue(); }
1356 bool isOpaque() const { return SubclassData & 1; }
1358 static bool classof(const SDNode *N) {
1359 return N->getOpcode() == ISD::Constant ||
1360 N->getOpcode() == ISD::TargetConstant;
1364 class ConstantFPSDNode : public SDNode {
1365 const ConstantFP *Value;
1366 friend class SelectionDAG;
1367 ConstantFPSDNode(bool isTarget, const ConstantFP *val, EVT VT)
1368 : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
1369 0, DebugLoc(), getSDVTList(VT)), Value(val) {
1373 const APFloat& getValueAPF() const { return Value->getValueAPF(); }
1374 const ConstantFP *getConstantFPValue() const { return Value; }
1376 /// isZero - Return true if the value is positive or negative zero.
1377 bool isZero() const { return Value->isZero(); }
1379 /// isNaN - Return true if the value is a NaN.
1380 bool isNaN() const { return Value->isNaN(); }
1382 /// isExactlyValue - We don't rely on operator== working on double values, as
1383 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1384 /// As such, this method can be used to do an exact bit-for-bit comparison of
1385 /// two floating point values.
1387 /// We leave the version with the double argument here because it's just so
1388 /// convenient to write "2.0" and the like. Without this function we'd
1389 /// have to duplicate its logic everywhere it's called.
1390 bool isExactlyValue(double V) const {
1393 Tmp.convert(Value->getValueAPF().getSemantics(),
1394 APFloat::rmNearestTiesToEven, &ignored);
1395 return isExactlyValue(Tmp);
1397 bool isExactlyValue(const APFloat& V) const;
1399 static bool isValueValidForType(EVT VT, const APFloat& Val);
1401 static bool classof(const SDNode *N) {
1402 return N->getOpcode() == ISD::ConstantFP ||
1403 N->getOpcode() == ISD::TargetConstantFP;
1407 class GlobalAddressSDNode : public SDNode {
1408 const GlobalValue *TheGlobal;
1410 unsigned char TargetFlags;
1411 friend class SelectionDAG;
1412 GlobalAddressSDNode(unsigned Opc, unsigned Order, DebugLoc DL,
1413 const GlobalValue *GA, EVT VT, int64_t o,
1414 unsigned char TargetFlags);
1417 const GlobalValue *getGlobal() const { return TheGlobal; }
1418 int64_t getOffset() const { return Offset; }
1419 unsigned char getTargetFlags() const { return TargetFlags; }
1420 // Return the address space this GlobalAddress belongs to.
1421 unsigned getAddressSpace() const;
1423 static bool classof(const SDNode *N) {
1424 return N->getOpcode() == ISD::GlobalAddress ||
1425 N->getOpcode() == ISD::TargetGlobalAddress ||
1426 N->getOpcode() == ISD::GlobalTLSAddress ||
1427 N->getOpcode() == ISD::TargetGlobalTLSAddress;
1431 class FrameIndexSDNode : public SDNode {
1433 friend class SelectionDAG;
1434 FrameIndexSDNode(int fi, EVT VT, bool isTarg)
1435 : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex,
1436 0, DebugLoc(), getSDVTList(VT)), FI(fi) {
1440 int getIndex() const { return FI; }
1442 static bool classof(const SDNode *N) {
1443 return N->getOpcode() == ISD::FrameIndex ||
1444 N->getOpcode() == ISD::TargetFrameIndex;
1448 class JumpTableSDNode : public SDNode {
1450 unsigned char TargetFlags;
1451 friend class SelectionDAG;
1452 JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF)
1453 : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable,
1454 0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) {
1458 int getIndex() const { return JTI; }
1459 unsigned char getTargetFlags() const { return TargetFlags; }
1461 static bool classof(const SDNode *N) {
1462 return N->getOpcode() == ISD::JumpTable ||
1463 N->getOpcode() == ISD::TargetJumpTable;
1467 class ConstantPoolSDNode : public SDNode {
1469 const Constant *ConstVal;
1470 MachineConstantPoolValue *MachineCPVal;
1472 int Offset; // It's a MachineConstantPoolValue if top bit is set.
1473 unsigned Alignment; // Minimum alignment requirement of CP (not log2 value).
1474 unsigned char TargetFlags;
1475 friend class SelectionDAG;
1476 ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o,
1477 unsigned Align, unsigned char TF)
1478 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
1479 DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align),
1481 assert(Offset >= 0 && "Offset is too large");
1484 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1485 EVT VT, int o, unsigned Align, unsigned char TF)
1486 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
1487 DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align),
1489 assert(Offset >= 0 && "Offset is too large");
1490 Val.MachineCPVal = v;
1491 Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1);
1495 bool isMachineConstantPoolEntry() const {
1499 const Constant *getConstVal() const {
1500 assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1501 return Val.ConstVal;
1504 MachineConstantPoolValue *getMachineCPVal() const {
1505 assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1506 return Val.MachineCPVal;
1509 int getOffset() const {
1510 return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1));
1513 // Return the alignment of this constant pool object, which is either 0 (for
1514 // default alignment) or the desired value.
1515 unsigned getAlignment() const { return Alignment; }
1516 unsigned char getTargetFlags() const { return TargetFlags; }
1518 Type *getType() const;
1520 static bool classof(const SDNode *N) {
1521 return N->getOpcode() == ISD::ConstantPool ||
1522 N->getOpcode() == ISD::TargetConstantPool;
1526 /// Completely target-dependent object reference.
1527 class TargetIndexSDNode : public SDNode {
1528 unsigned char TargetFlags;
1531 friend class SelectionDAG;
1534 TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF)
1535 : SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)),
1536 TargetFlags(TF), Index(Idx), Offset(Ofs) {}
1539 unsigned char getTargetFlags() const { return TargetFlags; }
1540 int getIndex() const { return Index; }
1541 int64_t getOffset() const { return Offset; }
1543 static bool classof(const SDNode *N) {
1544 return N->getOpcode() == ISD::TargetIndex;
1548 class BasicBlockSDNode : public SDNode {
1549 MachineBasicBlock *MBB;
1550 friend class SelectionDAG;
1551 /// Debug info is meaningful and potentially useful here, but we create
1552 /// blocks out of order when they're jumped to, which makes it a bit
1553 /// harder. Let's see if we need it first.
1554 explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1555 : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb)
1559 MachineBasicBlock *getBasicBlock() const { return MBB; }
1561 static bool classof(const SDNode *N) {
1562 return N->getOpcode() == ISD::BasicBlock;
1566 /// BuildVectorSDNode - A "pseudo-class" with methods for operating on
1568 class BuildVectorSDNode : public SDNode {
1569 // These are constructed as SDNodes and then cast to BuildVectorSDNodes.
1570 explicit BuildVectorSDNode() LLVM_DELETED_FUNCTION;
1572 /// isConstantSplat - Check if this is a constant splat, and if so, find the
1573 /// smallest element size that splats the vector. If MinSplatBits is
1574 /// nonzero, the element size must be at least that large. Note that the
1575 /// splat element may be the entire vector (i.e., a one element vector).
1576 /// Returns the splat element value in SplatValue. Any undefined bits in
1577 /// that value are zero, and the corresponding bits in the SplatUndef mask
1578 /// are set. The SplatBitSize value is set to the splat element size in
1579 /// bits. HasAnyUndefs is set to true if any bits in the vector are
1580 /// undefined. isBigEndian describes the endianness of the target.
1581 bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef,
1582 unsigned &SplatBitSize, bool &HasAnyUndefs,
1583 unsigned MinSplatBits = 0,
1584 bool isBigEndian = false) const;
1586 /// getConstantSplatValue - Check if this is a constant splat, and if so,
1587 /// return the splatted value. Otherwise return a null SDValue. This is
1588 /// a simpler form of isConstantSplat. Get the constant splat only if you
1589 /// care about the splat value.
1590 SDValue getConstantSplatValue() const;
1592 bool isConstant() const;
1594 static inline bool classof(const SDNode *N) {
1595 return N->getOpcode() == ISD::BUILD_VECTOR;
1599 /// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
1600 /// used when the SelectionDAG needs to make a simple reference to something
1601 /// in the LLVM IR representation.
1603 class SrcValueSDNode : public SDNode {
1605 friend class SelectionDAG;
1606 /// Create a SrcValue for a general value.
1607 explicit SrcValueSDNode(const Value *v)
1608 : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {}
1611 /// getValue - return the contained Value.
1612 const Value *getValue() const { return V; }
1614 static bool classof(const SDNode *N) {
1615 return N->getOpcode() == ISD::SRCVALUE;
1619 class MDNodeSDNode : public SDNode {
1621 friend class SelectionDAG;
1622 explicit MDNodeSDNode(const MDNode *md)
1623 : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md)
1627 const MDNode *getMD() const { return MD; }
1629 static bool classof(const SDNode *N) {
1630 return N->getOpcode() == ISD::MDNODE_SDNODE;
1634 class RegisterSDNode : public SDNode {
1636 friend class SelectionDAG;
1637 RegisterSDNode(unsigned reg, EVT VT)
1638 : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {
1642 unsigned getReg() const { return Reg; }
1644 static bool classof(const SDNode *N) {
1645 return N->getOpcode() == ISD::Register;
1649 class RegisterMaskSDNode : public SDNode {
1650 // The memory for RegMask is not owned by the node.
1651 const uint32_t *RegMask;
1652 friend class SelectionDAG;
1653 RegisterMaskSDNode(const uint32_t *mask)
1654 : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)),
1658 const uint32_t *getRegMask() const { return RegMask; }
1660 static bool classof(const SDNode *N) {
1661 return N->getOpcode() == ISD::RegisterMask;
1665 class BlockAddressSDNode : public SDNode {
1666 const BlockAddress *BA;
1668 unsigned char TargetFlags;
1669 friend class SelectionDAG;
1670 BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba,
1671 int64_t o, unsigned char Flags)
1672 : SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)),
1673 BA(ba), Offset(o), TargetFlags(Flags) {
1676 const BlockAddress *getBlockAddress() const { return BA; }
1677 int64_t getOffset() const { return Offset; }
1678 unsigned char getTargetFlags() const { return TargetFlags; }
1680 static bool classof(const SDNode *N) {
1681 return N->getOpcode() == ISD::BlockAddress ||
1682 N->getOpcode() == ISD::TargetBlockAddress;
1686 class EHLabelSDNode : public SDNode {
1689 friend class SelectionDAG;
1690 EHLabelSDNode(unsigned Order, DebugLoc dl, SDValue ch, MCSymbol *L)
1691 : SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {
1692 InitOperands(&Chain, ch);
1695 MCSymbol *getLabel() const { return Label; }
1697 static bool classof(const SDNode *N) {
1698 return N->getOpcode() == ISD::EH_LABEL;
1702 class ExternalSymbolSDNode : public SDNode {
1704 unsigned char TargetFlags;
1706 friend class SelectionDAG;
1707 ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT)
1708 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
1709 0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) {
1713 const char *getSymbol() const { return Symbol; }
1714 unsigned char getTargetFlags() const { return TargetFlags; }
1716 static bool classof(const SDNode *N) {
1717 return N->getOpcode() == ISD::ExternalSymbol ||
1718 N->getOpcode() == ISD::TargetExternalSymbol;
1722 class CondCodeSDNode : public SDNode {
1723 ISD::CondCode Condition;
1724 friend class SelectionDAG;
1725 explicit CondCodeSDNode(ISD::CondCode Cond)
1726 : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)),
1731 ISD::CondCode get() const { return Condition; }
1733 static bool classof(const SDNode *N) {
1734 return N->getOpcode() == ISD::CONDCODE;
1738 /// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the
1739 /// future and most targets don't support it.
1740 class CvtRndSatSDNode : public SDNode {
1741 ISD::CvtCode CvtCode;
1742 friend class SelectionDAG;
1743 explicit CvtRndSatSDNode(EVT VT, unsigned Order, DebugLoc dl,
1744 ArrayRef<SDValue> Ops, ISD::CvtCode Code)
1745 : SDNode(ISD::CONVERT_RNDSAT, Order, dl, getSDVTList(VT), Ops),
1747 assert(Ops.size() == 5 && "wrong number of operations");
1750 ISD::CvtCode getCvtCode() const { return CvtCode; }
1752 static bool classof(const SDNode *N) {
1753 return N->getOpcode() == ISD::CONVERT_RNDSAT;
1757 /// VTSDNode - This class is used to represent EVT's, which are used
1758 /// to parameterize some operations.
1759 class VTSDNode : public SDNode {
1761 friend class SelectionDAG;
1762 explicit VTSDNode(EVT VT)
1763 : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)),
1768 EVT getVT() const { return ValueType; }
1770 static bool classof(const SDNode *N) {
1771 return N->getOpcode() == ISD::VALUETYPE;
1775 /// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
1777 class LSBaseSDNode : public MemSDNode {
1778 //! Operand array for load and store
1780 \note Moving this array to the base class captures more
1781 common functionality shared between LoadSDNode and
1786 LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, DebugLoc dl,
1787 SDValue *Operands, unsigned numOperands,
1788 SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT,
1789 MachineMemOperand *MMO)
1790 : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
1791 SubclassData |= AM << 2;
1792 assert(getAddressingMode() == AM && "MemIndexedMode encoding error!");
1793 InitOperands(Ops, Operands, numOperands);
1794 assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
1795 "Only indexed loads and stores have a non-undef offset operand");
1798 const SDValue &getOffset() const {
1799 return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
1802 /// getAddressingMode - Return the addressing mode for this load or store:
1803 /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
1804 ISD::MemIndexedMode getAddressingMode() const {
1805 return ISD::MemIndexedMode((SubclassData >> 2) & 7);
1808 /// isIndexed - Return true if this is a pre/post inc/dec load/store.
1809 bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
1811 /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
1812 bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
1814 static bool classof(const SDNode *N) {
1815 return N->getOpcode() == ISD::LOAD ||
1816 N->getOpcode() == ISD::STORE;
1820 /// LoadSDNode - This class is used to represent ISD::LOAD nodes.
1822 class LoadSDNode : public LSBaseSDNode {
1823 friend class SelectionDAG;
1824 LoadSDNode(SDValue *ChainPtrOff, unsigned Order, DebugLoc dl, SDVTList VTs,
1825 ISD::MemIndexedMode AM, ISD::LoadExtType ETy, EVT MemVT,
1826 MachineMemOperand *MMO)
1827 : LSBaseSDNode(ISD::LOAD, Order, dl, ChainPtrOff, 3, VTs, AM, MemVT, MMO) {
1828 SubclassData |= (unsigned short)ETy;
1829 assert(getExtensionType() == ETy && "LoadExtType encoding error!");
1830 assert(readMem() && "Load MachineMemOperand is not a load!");
1831 assert(!writeMem() && "Load MachineMemOperand is a store!");
1835 /// getExtensionType - Return whether this is a plain node,
1836 /// or one of the varieties of value-extending loads.
1837 ISD::LoadExtType getExtensionType() const {
1838 return ISD::LoadExtType(SubclassData & 3);
1841 const SDValue &getBasePtr() const { return getOperand(1); }
1842 const SDValue &getOffset() const { return getOperand(2); }
1844 static bool classof(const SDNode *N) {
1845 return N->getOpcode() == ISD::LOAD;
1849 /// StoreSDNode - This class is used to represent ISD::STORE nodes.
1851 class StoreSDNode : public LSBaseSDNode {
1852 friend class SelectionDAG;
1853 StoreSDNode(SDValue *ChainValuePtrOff, unsigned Order, DebugLoc dl,
1854 SDVTList VTs, ISD::MemIndexedMode AM, bool isTrunc, EVT MemVT,
1855 MachineMemOperand *MMO)
1856 : LSBaseSDNode(ISD::STORE, Order, dl, ChainValuePtrOff, 4,
1857 VTs, AM, MemVT, MMO) {
1858 SubclassData |= (unsigned short)isTrunc;
1859 assert(isTruncatingStore() == isTrunc && "isTrunc encoding error!");
1860 assert(!readMem() && "Store MachineMemOperand is a load!");
1861 assert(writeMem() && "Store MachineMemOperand is not a store!");
1865 /// isTruncatingStore - Return true if the op does a truncation before store.
1866 /// For integers this is the same as doing a TRUNCATE and storing the result.
1867 /// For floats, it is the same as doing an FP_ROUND and storing the result.
1868 bool isTruncatingStore() const { return SubclassData & 1; }
1870 const SDValue &getValue() const { return getOperand(1); }
1871 const SDValue &getBasePtr() const { return getOperand(2); }
1872 const SDValue &getOffset() const { return getOperand(3); }
1874 static bool classof(const SDNode *N) {
1875 return N->getOpcode() == ISD::STORE;
1879 /// MachineSDNode - An SDNode that represents everything that will be needed
1880 /// to construct a MachineInstr. These nodes are created during the
1881 /// instruction selection proper phase.
1883 class MachineSDNode : public SDNode {
1885 typedef MachineMemOperand **mmo_iterator;
1888 friend class SelectionDAG;
1889 MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc DL, SDVTList VTs)
1890 : SDNode(Opc, Order, DL, VTs), MemRefs(nullptr), MemRefsEnd(nullptr) {}
1892 /// LocalOperands - Operands for this instruction, if they fit here. If
1893 /// they don't, this field is unused.
1894 SDUse LocalOperands[4];
1896 /// MemRefs - Memory reference descriptions for this instruction.
1897 mmo_iterator MemRefs;
1898 mmo_iterator MemRefsEnd;
1901 mmo_iterator memoperands_begin() const { return MemRefs; }
1902 mmo_iterator memoperands_end() const { return MemRefsEnd; }
1903 bool memoperands_empty() const { return MemRefsEnd == MemRefs; }
1905 /// setMemRefs - Assign this MachineSDNodes's memory reference descriptor
1906 /// list. This does not transfer ownership.
1907 void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd) {
1908 for (mmo_iterator MMI = NewMemRefs, MME = NewMemRefsEnd; MMI != MME; ++MMI)
1909 assert(*MMI && "Null mem ref detected!");
1910 MemRefs = NewMemRefs;
1911 MemRefsEnd = NewMemRefsEnd;
1914 static bool classof(const SDNode *N) {
1915 return N->isMachineOpcode();
1919 class SDNodeIterator : public std::iterator<std::forward_iterator_tag,
1920 SDNode, ptrdiff_t> {
1924 SDNodeIterator(const SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
1926 bool operator==(const SDNodeIterator& x) const {
1927 return Operand == x.Operand;
1929 bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
1931 const SDNodeIterator &operator=(const SDNodeIterator &I) {
1932 assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
1933 Operand = I.Operand;
1937 pointer operator*() const {
1938 return Node->getOperand(Operand).getNode();
1940 pointer operator->() const { return operator*(); }
1942 SDNodeIterator& operator++() { // Preincrement
1946 SDNodeIterator operator++(int) { // Postincrement
1947 SDNodeIterator tmp = *this; ++*this; return tmp;
1949 size_t operator-(SDNodeIterator Other) const {
1950 assert(Node == Other.Node &&
1951 "Cannot compare iterators of two different nodes!");
1952 return Operand - Other.Operand;
1955 static SDNodeIterator begin(const SDNode *N) { return SDNodeIterator(N, 0); }
1956 static SDNodeIterator end (const SDNode *N) {
1957 return SDNodeIterator(N, N->getNumOperands());
1960 unsigned getOperand() const { return Operand; }
1961 const SDNode *getNode() const { return Node; }
1964 template <> struct GraphTraits<SDNode*> {
1965 typedef SDNode NodeType;
1966 typedef SDNodeIterator ChildIteratorType;
1967 static inline NodeType *getEntryNode(SDNode *N) { return N; }
1968 static inline ChildIteratorType child_begin(NodeType *N) {
1969 return SDNodeIterator::begin(N);
1971 static inline ChildIteratorType child_end(NodeType *N) {
1972 return SDNodeIterator::end(N);
1976 /// LargestSDNode - The largest SDNode class.
1978 typedef AtomicSDNode LargestSDNode;
1980 /// MostAlignedSDNode - The SDNode class with the greatest alignment
1983 typedef GlobalAddressSDNode MostAlignedSDNode;
1986 /// isNormalLoad - Returns true if the specified node is a non-extending
1987 /// and unindexed load.
1988 inline bool isNormalLoad(const SDNode *N) {
1989 const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
1990 return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
1991 Ld->getAddressingMode() == ISD::UNINDEXED;
1994 /// isNON_EXTLoad - Returns true if the specified node is a non-extending
1996 inline bool isNON_EXTLoad(const SDNode *N) {
1997 return isa<LoadSDNode>(N) &&
1998 cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
2001 /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
2003 inline bool isEXTLoad(const SDNode *N) {
2004 return isa<LoadSDNode>(N) &&
2005 cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
2008 /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
2010 inline bool isSEXTLoad(const SDNode *N) {
2011 return isa<LoadSDNode>(N) &&
2012 cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
2015 /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
2017 inline bool isZEXTLoad(const SDNode *N) {
2018 return isa<LoadSDNode>(N) &&
2019 cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
2022 /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
2024 inline bool isUNINDEXEDLoad(const SDNode *N) {
2025 return isa<LoadSDNode>(N) &&
2026 cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2029 /// isNormalStore - Returns true if the specified node is a non-truncating
2030 /// and unindexed store.
2031 inline bool isNormalStore(const SDNode *N) {
2032 const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
2033 return St && !St->isTruncatingStore() &&
2034 St->getAddressingMode() == ISD::UNINDEXED;
2037 /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
2039 inline bool isNON_TRUNCStore(const SDNode *N) {
2040 return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
2043 /// isTRUNCStore - Returns true if the specified node is a truncating
2045 inline bool isTRUNCStore(const SDNode *N) {
2046 return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
2049 /// isUNINDEXEDStore - Returns true if the specified node is an
2050 /// unindexed store.
2051 inline bool isUNINDEXEDStore(const SDNode *N) {
2052 return isa<StoreSDNode>(N) &&
2053 cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2057 } // end llvm namespace