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);
146 SDValue getValue(unsigned R) const {
147 return SDValue(Node, R);
150 // isOperandOf - Return true if this node is an operand of N.
151 bool isOperandOf(SDNode *N) const;
153 /// getValueType - Return the ValueType of the referenced return value.
155 inline EVT getValueType() const;
157 /// Return the simple ValueType of the referenced return value.
158 MVT getSimpleValueType() const {
159 return getValueType().getSimpleVT();
162 /// getValueSizeInBits - Returns the size of the value in bits.
164 unsigned getValueSizeInBits() const {
165 return getValueType().getSizeInBits();
168 unsigned getScalarValueSizeInBits() const {
169 return getValueType().getScalarType().getSizeInBits();
172 // Forwarding methods - These forward to the corresponding methods in SDNode.
173 inline unsigned getOpcode() const;
174 inline unsigned getNumOperands() const;
175 inline const SDValue &getOperand(unsigned i) const;
176 inline uint64_t getConstantOperandVal(unsigned i) const;
177 inline bool isTargetMemoryOpcode() const;
178 inline bool isTargetOpcode() const;
179 inline bool isMachineOpcode() const;
180 inline unsigned getMachineOpcode() const;
181 inline const DebugLoc getDebugLoc() const;
182 inline void dump() const;
183 inline void dumpr() const;
185 /// reachesChainWithoutSideEffects - Return true if this operand (which must
186 /// be a chain) reaches the specified operand without crossing any
187 /// side-effecting instructions. In practice, this looks through token
188 /// factors and non-volatile loads. In order to remain efficient, this only
189 /// looks a couple of nodes in, it does not do an exhaustive search.
190 bool reachesChainWithoutSideEffects(SDValue Dest,
191 unsigned Depth = 2) const;
193 /// use_empty - Return true if there are no nodes using value ResNo
196 inline bool use_empty() const;
198 /// hasOneUse - Return true if there is exactly one node using value
201 inline bool hasOneUse() const;
205 template<> struct DenseMapInfo<SDValue> {
206 static inline SDValue getEmptyKey() {
207 return SDValue((SDNode*)-1, -1U);
209 static inline SDValue getTombstoneKey() {
210 return SDValue((SDNode*)-1, 0);
212 static unsigned getHashValue(const SDValue &Val) {
213 return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
214 (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
216 static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
220 template <> struct isPodLike<SDValue> { static const bool value = true; };
223 /// simplify_type specializations - Allow casting operators to work directly on
224 /// SDValues as if they were SDNode*'s.
225 template<> struct simplify_type<SDValue> {
226 typedef SDNode* SimpleType;
227 static SimpleType getSimplifiedValue(SDValue &Val) {
228 return Val.getNode();
231 template<> struct simplify_type<const SDValue> {
232 typedef /*const*/ SDNode* SimpleType;
233 static SimpleType getSimplifiedValue(const SDValue &Val) {
234 return Val.getNode();
238 /// SDUse - Represents a use of a SDNode. This class holds an SDValue,
239 /// which records the SDNode being used and the result number, a
240 /// pointer to the SDNode using the value, and Next and Prev pointers,
241 /// which link together all the uses of an SDNode.
244 /// Val - The value being used.
246 /// User - The user of this value.
248 /// Prev, Next - Pointers to the uses list of the SDNode referred by
252 SDUse(const SDUse &U) LLVM_DELETED_FUNCTION;
253 void operator=(const SDUse &U) LLVM_DELETED_FUNCTION;
256 SDUse() : Val(), User(nullptr), Prev(nullptr), Next(nullptr) {}
258 /// Normally SDUse will just implicitly convert to an SDValue that it holds.
259 operator const SDValue&() const { return Val; }
261 /// If implicit conversion to SDValue doesn't work, the get() method returns
263 const SDValue &get() const { return Val; }
265 /// getUser - This returns the SDNode that contains this Use.
266 SDNode *getUser() { return User; }
268 /// getNext - Get the next SDUse in the use list.
269 SDUse *getNext() const { return Next; }
271 /// getNode - Convenience function for get().getNode().
272 SDNode *getNode() const { return Val.getNode(); }
273 /// getResNo - Convenience function for get().getResNo().
274 unsigned getResNo() const { return Val.getResNo(); }
275 /// getValueType - Convenience function for get().getValueType().
276 EVT getValueType() const { return Val.getValueType(); }
278 /// operator== - Convenience function for get().operator==
279 bool operator==(const SDValue &V) const {
283 /// operator!= - Convenience function for get().operator!=
284 bool operator!=(const SDValue &V) const {
288 /// operator< - Convenience function for get().operator<
289 bool operator<(const SDValue &V) const {
294 friend class SelectionDAG;
297 void setUser(SDNode *p) { User = p; }
299 /// set - Remove this use from its existing use list, assign it the
300 /// given value, and add it to the new value's node's use list.
301 inline void set(const SDValue &V);
302 /// setInitial - like set, but only supports initializing a newly-allocated
303 /// SDUse with a non-null value.
304 inline void setInitial(const SDValue &V);
305 /// setNode - like set, but only sets the Node portion of the value,
306 /// leaving the ResNo portion unmodified.
307 inline void setNode(SDNode *N);
309 void addToList(SDUse **List) {
311 if (Next) Next->Prev = &Next;
316 void removeFromList() {
318 if (Next) Next->Prev = Prev;
322 /// simplify_type specializations - Allow casting operators to work directly on
323 /// SDValues as if they were SDNode*'s.
324 template<> struct simplify_type<SDUse> {
325 typedef SDNode* SimpleType;
326 static SimpleType getSimplifiedValue(SDUse &Val) {
327 return Val.getNode();
332 /// SDNode - Represents one node in the SelectionDAG.
334 class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
336 /// NodeType - The operation that this node performs.
340 /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true,
341 /// then they will be delete[]'d when the node is destroyed.
342 uint16_t OperandsNeedDelete : 1;
344 /// HasDebugValue - This tracks whether this node has one or more dbg_value
345 /// nodes corresponding to it.
346 uint16_t HasDebugValue : 1;
349 /// SubclassData - This member is defined by this class, but is not used for
350 /// anything. Subclasses can use it to hold whatever state they find useful.
351 /// This field is initialized to zero by the ctor.
352 uint16_t SubclassData : 14;
355 /// NodeId - Unique id per SDNode in the DAG.
358 /// OperandList - The values that are used by this operation.
362 /// ValueList - The types of the values this node defines. SDNode's may
363 /// define multiple values simultaneously.
364 const EVT *ValueList;
366 /// UseList - List of uses for this SDNode.
369 /// NumOperands/NumValues - The number of entries in the Operand/Value list.
370 unsigned short NumOperands, NumValues;
372 /// debugLoc - source line information.
375 // The ordering of the SDNodes. It roughly corresponds to the ordering of the
376 // original LLVM instructions.
377 // This is used for turning off scheduling, because we'll forgo
378 // the normal scheduling algorithms and output the instructions according to
382 /// getValueTypeList - Return a pointer to the specified value type.
383 static const EVT *getValueTypeList(EVT VT);
385 friend class SelectionDAG;
386 friend struct ilist_traits<SDNode>;
389 //===--------------------------------------------------------------------===//
393 /// getOpcode - Return the SelectionDAG opcode value for this node. For
394 /// pre-isel nodes (those for which isMachineOpcode returns false), these
395 /// are the opcode values in the ISD and <target>ISD namespaces. For
396 /// post-isel opcodes, see getMachineOpcode.
397 unsigned getOpcode() const { return (unsigned short)NodeType; }
399 /// isTargetOpcode - Test if this node has a target-specific opcode (in the
400 /// \<target\>ISD namespace).
401 bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
403 /// isTargetMemoryOpcode - Test if this node has a target-specific
404 /// memory-referencing opcode (in the \<target\>ISD namespace and
405 /// greater than FIRST_TARGET_MEMORY_OPCODE).
406 bool isTargetMemoryOpcode() const {
407 return NodeType >= ISD::FIRST_TARGET_MEMORY_OPCODE;
410 /// isMachineOpcode - Test if this node has a post-isel opcode, directly
411 /// corresponding to a MachineInstr opcode.
412 bool isMachineOpcode() const { return NodeType < 0; }
414 /// getMachineOpcode - This may only be called if isMachineOpcode returns
415 /// true. It returns the MachineInstr opcode value that the node's opcode
417 unsigned getMachineOpcode() const {
418 assert(isMachineOpcode() && "Not a MachineInstr opcode!");
422 /// getHasDebugValue - get this bit.
423 bool getHasDebugValue() const { return HasDebugValue; }
425 /// setHasDebugValue - set this bit.
426 void setHasDebugValue(bool b) { HasDebugValue = b; }
428 /// use_empty - Return true if there are no uses of this node.
430 bool use_empty() const { return UseList == nullptr; }
432 /// hasOneUse - Return true if there is exactly one use of this node.
434 bool hasOneUse() const {
435 return !use_empty() && std::next(use_begin()) == use_end();
438 /// use_size - Return the number of uses of this node. This method takes
439 /// time proportional to the number of uses.
441 size_t use_size() const { return std::distance(use_begin(), use_end()); }
443 /// getNodeId - Return the unique node id.
445 int getNodeId() const { return NodeId; }
447 /// setNodeId - Set unique node id.
448 void setNodeId(int Id) { NodeId = Id; }
450 /// getIROrder - Return the node ordering.
452 unsigned getIROrder() const { return IROrder; }
454 /// setIROrder - Set the node ordering.
456 void setIROrder(unsigned Order) { IROrder = Order; }
458 /// getDebugLoc - Return the source location info.
459 const DebugLoc getDebugLoc() const { return debugLoc; }
461 /// setDebugLoc - Set source location info. Try to avoid this, putting
462 /// it in the constructor is preferable.
463 void setDebugLoc(const DebugLoc dl) { debugLoc = dl; }
465 /// use_iterator - This class provides iterator support for SDUse
466 /// operands that use a specific SDNode.
468 : public std::iterator<std::forward_iterator_tag, SDUse, ptrdiff_t> {
470 explicit use_iterator(SDUse *op) : Op(op) {
474 typedef std::iterator<std::forward_iterator_tag,
475 SDUse, ptrdiff_t>::reference reference;
476 typedef std::iterator<std::forward_iterator_tag,
477 SDUse, ptrdiff_t>::pointer pointer;
479 use_iterator(const use_iterator &I) : Op(I.Op) {}
480 use_iterator() : Op(nullptr) {}
482 bool operator==(const use_iterator &x) const {
485 bool operator!=(const use_iterator &x) const {
486 return !operator==(x);
489 /// atEnd - return true if this iterator is at the end of uses list.
490 bool atEnd() const { return Op == nullptr; }
492 // Iterator traversal: forward iteration only.
493 use_iterator &operator++() { // Preincrement
494 assert(Op && "Cannot increment end iterator!");
499 use_iterator operator++(int) { // Postincrement
500 use_iterator tmp = *this; ++*this; return tmp;
503 /// Retrieve a pointer to the current user node.
504 SDNode *operator*() const {
505 assert(Op && "Cannot dereference end iterator!");
506 return Op->getUser();
509 SDNode *operator->() const { return operator*(); }
511 SDUse &getUse() const { return *Op; }
513 /// getOperandNo - Retrieve the operand # of this use in its user.
515 unsigned getOperandNo() const {
516 assert(Op && "Cannot dereference end iterator!");
517 return (unsigned)(Op - Op->getUser()->OperandList);
521 /// use_begin/use_end - Provide iteration support to walk over all uses
524 use_iterator use_begin() const {
525 return use_iterator(UseList);
528 static use_iterator use_end() { return use_iterator(nullptr); }
530 inline iterator_range<use_iterator> uses() {
531 return iterator_range<use_iterator>(use_begin(), use_end());
533 inline iterator_range<use_iterator> uses() const {
534 return iterator_range<use_iterator>(use_begin(), use_end());
537 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
538 /// indicated value. This method ignores uses of other values defined by this
540 bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
542 /// hasAnyUseOfValue - Return true if there are any use of the indicated
543 /// value. This method ignores uses of other values defined by this operation.
544 bool hasAnyUseOfValue(unsigned Value) const;
546 /// isOnlyUserOf - Return true if this node is the only use of N.
548 bool isOnlyUserOf(SDNode *N) const;
550 /// isOperandOf - Return true if this node is an operand of N.
552 bool isOperandOf(SDNode *N) const;
554 /// isPredecessorOf - Return true if this node is a predecessor of N.
555 /// NOTE: Implemented on top of hasPredecessor and every bit as
556 /// expensive. Use carefully.
557 bool isPredecessorOf(const SDNode *N) const {
558 return N->hasPredecessor(this);
561 /// hasPredecessor - Return true if N is a predecessor of this node.
562 /// N is either an operand of this node, or can be reached by recursively
563 /// traversing up the operands.
564 /// NOTE: This is an expensive method. Use it carefully.
565 bool hasPredecessor(const SDNode *N) const;
567 /// hasPredecesorHelper - Return true if N is a predecessor of this node.
568 /// N is either an operand of this node, or can be reached by recursively
569 /// traversing up the operands.
570 /// In this helper the Visited and worklist sets are held externally to
571 /// cache predecessors over multiple invocations. If you want to test for
572 /// multiple predecessors this method is preferable to multiple calls to
573 /// hasPredecessor. Be sure to clear Visited and Worklist if the DAG
575 /// NOTE: This is still very expensive. Use carefully.
576 bool hasPredecessorHelper(const SDNode *N,
577 SmallPtrSet<const SDNode *, 32> &Visited,
578 SmallVectorImpl<const SDNode *> &Worklist) const;
580 /// getNumOperands - Return the number of values used by this operation.
582 unsigned getNumOperands() const { return NumOperands; }
584 /// getConstantOperandVal - Helper method returns the integer value of a
585 /// ConstantSDNode operand.
586 uint64_t getConstantOperandVal(unsigned Num) const;
588 const SDValue &getOperand(unsigned Num) const {
589 assert(Num < NumOperands && "Invalid child # of SDNode!");
590 return OperandList[Num];
593 typedef SDUse* op_iterator;
594 op_iterator op_begin() const { return OperandList; }
595 op_iterator op_end() const { return OperandList+NumOperands; }
597 SDVTList getVTList() const {
598 SDVTList X = { ValueList, NumValues };
602 /// getGluedNode - If this node has a glue operand, return the node
603 /// to which the glue operand points. Otherwise return NULL.
604 SDNode *getGluedNode() const {
605 if (getNumOperands() != 0 &&
606 getOperand(getNumOperands()-1).getValueType() == MVT::Glue)
607 return getOperand(getNumOperands()-1).getNode();
611 // If this is a pseudo op, like copyfromreg, look to see if there is a
612 // real target node glued to it. If so, return the target node.
613 const SDNode *getGluedMachineNode() const {
614 const SDNode *FoundNode = this;
616 // Climb up glue edges until a machine-opcode node is found, or the
617 // end of the chain is reached.
618 while (!FoundNode->isMachineOpcode()) {
619 const SDNode *N = FoundNode->getGluedNode();
627 /// getGluedUser - If this node has a glue value with a user, return
628 /// the user (there is at most one). Otherwise return NULL.
629 SDNode *getGluedUser() const {
630 for (use_iterator UI = use_begin(), UE = use_end(); UI != UE; ++UI)
631 if (UI.getUse().get().getValueType() == MVT::Glue)
636 /// getNumValues - Return the number of values defined/returned by this
639 unsigned getNumValues() const { return NumValues; }
641 /// getValueType - Return the type of a specified result.
643 EVT getValueType(unsigned ResNo) const {
644 assert(ResNo < NumValues && "Illegal result number!");
645 return ValueList[ResNo];
648 /// Return the type of a specified result as a simple type.
650 MVT getSimpleValueType(unsigned ResNo) const {
651 return getValueType(ResNo).getSimpleVT();
654 /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
656 unsigned getValueSizeInBits(unsigned ResNo) const {
657 return getValueType(ResNo).getSizeInBits();
660 typedef const EVT* value_iterator;
661 value_iterator value_begin() const { return ValueList; }
662 value_iterator value_end() const { return ValueList+NumValues; }
664 /// getOperationName - Return the opcode of this operation for printing.
666 std::string getOperationName(const SelectionDAG *G = nullptr) const;
667 static const char* getIndexedModeName(ISD::MemIndexedMode AM);
668 void print_types(raw_ostream &OS, const SelectionDAG *G) const;
669 void print_details(raw_ostream &OS, const SelectionDAG *G) const;
670 void print(raw_ostream &OS, const SelectionDAG *G = nullptr) const;
671 void printr(raw_ostream &OS, const SelectionDAG *G = nullptr) const;
673 /// printrFull - Print a SelectionDAG node and all children down to
674 /// the leaves. The given SelectionDAG allows target-specific nodes
675 /// to be printed in human-readable form. Unlike printr, this will
676 /// print the whole DAG, including children that appear multiple
679 void printrFull(raw_ostream &O, const SelectionDAG *G = nullptr) const;
681 /// printrWithDepth - Print a SelectionDAG node and children up to
682 /// depth "depth." The given SelectionDAG allows target-specific
683 /// nodes to be printed in human-readable form. Unlike printr, this
684 /// will print children that appear multiple times wherever they are
687 void printrWithDepth(raw_ostream &O, const SelectionDAG *G = nullptr,
688 unsigned depth = 100) const;
691 /// dump - Dump this node, for debugging.
694 /// dumpr - Dump (recursively) this node and its use-def subgraph.
697 /// dump - Dump this node, for debugging.
698 /// The given SelectionDAG allows target-specific nodes to be printed
699 /// in human-readable form.
700 void dump(const SelectionDAG *G) const;
702 /// dumpr - Dump (recursively) this node and its use-def subgraph.
703 /// The given SelectionDAG allows target-specific nodes to be printed
704 /// in human-readable form.
705 void dumpr(const SelectionDAG *G) const;
707 /// dumprFull - printrFull to dbgs(). The given SelectionDAG allows
708 /// target-specific nodes to be printed in human-readable form.
709 /// Unlike dumpr, this will print the whole DAG, including children
710 /// that appear multiple times.
712 void dumprFull(const SelectionDAG *G = nullptr) const;
714 /// dumprWithDepth - printrWithDepth to dbgs(). The given
715 /// SelectionDAG allows target-specific nodes to be printed in
716 /// human-readable form. Unlike dumpr, this will print children
717 /// that appear multiple times wherever they are used.
719 void dumprWithDepth(const SelectionDAG *G = nullptr,
720 unsigned depth = 100) const;
722 /// Profile - Gather unique data for the node.
724 void Profile(FoldingSetNodeID &ID) const;
726 /// addUse - This method should only be used by the SDUse class.
728 void addUse(SDUse &U) { U.addToList(&UseList); }
731 static SDVTList getSDVTList(EVT VT) {
732 SDVTList Ret = { getValueTypeList(VT), 1 };
736 SDNode(unsigned Opc, unsigned Order, const DebugLoc dl, SDVTList VTs,
737 ArrayRef<SDValue> Ops)
738 : NodeType(Opc), OperandsNeedDelete(true), HasDebugValue(false),
739 SubclassData(0), NodeId(-1),
740 OperandList(Ops.size() ? new SDUse[Ops.size()] : nullptr),
741 ValueList(VTs.VTs), UseList(nullptr),
742 NumOperands(Ops.size()), NumValues(VTs.NumVTs),
743 debugLoc(dl), IROrder(Order) {
744 for (unsigned i = 0; i != Ops.size(); ++i) {
745 OperandList[i].setUser(this);
746 OperandList[i].setInitial(Ops[i]);
748 checkForCycles(this);
751 /// This constructor adds no operands itself; operands can be
752 /// set later with InitOperands.
753 SDNode(unsigned Opc, unsigned Order, const DebugLoc dl, SDVTList VTs)
754 : NodeType(Opc), OperandsNeedDelete(false), HasDebugValue(false),
755 SubclassData(0), NodeId(-1), OperandList(nullptr), ValueList(VTs.VTs),
756 UseList(nullptr), NumOperands(0), NumValues(VTs.NumVTs), debugLoc(dl),
759 /// InitOperands - Initialize the operands list of this with 1 operand.
760 void InitOperands(SDUse *Ops, const SDValue &Op0) {
761 Ops[0].setUser(this);
762 Ops[0].setInitial(Op0);
765 checkForCycles(this);
768 /// InitOperands - Initialize the operands list of this with 2 operands.
769 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) {
770 Ops[0].setUser(this);
771 Ops[0].setInitial(Op0);
772 Ops[1].setUser(this);
773 Ops[1].setInitial(Op1);
776 checkForCycles(this);
779 /// InitOperands - Initialize the operands list of this with 3 operands.
780 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
781 const SDValue &Op2) {
782 Ops[0].setUser(this);
783 Ops[0].setInitial(Op0);
784 Ops[1].setUser(this);
785 Ops[1].setInitial(Op1);
786 Ops[2].setUser(this);
787 Ops[2].setInitial(Op2);
790 checkForCycles(this);
793 /// InitOperands - Initialize the operands list of this with 4 operands.
794 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
795 const SDValue &Op2, const SDValue &Op3) {
796 Ops[0].setUser(this);
797 Ops[0].setInitial(Op0);
798 Ops[1].setUser(this);
799 Ops[1].setInitial(Op1);
800 Ops[2].setUser(this);
801 Ops[2].setInitial(Op2);
802 Ops[3].setUser(this);
803 Ops[3].setInitial(Op3);
806 checkForCycles(this);
809 /// InitOperands - Initialize the operands list of this with N operands.
810 void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) {
811 for (unsigned i = 0; i != N; ++i) {
812 Ops[i].setUser(this);
813 Ops[i].setInitial(Vals[i]);
817 checkForCycles(this);
820 /// DropOperands - Release the operands and set this node to have
825 /// Wrapper class for IR location info (IR ordering and DebugLoc) to be passed
826 /// into SDNode creation functions.
827 /// When an SDNode is created from the DAGBuilder, the DebugLoc is extracted
828 /// from the original Instruction, and IROrder is the ordinal position of
830 /// When an SDNode is created after the DAG is being built, both DebugLoc and
831 /// the IROrder are propagated from the original SDNode.
832 /// So SDLoc class provides two constructors besides the default one, one to
833 /// be used by the DAGBuilder, the other to be used by others.
836 // Ptr could be used for either Instruction* or SDNode*. It is used for
837 // Instruction* if IROrder is not -1.
842 SDLoc() : Ptr(nullptr), IROrder(0) {}
843 SDLoc(const SDNode *N) : Ptr(N), IROrder(-1) {
844 assert(N && "null SDNode");
846 SDLoc(const SDValue V) : Ptr(V.getNode()), IROrder(-1) {
847 assert(Ptr && "null SDNode");
849 SDLoc(const Instruction *I, int Order) : Ptr(I), IROrder(Order) {
850 assert(Order >= 0 && "bad IROrder");
852 unsigned getIROrder() {
853 if (IROrder >= 0 || Ptr == nullptr) {
854 return (unsigned)IROrder;
856 const SDNode *N = (const SDNode*)(Ptr);
857 return N->getIROrder();
859 DebugLoc getDebugLoc() {
864 const Instruction *I = (const Instruction*)(Ptr);
865 return I->getDebugLoc();
867 const SDNode *N = (const SDNode*)(Ptr);
868 return N->getDebugLoc();
873 // Define inline functions from the SDValue class.
875 inline unsigned SDValue::getOpcode() const {
876 return Node->getOpcode();
878 inline EVT SDValue::getValueType() const {
879 return Node->getValueType(ResNo);
881 inline unsigned SDValue::getNumOperands() const {
882 return Node->getNumOperands();
884 inline const SDValue &SDValue::getOperand(unsigned i) const {
885 return Node->getOperand(i);
887 inline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
888 return Node->getConstantOperandVal(i);
890 inline bool SDValue::isTargetOpcode() const {
891 return Node->isTargetOpcode();
893 inline bool SDValue::isTargetMemoryOpcode() const {
894 return Node->isTargetMemoryOpcode();
896 inline bool SDValue::isMachineOpcode() const {
897 return Node->isMachineOpcode();
899 inline unsigned SDValue::getMachineOpcode() const {
900 return Node->getMachineOpcode();
902 inline bool SDValue::use_empty() const {
903 return !Node->hasAnyUseOfValue(ResNo);
905 inline bool SDValue::hasOneUse() const {
906 return Node->hasNUsesOfValue(1, ResNo);
908 inline const DebugLoc SDValue::getDebugLoc() const {
909 return Node->getDebugLoc();
911 inline void SDValue::dump() const {
914 inline void SDValue::dumpr() const {
915 return Node->dumpr();
917 // Define inline functions from the SDUse class.
919 inline void SDUse::set(const SDValue &V) {
920 if (Val.getNode()) removeFromList();
922 if (V.getNode()) V.getNode()->addUse(*this);
925 inline void SDUse::setInitial(const SDValue &V) {
927 V.getNode()->addUse(*this);
930 inline void SDUse::setNode(SDNode *N) {
931 if (Val.getNode()) removeFromList();
933 if (N) N->addUse(*this);
936 /// UnarySDNode - This class is used for single-operand SDNodes. This is solely
937 /// to allow co-allocation of node operands with the node itself.
938 class UnarySDNode : public SDNode {
941 UnarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
943 : SDNode(Opc, Order, dl, VTs) {
944 InitOperands(&Op, X);
948 /// BinarySDNode - This class is used for two-operand SDNodes. This is solely
949 /// to allow co-allocation of node operands with the node itself.
950 class BinarySDNode : public SDNode {
953 BinarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
954 SDValue X, SDValue Y)
955 : SDNode(Opc, Order, dl, VTs) {
956 InitOperands(Ops, X, Y);
960 /// BinaryWithFlagsSDNode - This class is an extension of BinarySDNode
961 /// used from those opcodes that have associated extra flags.
962 class BinaryWithFlagsSDNode : public BinarySDNode {
963 enum { NUW = (1 << 0), NSW = (1 << 1), EXACT = (1 << 2) };
966 BinaryWithFlagsSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
967 SDValue X, SDValue Y)
968 : BinarySDNode(Opc, Order, dl, VTs, X, Y) {}
969 /// getRawSubclassData - Return the SubclassData value, which contains an
970 /// encoding of the flags.
971 /// This function should be used to add subclass data to the NodeID value.
972 unsigned getRawSubclassData() const { return SubclassData; }
973 void setHasNoUnsignedWrap(bool b) {
974 SubclassData = (SubclassData & ~NUW) | (b ? NUW : 0);
976 void setHasNoSignedWrap(bool b) {
977 SubclassData = (SubclassData & ~NSW) | (b ? NSW : 0);
979 void setIsExact(bool b) {
980 SubclassData = (SubclassData & ~EXACT) | (b ? EXACT : 0);
982 bool hasNoUnsignedWrap() const { return SubclassData & NUW; }
983 bool hasNoSignedWrap() const { return SubclassData & NSW; }
984 bool isExact() const { return SubclassData & EXACT; }
985 static bool classof(const SDNode *N) {
986 return isBinOpWithFlags(N->getOpcode());
990 /// TernarySDNode - This class is used for three-operand SDNodes. This is solely
991 /// to allow co-allocation of node operands with the node itself.
992 class TernarySDNode : public SDNode {
995 TernarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
996 SDValue X, SDValue Y, SDValue Z)
997 : SDNode(Opc, Order, dl, VTs) {
998 InitOperands(Ops, X, Y, Z);
1003 /// HandleSDNode - This class is used to form a handle around another node that
1004 /// is persistent and is updated across invocations of replaceAllUsesWith on its
1005 /// operand. This node should be directly created by end-users and not added to
1006 /// the AllNodes list.
1007 class HandleSDNode : public SDNode {
1010 explicit HandleSDNode(SDValue X)
1011 : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) {
1012 InitOperands(&Op, X);
1015 const SDValue &getValue() const { return Op; }
1018 class AddrSpaceCastSDNode : public UnarySDNode {
1020 unsigned SrcAddrSpace;
1021 unsigned DestAddrSpace;
1024 AddrSpaceCastSDNode(unsigned Order, DebugLoc dl, EVT VT, SDValue X,
1025 unsigned SrcAS, unsigned DestAS);
1027 unsigned getSrcAddressSpace() const { return SrcAddrSpace; }
1028 unsigned getDestAddressSpace() const { return DestAddrSpace; }
1030 static bool classof(const SDNode *N) {
1031 return N->getOpcode() == ISD::ADDRSPACECAST;
1035 /// Abstact virtual class for operations for memory operations
1036 class MemSDNode : public SDNode {
1038 // MemoryVT - VT of in-memory value.
1042 /// MMO - Memory reference information.
1043 MachineMemOperand *MMO;
1046 MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1047 EVT MemoryVT, MachineMemOperand *MMO);
1049 MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1050 ArrayRef<SDValue> Ops, EVT MemoryVT, MachineMemOperand *MMO);
1052 bool readMem() const { return MMO->isLoad(); }
1053 bool writeMem() const { return MMO->isStore(); }
1055 /// Returns alignment and volatility of the memory access
1056 unsigned getOriginalAlignment() const {
1057 return MMO->getBaseAlignment();
1059 unsigned getAlignment() const {
1060 return MMO->getAlignment();
1063 /// getRawSubclassData - Return the SubclassData value, which contains an
1064 /// encoding of the volatile flag, as well as bits used by subclasses. This
1065 /// function should only be used to compute a FoldingSetNodeID value.
1066 unsigned getRawSubclassData() const {
1067 return SubclassData;
1070 // We access subclass data here so that we can check consistency
1071 // with MachineMemOperand information.
1072 bool isVolatile() const { return (SubclassData >> 5) & 1; }
1073 bool isNonTemporal() const { return (SubclassData >> 6) & 1; }
1074 bool isInvariant() const { return (SubclassData >> 7) & 1; }
1076 AtomicOrdering getOrdering() const {
1077 return AtomicOrdering((SubclassData >> 8) & 15);
1079 SynchronizationScope getSynchScope() const {
1080 return SynchronizationScope((SubclassData >> 12) & 1);
1083 // Returns the offset from the location of the access.
1084 int64_t getSrcValueOffset() const { return MMO->getOffset(); }
1086 /// Returns the TBAAInfo that describes the dereference.
1087 const MDNode *getTBAAInfo() const { return MMO->getTBAAInfo(); }
1089 /// Returns the Ranges that describes the dereference.
1090 const MDNode *getRanges() const { return MMO->getRanges(); }
1092 /// getMemoryVT - Return the type of the in-memory value.
1093 EVT getMemoryVT() const { return MemoryVT; }
1095 /// getMemOperand - Return a MachineMemOperand object describing the memory
1096 /// reference performed by operation.
1097 MachineMemOperand *getMemOperand() const { return MMO; }
1099 const MachinePointerInfo &getPointerInfo() const {
1100 return MMO->getPointerInfo();
1103 /// getAddressSpace - Return the address space for the associated pointer
1104 unsigned getAddressSpace() const {
1105 return getPointerInfo().getAddrSpace();
1108 /// refineAlignment - Update this MemSDNode's MachineMemOperand information
1109 /// to reflect the alignment of NewMMO, if it has a greater alignment.
1110 /// This must only be used when the new alignment applies to all users of
1111 /// this MachineMemOperand.
1112 void refineAlignment(const MachineMemOperand *NewMMO) {
1113 MMO->refineAlignment(NewMMO);
1116 const SDValue &getChain() const { return getOperand(0); }
1117 const SDValue &getBasePtr() const {
1118 return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
1121 // Methods to support isa and dyn_cast
1122 static bool classof(const SDNode *N) {
1123 // For some targets, we lower some target intrinsics to a MemIntrinsicNode
1124 // with either an intrinsic or a target opcode.
1125 return N->getOpcode() == ISD::LOAD ||
1126 N->getOpcode() == ISD::STORE ||
1127 N->getOpcode() == ISD::PREFETCH ||
1128 N->getOpcode() == ISD::ATOMIC_CMP_SWAP ||
1129 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS ||
1130 N->getOpcode() == ISD::ATOMIC_SWAP ||
1131 N->getOpcode() == ISD::ATOMIC_LOAD_ADD ||
1132 N->getOpcode() == ISD::ATOMIC_LOAD_SUB ||
1133 N->getOpcode() == ISD::ATOMIC_LOAD_AND ||
1134 N->getOpcode() == ISD::ATOMIC_LOAD_OR ||
1135 N->getOpcode() == ISD::ATOMIC_LOAD_XOR ||
1136 N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1137 N->getOpcode() == ISD::ATOMIC_LOAD_MIN ||
1138 N->getOpcode() == ISD::ATOMIC_LOAD_MAX ||
1139 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1140 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX ||
1141 N->getOpcode() == ISD::ATOMIC_LOAD ||
1142 N->getOpcode() == ISD::ATOMIC_STORE ||
1143 N->isTargetMemoryOpcode();
1147 /// AtomicSDNode - A SDNode reprenting atomic operations.
1149 class AtomicSDNode : public MemSDNode {
1152 /// For cmpxchg instructions, the ordering requirements when a store does not
1154 AtomicOrdering FailureOrdering;
1156 void InitAtomic(AtomicOrdering SuccessOrdering,
1157 AtomicOrdering FailureOrdering,
1158 SynchronizationScope SynchScope) {
1159 // This must match encodeMemSDNodeFlags() in SelectionDAG.cpp.
1160 assert((SuccessOrdering & 15) == SuccessOrdering &&
1161 "Ordering may not require more than 4 bits!");
1162 assert((FailureOrdering & 15) == FailureOrdering &&
1163 "Ordering may not require more than 4 bits!");
1164 assert((SynchScope & 1) == SynchScope &&
1165 "SynchScope may not require more than 1 bit!");
1166 SubclassData |= SuccessOrdering << 8;
1167 SubclassData |= SynchScope << 12;
1168 this->FailureOrdering = FailureOrdering;
1169 assert(getSuccessOrdering() == SuccessOrdering &&
1170 "Ordering encoding error!");
1171 assert(getFailureOrdering() == FailureOrdering &&
1172 "Ordering encoding error!");
1173 assert(getSynchScope() == SynchScope && "Synch-scope encoding error!");
1177 // Opc: opcode for atomic
1178 // VTL: value type list
1179 // Chain: memory chain for operaand
1180 // Ptr: address to update as a SDValue
1181 // Cmp: compare value
1183 // SrcVal: address to update as a Value (used for MemOperand)
1184 // Align: alignment of memory
1185 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1186 EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp,
1187 MachineMemOperand *MMO, AtomicOrdering Ordering,
1188 SynchronizationScope SynchScope)
1189 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1190 InitAtomic(Ordering, Ordering, SynchScope);
1191 InitOperands(Ops, Chain, Ptr, Cmp, Swp);
1193 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1195 SDValue Chain, SDValue Ptr,
1196 SDValue Val, MachineMemOperand *MMO,
1197 AtomicOrdering Ordering, SynchronizationScope SynchScope)
1198 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1199 InitAtomic(Ordering, Ordering, SynchScope);
1200 InitOperands(Ops, Chain, Ptr, Val);
1202 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1204 SDValue Chain, SDValue Ptr,
1205 MachineMemOperand *MMO,
1206 AtomicOrdering Ordering, SynchronizationScope SynchScope)
1207 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1208 InitAtomic(Ordering, Ordering, SynchScope);
1209 InitOperands(Ops, Chain, Ptr);
1211 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT,
1212 const SDValue* AllOps, SDUse *DynOps, unsigned NumOps,
1213 MachineMemOperand *MMO,
1214 AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
1215 SynchronizationScope SynchScope)
1216 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1217 InitAtomic(SuccessOrdering, FailureOrdering, SynchScope);
1218 assert((DynOps || NumOps <= array_lengthof(Ops)) &&
1219 "Too many ops for internal storage!");
1220 InitOperands(DynOps ? DynOps : Ops, AllOps, NumOps);
1223 const SDValue &getBasePtr() const { return getOperand(1); }
1224 const SDValue &getVal() const { return getOperand(2); }
1226 AtomicOrdering getSuccessOrdering() const {
1227 return getOrdering();
1230 // Not quite enough room in SubclassData for everything, so failure gets its
1232 AtomicOrdering getFailureOrdering() const {
1233 return FailureOrdering;
1236 bool isCompareAndSwap() const {
1237 unsigned Op = getOpcode();
1238 return Op == ISD::ATOMIC_CMP_SWAP || Op == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS;
1241 // Methods to support isa and dyn_cast
1242 static bool classof(const SDNode *N) {
1243 return N->getOpcode() == ISD::ATOMIC_CMP_SWAP ||
1244 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS ||
1245 N->getOpcode() == ISD::ATOMIC_SWAP ||
1246 N->getOpcode() == ISD::ATOMIC_LOAD_ADD ||
1247 N->getOpcode() == ISD::ATOMIC_LOAD_SUB ||
1248 N->getOpcode() == ISD::ATOMIC_LOAD_AND ||
1249 N->getOpcode() == ISD::ATOMIC_LOAD_OR ||
1250 N->getOpcode() == ISD::ATOMIC_LOAD_XOR ||
1251 N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1252 N->getOpcode() == ISD::ATOMIC_LOAD_MIN ||
1253 N->getOpcode() == ISD::ATOMIC_LOAD_MAX ||
1254 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1255 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX ||
1256 N->getOpcode() == ISD::ATOMIC_LOAD ||
1257 N->getOpcode() == ISD::ATOMIC_STORE;
1261 /// MemIntrinsicSDNode - This SDNode is used for target intrinsics that touch
1262 /// memory and need an associated MachineMemOperand. Its opcode may be
1263 /// INTRINSIC_VOID, INTRINSIC_W_CHAIN, PREFETCH, or a target-specific opcode
1264 /// with a value not less than FIRST_TARGET_MEMORY_OPCODE.
1265 class MemIntrinsicSDNode : public MemSDNode {
1267 MemIntrinsicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1268 ArrayRef<SDValue> Ops, EVT MemoryVT,
1269 MachineMemOperand *MMO)
1270 : MemSDNode(Opc, Order, dl, VTs, Ops, MemoryVT, MMO) {
1273 // Methods to support isa and dyn_cast
1274 static bool classof(const SDNode *N) {
1275 // We lower some target intrinsics to their target opcode
1276 // early a node with a target opcode can be of this class
1277 return N->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1278 N->getOpcode() == ISD::INTRINSIC_VOID ||
1279 N->getOpcode() == ISD::PREFETCH ||
1280 N->isTargetMemoryOpcode();
1284 /// ShuffleVectorSDNode - This SDNode is used to implement the code generator
1285 /// support for the llvm IR shufflevector instruction. It combines elements
1286 /// from two input vectors into a new input vector, with the selection and
1287 /// ordering of elements determined by an array of integers, referred to as
1288 /// the shuffle mask. For input vectors of width N, mask indices of 0..N-1
1289 /// refer to elements from the LHS input, and indices from N to 2N-1 the RHS.
1290 /// An index of -1 is treated as undef, such that the code generator may put
1291 /// any value in the corresponding element of the result.
1292 class ShuffleVectorSDNode : public SDNode {
1295 // The memory for Mask is owned by the SelectionDAG's OperandAllocator, and
1296 // is freed when the SelectionDAG object is destroyed.
1299 friend class SelectionDAG;
1300 ShuffleVectorSDNode(EVT VT, unsigned Order, DebugLoc dl, SDValue N1,
1301 SDValue N2, const int *M)
1302 : SDNode(ISD::VECTOR_SHUFFLE, Order, dl, getSDVTList(VT)), Mask(M) {
1303 InitOperands(Ops, N1, N2);
1307 ArrayRef<int> getMask() const {
1308 EVT VT = getValueType(0);
1309 return makeArrayRef(Mask, VT.getVectorNumElements());
1311 int getMaskElt(unsigned Idx) const {
1312 assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!");
1316 bool isSplat() const { return isSplatMask(Mask, getValueType(0)); }
1317 int getSplatIndex() const {
1318 assert(isSplat() && "Cannot get splat index for non-splat!");
1319 EVT VT = getValueType(0);
1320 for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
1324 llvm_unreachable("Splat with all undef indices?");
1326 static bool isSplatMask(const int *Mask, EVT VT);
1328 static bool classof(const SDNode *N) {
1329 return N->getOpcode() == ISD::VECTOR_SHUFFLE;
1333 class ConstantSDNode : public SDNode {
1334 const ConstantInt *Value;
1335 friend class SelectionDAG;
1336 ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, EVT VT)
1337 : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant,
1338 0, DebugLoc(), getSDVTList(VT)), Value(val) {
1339 SubclassData |= (uint16_t)isOpaque;
1343 const ConstantInt *getConstantIntValue() const { return Value; }
1344 const APInt &getAPIntValue() const { return Value->getValue(); }
1345 uint64_t getZExtValue() const { return Value->getZExtValue(); }
1346 int64_t getSExtValue() const { return Value->getSExtValue(); }
1348 bool isOne() const { return Value->isOne(); }
1349 bool isNullValue() const { return Value->isNullValue(); }
1350 bool isAllOnesValue() const { return Value->isAllOnesValue(); }
1352 bool isOpaque() const { return SubclassData & 1; }
1354 static bool classof(const SDNode *N) {
1355 return N->getOpcode() == ISD::Constant ||
1356 N->getOpcode() == ISD::TargetConstant;
1360 class ConstantFPSDNode : public SDNode {
1361 const ConstantFP *Value;
1362 friend class SelectionDAG;
1363 ConstantFPSDNode(bool isTarget, const ConstantFP *val, EVT VT)
1364 : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
1365 0, DebugLoc(), getSDVTList(VT)), Value(val) {
1369 const APFloat& getValueAPF() const { return Value->getValueAPF(); }
1370 const ConstantFP *getConstantFPValue() const { return Value; }
1372 /// isZero - Return true if the value is positive or negative zero.
1373 bool isZero() const { return Value->isZero(); }
1375 /// isNaN - Return true if the value is a NaN.
1376 bool isNaN() const { return Value->isNaN(); }
1378 /// isExactlyValue - We don't rely on operator== working on double values, as
1379 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1380 /// As such, this method can be used to do an exact bit-for-bit comparison of
1381 /// two floating point values.
1383 /// We leave the version with the double argument here because it's just so
1384 /// convenient to write "2.0" and the like. Without this function we'd
1385 /// have to duplicate its logic everywhere it's called.
1386 bool isExactlyValue(double V) const {
1389 Tmp.convert(Value->getValueAPF().getSemantics(),
1390 APFloat::rmNearestTiesToEven, &ignored);
1391 return isExactlyValue(Tmp);
1393 bool isExactlyValue(const APFloat& V) const;
1395 static bool isValueValidForType(EVT VT, const APFloat& Val);
1397 static bool classof(const SDNode *N) {
1398 return N->getOpcode() == ISD::ConstantFP ||
1399 N->getOpcode() == ISD::TargetConstantFP;
1403 class GlobalAddressSDNode : public SDNode {
1404 const GlobalValue *TheGlobal;
1406 unsigned char TargetFlags;
1407 friend class SelectionDAG;
1408 GlobalAddressSDNode(unsigned Opc, unsigned Order, DebugLoc DL,
1409 const GlobalValue *GA, EVT VT, int64_t o,
1410 unsigned char TargetFlags);
1413 const GlobalValue *getGlobal() const { return TheGlobal; }
1414 int64_t getOffset() const { return Offset; }
1415 unsigned char getTargetFlags() const { return TargetFlags; }
1416 // Return the address space this GlobalAddress belongs to.
1417 unsigned getAddressSpace() const;
1419 static bool classof(const SDNode *N) {
1420 return N->getOpcode() == ISD::GlobalAddress ||
1421 N->getOpcode() == ISD::TargetGlobalAddress ||
1422 N->getOpcode() == ISD::GlobalTLSAddress ||
1423 N->getOpcode() == ISD::TargetGlobalTLSAddress;
1427 class FrameIndexSDNode : public SDNode {
1429 friend class SelectionDAG;
1430 FrameIndexSDNode(int fi, EVT VT, bool isTarg)
1431 : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex,
1432 0, DebugLoc(), getSDVTList(VT)), FI(fi) {
1436 int getIndex() const { return FI; }
1438 static bool classof(const SDNode *N) {
1439 return N->getOpcode() == ISD::FrameIndex ||
1440 N->getOpcode() == ISD::TargetFrameIndex;
1444 class JumpTableSDNode : public SDNode {
1446 unsigned char TargetFlags;
1447 friend class SelectionDAG;
1448 JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF)
1449 : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable,
1450 0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) {
1454 int getIndex() const { return JTI; }
1455 unsigned char getTargetFlags() const { return TargetFlags; }
1457 static bool classof(const SDNode *N) {
1458 return N->getOpcode() == ISD::JumpTable ||
1459 N->getOpcode() == ISD::TargetJumpTable;
1463 class ConstantPoolSDNode : public SDNode {
1465 const Constant *ConstVal;
1466 MachineConstantPoolValue *MachineCPVal;
1468 int Offset; // It's a MachineConstantPoolValue if top bit is set.
1469 unsigned Alignment; // Minimum alignment requirement of CP (not log2 value).
1470 unsigned char TargetFlags;
1471 friend class SelectionDAG;
1472 ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o,
1473 unsigned Align, unsigned char TF)
1474 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
1475 DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align),
1477 assert(Offset >= 0 && "Offset is too large");
1480 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1481 EVT VT, int o, unsigned Align, unsigned char TF)
1482 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
1483 DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align),
1485 assert(Offset >= 0 && "Offset is too large");
1486 Val.MachineCPVal = v;
1487 Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1);
1491 bool isMachineConstantPoolEntry() const {
1495 const Constant *getConstVal() const {
1496 assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1497 return Val.ConstVal;
1500 MachineConstantPoolValue *getMachineCPVal() const {
1501 assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1502 return Val.MachineCPVal;
1505 int getOffset() const {
1506 return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1));
1509 // Return the alignment of this constant pool object, which is either 0 (for
1510 // default alignment) or the desired value.
1511 unsigned getAlignment() const { return Alignment; }
1512 unsigned char getTargetFlags() const { return TargetFlags; }
1514 Type *getType() const;
1516 static bool classof(const SDNode *N) {
1517 return N->getOpcode() == ISD::ConstantPool ||
1518 N->getOpcode() == ISD::TargetConstantPool;
1522 /// Completely target-dependent object reference.
1523 class TargetIndexSDNode : public SDNode {
1524 unsigned char TargetFlags;
1527 friend class SelectionDAG;
1530 TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF)
1531 : SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)),
1532 TargetFlags(TF), Index(Idx), Offset(Ofs) {}
1535 unsigned char getTargetFlags() const { return TargetFlags; }
1536 int getIndex() const { return Index; }
1537 int64_t getOffset() const { return Offset; }
1539 static bool classof(const SDNode *N) {
1540 return N->getOpcode() == ISD::TargetIndex;
1544 class BasicBlockSDNode : public SDNode {
1545 MachineBasicBlock *MBB;
1546 friend class SelectionDAG;
1547 /// Debug info is meaningful and potentially useful here, but we create
1548 /// blocks out of order when they're jumped to, which makes it a bit
1549 /// harder. Let's see if we need it first.
1550 explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1551 : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb)
1555 MachineBasicBlock *getBasicBlock() const { return MBB; }
1557 static bool classof(const SDNode *N) {
1558 return N->getOpcode() == ISD::BasicBlock;
1562 /// BuildVectorSDNode - A "pseudo-class" with methods for operating on
1564 class BuildVectorSDNode : public SDNode {
1565 // These are constructed as SDNodes and then cast to BuildVectorSDNodes.
1566 explicit BuildVectorSDNode() LLVM_DELETED_FUNCTION;
1568 /// isConstantSplat - Check if this is a constant splat, and if so, find the
1569 /// smallest element size that splats the vector. If MinSplatBits is
1570 /// nonzero, the element size must be at least that large. Note that the
1571 /// splat element may be the entire vector (i.e., a one element vector).
1572 /// Returns the splat element value in SplatValue. Any undefined bits in
1573 /// that value are zero, and the corresponding bits in the SplatUndef mask
1574 /// are set. The SplatBitSize value is set to the splat element size in
1575 /// bits. HasAnyUndefs is set to true if any bits in the vector are
1576 /// undefined. isBigEndian describes the endianness of the target.
1577 bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef,
1578 unsigned &SplatBitSize, bool &HasAnyUndefs,
1579 unsigned MinSplatBits = 0,
1580 bool isBigEndian = false) const;
1582 /// getConstantSplatValue - Check if this is a constant splat, and if so,
1583 /// return the splat value only if it is a ConstantSDNode. Otherwise
1584 /// return nullptr. This is a simpler form of isConstantSplat.
1585 /// Get the constant splat only if you care about the splat value.
1586 ConstantSDNode *getConstantSplatValue() const;
1588 bool isConstant() const;
1590 static inline bool classof(const SDNode *N) {
1591 return N->getOpcode() == ISD::BUILD_VECTOR;
1595 /// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
1596 /// used when the SelectionDAG needs to make a simple reference to something
1597 /// in the LLVM IR representation.
1599 class SrcValueSDNode : public SDNode {
1601 friend class SelectionDAG;
1602 /// Create a SrcValue for a general value.
1603 explicit SrcValueSDNode(const Value *v)
1604 : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {}
1607 /// getValue - return the contained Value.
1608 const Value *getValue() const { return V; }
1610 static bool classof(const SDNode *N) {
1611 return N->getOpcode() == ISD::SRCVALUE;
1615 class MDNodeSDNode : public SDNode {
1617 friend class SelectionDAG;
1618 explicit MDNodeSDNode(const MDNode *md)
1619 : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md)
1623 const MDNode *getMD() const { return MD; }
1625 static bool classof(const SDNode *N) {
1626 return N->getOpcode() == ISD::MDNODE_SDNODE;
1630 class RegisterSDNode : public SDNode {
1632 friend class SelectionDAG;
1633 RegisterSDNode(unsigned reg, EVT VT)
1634 : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {
1638 unsigned getReg() const { return Reg; }
1640 static bool classof(const SDNode *N) {
1641 return N->getOpcode() == ISD::Register;
1645 class RegisterMaskSDNode : public SDNode {
1646 // The memory for RegMask is not owned by the node.
1647 const uint32_t *RegMask;
1648 friend class SelectionDAG;
1649 RegisterMaskSDNode(const uint32_t *mask)
1650 : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)),
1654 const uint32_t *getRegMask() const { return RegMask; }
1656 static bool classof(const SDNode *N) {
1657 return N->getOpcode() == ISD::RegisterMask;
1661 class BlockAddressSDNode : public SDNode {
1662 const BlockAddress *BA;
1664 unsigned char TargetFlags;
1665 friend class SelectionDAG;
1666 BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba,
1667 int64_t o, unsigned char Flags)
1668 : SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)),
1669 BA(ba), Offset(o), TargetFlags(Flags) {
1672 const BlockAddress *getBlockAddress() const { return BA; }
1673 int64_t getOffset() const { return Offset; }
1674 unsigned char getTargetFlags() const { return TargetFlags; }
1676 static bool classof(const SDNode *N) {
1677 return N->getOpcode() == ISD::BlockAddress ||
1678 N->getOpcode() == ISD::TargetBlockAddress;
1682 class EHLabelSDNode : public SDNode {
1685 friend class SelectionDAG;
1686 EHLabelSDNode(unsigned Order, DebugLoc dl, SDValue ch, MCSymbol *L)
1687 : SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {
1688 InitOperands(&Chain, ch);
1691 MCSymbol *getLabel() const { return Label; }
1693 static bool classof(const SDNode *N) {
1694 return N->getOpcode() == ISD::EH_LABEL;
1698 class ExternalSymbolSDNode : public SDNode {
1700 unsigned char TargetFlags;
1702 friend class SelectionDAG;
1703 ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT)
1704 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
1705 0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) {
1709 const char *getSymbol() const { return Symbol; }
1710 unsigned char getTargetFlags() const { return TargetFlags; }
1712 static bool classof(const SDNode *N) {
1713 return N->getOpcode() == ISD::ExternalSymbol ||
1714 N->getOpcode() == ISD::TargetExternalSymbol;
1718 class CondCodeSDNode : public SDNode {
1719 ISD::CondCode Condition;
1720 friend class SelectionDAG;
1721 explicit CondCodeSDNode(ISD::CondCode Cond)
1722 : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)),
1727 ISD::CondCode get() const { return Condition; }
1729 static bool classof(const SDNode *N) {
1730 return N->getOpcode() == ISD::CONDCODE;
1734 /// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the
1735 /// future and most targets don't support it.
1736 class CvtRndSatSDNode : public SDNode {
1737 ISD::CvtCode CvtCode;
1738 friend class SelectionDAG;
1739 explicit CvtRndSatSDNode(EVT VT, unsigned Order, DebugLoc dl,
1740 ArrayRef<SDValue> Ops, ISD::CvtCode Code)
1741 : SDNode(ISD::CONVERT_RNDSAT, Order, dl, getSDVTList(VT), Ops),
1743 assert(Ops.size() == 5 && "wrong number of operations");
1746 ISD::CvtCode getCvtCode() const { return CvtCode; }
1748 static bool classof(const SDNode *N) {
1749 return N->getOpcode() == ISD::CONVERT_RNDSAT;
1753 /// VTSDNode - This class is used to represent EVT's, which are used
1754 /// to parameterize some operations.
1755 class VTSDNode : public SDNode {
1757 friend class SelectionDAG;
1758 explicit VTSDNode(EVT VT)
1759 : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)),
1764 EVT getVT() const { return ValueType; }
1766 static bool classof(const SDNode *N) {
1767 return N->getOpcode() == ISD::VALUETYPE;
1771 /// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
1773 class LSBaseSDNode : public MemSDNode {
1774 //! Operand array for load and store
1776 \note Moving this array to the base class captures more
1777 common functionality shared between LoadSDNode and
1782 LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, DebugLoc dl,
1783 SDValue *Operands, unsigned numOperands,
1784 SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT,
1785 MachineMemOperand *MMO)
1786 : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
1787 SubclassData |= AM << 2;
1788 assert(getAddressingMode() == AM && "MemIndexedMode encoding error!");
1789 InitOperands(Ops, Operands, numOperands);
1790 assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
1791 "Only indexed loads and stores have a non-undef offset operand");
1794 const SDValue &getOffset() const {
1795 return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
1798 /// getAddressingMode - Return the addressing mode for this load or store:
1799 /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
1800 ISD::MemIndexedMode getAddressingMode() const {
1801 return ISD::MemIndexedMode((SubclassData >> 2) & 7);
1804 /// isIndexed - Return true if this is a pre/post inc/dec load/store.
1805 bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
1807 /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
1808 bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
1810 static bool classof(const SDNode *N) {
1811 return N->getOpcode() == ISD::LOAD ||
1812 N->getOpcode() == ISD::STORE;
1816 /// LoadSDNode - This class is used to represent ISD::LOAD nodes.
1818 class LoadSDNode : public LSBaseSDNode {
1819 friend class SelectionDAG;
1820 LoadSDNode(SDValue *ChainPtrOff, unsigned Order, DebugLoc dl, SDVTList VTs,
1821 ISD::MemIndexedMode AM, ISD::LoadExtType ETy, EVT MemVT,
1822 MachineMemOperand *MMO)
1823 : LSBaseSDNode(ISD::LOAD, Order, dl, ChainPtrOff, 3, VTs, AM, MemVT, MMO) {
1824 SubclassData |= (unsigned short)ETy;
1825 assert(getExtensionType() == ETy && "LoadExtType encoding error!");
1826 assert(readMem() && "Load MachineMemOperand is not a load!");
1827 assert(!writeMem() && "Load MachineMemOperand is a store!");
1831 /// getExtensionType - Return whether this is a plain node,
1832 /// or one of the varieties of value-extending loads.
1833 ISD::LoadExtType getExtensionType() const {
1834 return ISD::LoadExtType(SubclassData & 3);
1837 const SDValue &getBasePtr() const { return getOperand(1); }
1838 const SDValue &getOffset() const { return getOperand(2); }
1840 static bool classof(const SDNode *N) {
1841 return N->getOpcode() == ISD::LOAD;
1845 /// StoreSDNode - This class is used to represent ISD::STORE nodes.
1847 class StoreSDNode : public LSBaseSDNode {
1848 friend class SelectionDAG;
1849 StoreSDNode(SDValue *ChainValuePtrOff, unsigned Order, DebugLoc dl,
1850 SDVTList VTs, ISD::MemIndexedMode AM, bool isTrunc, EVT MemVT,
1851 MachineMemOperand *MMO)
1852 : LSBaseSDNode(ISD::STORE, Order, dl, ChainValuePtrOff, 4,
1853 VTs, AM, MemVT, MMO) {
1854 SubclassData |= (unsigned short)isTrunc;
1855 assert(isTruncatingStore() == isTrunc && "isTrunc encoding error!");
1856 assert(!readMem() && "Store MachineMemOperand is a load!");
1857 assert(writeMem() && "Store MachineMemOperand is not a store!");
1861 /// isTruncatingStore - Return true if the op does a truncation before store.
1862 /// For integers this is the same as doing a TRUNCATE and storing the result.
1863 /// For floats, it is the same as doing an FP_ROUND and storing the result.
1864 bool isTruncatingStore() const { return SubclassData & 1; }
1866 const SDValue &getValue() const { return getOperand(1); }
1867 const SDValue &getBasePtr() const { return getOperand(2); }
1868 const SDValue &getOffset() const { return getOperand(3); }
1870 static bool classof(const SDNode *N) {
1871 return N->getOpcode() == ISD::STORE;
1875 /// MachineSDNode - An SDNode that represents everything that will be needed
1876 /// to construct a MachineInstr. These nodes are created during the
1877 /// instruction selection proper phase.
1879 class MachineSDNode : public SDNode {
1881 typedef MachineMemOperand **mmo_iterator;
1884 friend class SelectionDAG;
1885 MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc DL, SDVTList VTs)
1886 : SDNode(Opc, Order, DL, VTs), MemRefs(nullptr), MemRefsEnd(nullptr) {}
1888 /// LocalOperands - Operands for this instruction, if they fit here. If
1889 /// they don't, this field is unused.
1890 SDUse LocalOperands[4];
1892 /// MemRefs - Memory reference descriptions for this instruction.
1893 mmo_iterator MemRefs;
1894 mmo_iterator MemRefsEnd;
1897 mmo_iterator memoperands_begin() const { return MemRefs; }
1898 mmo_iterator memoperands_end() const { return MemRefsEnd; }
1899 bool memoperands_empty() const { return MemRefsEnd == MemRefs; }
1901 /// setMemRefs - Assign this MachineSDNodes's memory reference descriptor
1902 /// list. This does not transfer ownership.
1903 void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd) {
1904 for (mmo_iterator MMI = NewMemRefs, MME = NewMemRefsEnd; MMI != MME; ++MMI)
1905 assert(*MMI && "Null mem ref detected!");
1906 MemRefs = NewMemRefs;
1907 MemRefsEnd = NewMemRefsEnd;
1910 static bool classof(const SDNode *N) {
1911 return N->isMachineOpcode();
1915 class SDNodeIterator : public std::iterator<std::forward_iterator_tag,
1916 SDNode, ptrdiff_t> {
1920 SDNodeIterator(const SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
1922 bool operator==(const SDNodeIterator& x) const {
1923 return Operand == x.Operand;
1925 bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
1927 const SDNodeIterator &operator=(const SDNodeIterator &I) {
1928 assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
1929 Operand = I.Operand;
1933 pointer operator*() const {
1934 return Node->getOperand(Operand).getNode();
1936 pointer operator->() const { return operator*(); }
1938 SDNodeIterator& operator++() { // Preincrement
1942 SDNodeIterator operator++(int) { // Postincrement
1943 SDNodeIterator tmp = *this; ++*this; return tmp;
1945 size_t operator-(SDNodeIterator Other) const {
1946 assert(Node == Other.Node &&
1947 "Cannot compare iterators of two different nodes!");
1948 return Operand - Other.Operand;
1951 static SDNodeIterator begin(const SDNode *N) { return SDNodeIterator(N, 0); }
1952 static SDNodeIterator end (const SDNode *N) {
1953 return SDNodeIterator(N, N->getNumOperands());
1956 unsigned getOperand() const { return Operand; }
1957 const SDNode *getNode() const { return Node; }
1960 template <> struct GraphTraits<SDNode*> {
1961 typedef SDNode NodeType;
1962 typedef SDNodeIterator ChildIteratorType;
1963 static inline NodeType *getEntryNode(SDNode *N) { return N; }
1964 static inline ChildIteratorType child_begin(NodeType *N) {
1965 return SDNodeIterator::begin(N);
1967 static inline ChildIteratorType child_end(NodeType *N) {
1968 return SDNodeIterator::end(N);
1972 /// LargestSDNode - The largest SDNode class.
1974 typedef AtomicSDNode LargestSDNode;
1976 /// MostAlignedSDNode - The SDNode class with the greatest alignment
1979 typedef GlobalAddressSDNode MostAlignedSDNode;
1982 /// isNormalLoad - Returns true if the specified node is a non-extending
1983 /// and unindexed load.
1984 inline bool isNormalLoad(const SDNode *N) {
1985 const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
1986 return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
1987 Ld->getAddressingMode() == ISD::UNINDEXED;
1990 /// isNON_EXTLoad - Returns true if the specified node is a non-extending
1992 inline bool isNON_EXTLoad(const SDNode *N) {
1993 return isa<LoadSDNode>(N) &&
1994 cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
1997 /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
1999 inline bool isEXTLoad(const SDNode *N) {
2000 return isa<LoadSDNode>(N) &&
2001 cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
2004 /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
2006 inline bool isSEXTLoad(const SDNode *N) {
2007 return isa<LoadSDNode>(N) &&
2008 cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
2011 /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
2013 inline bool isZEXTLoad(const SDNode *N) {
2014 return isa<LoadSDNode>(N) &&
2015 cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
2018 /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
2020 inline bool isUNINDEXEDLoad(const SDNode *N) {
2021 return isa<LoadSDNode>(N) &&
2022 cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2025 /// isNormalStore - Returns true if the specified node is a non-truncating
2026 /// and unindexed store.
2027 inline bool isNormalStore(const SDNode *N) {
2028 const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
2029 return St && !St->isTruncatingStore() &&
2030 St->getAddressingMode() == ISD::UNINDEXED;
2033 /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
2035 inline bool isNON_TRUNCStore(const SDNode *N) {
2036 return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
2039 /// isTRUNCStore - Returns true if the specified node is a truncating
2041 inline bool isTRUNCStore(const SDNode *N) {
2042 return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
2045 /// isUNINDEXEDStore - Returns true if the specified node is an
2046 /// unindexed store.
2047 inline bool isUNINDEXEDStore(const SDNode *N) {
2048 return isa<StoreSDNode>(N) &&
2049 cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2053 } // end llvm namespace