LLVM  mainline
SelectionDAGNodes.h
Go to the documentation of this file.
00001 //===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file declares the SDNode class and derived classes, which are used to
00011 // represent the nodes and operations present in a SelectionDAG.  These nodes
00012 // and operations are machine code level operations, with some similarities to
00013 // the GCC RTL representation.
00014 //
00015 // Clients should include the SelectionDAG.h file instead of this file directly.
00016 //
00017 //===----------------------------------------------------------------------===//
00018 
00019 #ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
00020 #define LLVM_CODEGEN_SELECTIONDAGNODES_H
00021 
00022 #include "llvm/ADT/BitVector.h"
00023 #include "llvm/ADT/FoldingSet.h"
00024 #include "llvm/ADT/GraphTraits.h"
00025 #include "llvm/ADT/STLExtras.h"
00026 #include "llvm/ADT/SmallPtrSet.h"
00027 #include "llvm/ADT/SmallVector.h"
00028 #include "llvm/ADT/ilist_node.h"
00029 #include "llvm/ADT/iterator_range.h"
00030 #include "llvm/CodeGen/ISDOpcodes.h"
00031 #include "llvm/CodeGen/MachineMemOperand.h"
00032 #include "llvm/CodeGen/ValueTypes.h"
00033 #include "llvm/IR/Constants.h"
00034 #include "llvm/IR/DebugLoc.h"
00035 #include "llvm/IR/Instructions.h"
00036 #include "llvm/Support/DataTypes.h"
00037 #include "llvm/Support/MathExtras.h"
00038 #include <cassert>
00039 
00040 namespace llvm {
00041 
00042 class SelectionDAG;
00043 class GlobalValue;
00044 class MachineBasicBlock;
00045 class MachineConstantPoolValue;
00046 class SDNode;
00047 class Value;
00048 class MCSymbol;
00049 template <typename T> struct DenseMapInfo;
00050 template <typename T> struct simplify_type;
00051 template <typename T> struct ilist_traits;
00052 
00053 void checkForCycles(const SDNode *N, const SelectionDAG *DAG = nullptr,
00054                     bool force = false);
00055 
00056 /// This represents a list of ValueType's that has been intern'd by
00057 /// a SelectionDAG.  Instances of this simple value class are returned by
00058 /// SelectionDAG::getVTList(...).
00059 ///
00060 struct SDVTList {
00061   const EVT *VTs;
00062   unsigned int NumVTs;
00063 };
00064 
00065 namespace ISD {
00066   /// Node predicates
00067 
00068   /// Return true if the specified node is a
00069   /// BUILD_VECTOR where all of the elements are ~0 or undef.
00070   bool isBuildVectorAllOnes(const SDNode *N);
00071 
00072   /// Return true if the specified node is a
00073   /// BUILD_VECTOR where all of the elements are 0 or undef.
00074   bool isBuildVectorAllZeros(const SDNode *N);
00075 
00076   /// \brief Return true if the specified node is a BUILD_VECTOR node of
00077   /// all ConstantSDNode or undef.
00078   bool isBuildVectorOfConstantSDNodes(const SDNode *N);
00079 
00080   /// \brief Return true if the specified node is a BUILD_VECTOR node of
00081   /// all ConstantFPSDNode or undef.
00082   bool isBuildVectorOfConstantFPSDNodes(const SDNode *N);
00083 
00084   /// Return true if the specified node is a
00085   /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
00086   /// element is not an undef.
00087   bool isScalarToVector(const SDNode *N);
00088 
00089   /// Return true if the node has at least one operand
00090   /// and all operands of the specified node are ISD::UNDEF.
00091   bool allOperandsUndef(const SDNode *N);
00092 }  // end llvm:ISD namespace
00093 
00094 //===----------------------------------------------------------------------===//
00095 /// Unlike LLVM values, Selection DAG nodes may return multiple
00096 /// values as the result of a computation.  Many nodes return multiple values,
00097 /// from loads (which define a token and a return value) to ADDC (which returns
00098 /// a result and a carry value), to calls (which may return an arbitrary number
00099 /// of values).
00100 ///
00101 /// As such, each use of a SelectionDAG computation must indicate the node that
00102 /// computes it as well as which return value to use from that node.  This pair
00103 /// of information is represented with the SDValue value type.
00104 ///
00105 class SDValue {
00106   friend struct DenseMapInfo<SDValue>;
00107 
00108   SDNode *Node;       // The node defining the value we are using.
00109   unsigned ResNo;     // Which return value of the node we are using.
00110 public:
00111   SDValue() : Node(nullptr), ResNo(0) {}
00112   SDValue(SDNode *node, unsigned resno);
00113 
00114   /// get the index which selects a specific result in the SDNode
00115   unsigned getResNo() const { return ResNo; }
00116 
00117   /// get the SDNode which holds the desired result
00118   SDNode *getNode() const { return Node; }
00119 
00120   /// set the SDNode
00121   void setNode(SDNode *N) { Node = N; }
00122 
00123   inline SDNode *operator->() const { return Node; }
00124 
00125   bool operator==(const SDValue &O) const {
00126     return Node == O.Node && ResNo == O.ResNo;
00127   }
00128   bool operator!=(const SDValue &O) const {
00129     return !operator==(O);
00130   }
00131   bool operator<(const SDValue &O) const {
00132     return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo);
00133   }
00134   explicit operator bool() const {
00135     return Node != nullptr;
00136   }
00137 
00138   SDValue getValue(unsigned R) const {
00139     return SDValue(Node, R);
00140   }
00141 
00142   // Return true if this node is an operand of N.
00143   bool isOperandOf(SDNode *N) const;
00144 
00145   /// Return the ValueType of the referenced return value.
00146   inline EVT getValueType() const;
00147 
00148   /// Return the simple ValueType of the referenced return value.
00149   MVT getSimpleValueType() const {
00150     return getValueType().getSimpleVT();
00151   }
00152 
00153   /// Returns the size of the value in bits.
00154   unsigned getValueSizeInBits() const {
00155     return getValueType().getSizeInBits();
00156   }
00157 
00158   unsigned getScalarValueSizeInBits() const {
00159     return getValueType().getScalarType().getSizeInBits();
00160   }
00161 
00162   // Forwarding methods - These forward to the corresponding methods in SDNode.
00163   inline unsigned getOpcode() const;
00164   inline unsigned getNumOperands() const;
00165   inline const SDValue &getOperand(unsigned i) const;
00166   inline uint64_t getConstantOperandVal(unsigned i) const;
00167   inline bool isTargetMemoryOpcode() const;
00168   inline bool isTargetOpcode() const;
00169   inline bool isMachineOpcode() const;
00170   inline unsigned getMachineOpcode() const;
00171   inline const DebugLoc &getDebugLoc() const;
00172   inline void dump() const;
00173   inline void dumpr() const;
00174 
00175   /// Return true if this operand (which must be a chain) reaches the
00176   /// specified operand without crossing any side-effecting instructions.
00177   /// In practice, this looks through token factors and non-volatile loads.
00178   /// In order to remain efficient, this only
00179   /// looks a couple of nodes in, it does not do an exhaustive search.
00180   bool reachesChainWithoutSideEffects(SDValue Dest,
00181                                       unsigned Depth = 2) const;
00182 
00183   /// Return true if there are no nodes using value ResNo of Node.
00184   inline bool use_empty() const;
00185 
00186   /// Return true if there is exactly one node using value ResNo of Node.
00187   inline bool hasOneUse() const;
00188 };
00189 
00190 
00191 template<> struct DenseMapInfo<SDValue> {
00192   static inline SDValue getEmptyKey() {
00193     SDValue V;
00194     V.ResNo = -1U;
00195     return V;
00196   }
00197   static inline SDValue getTombstoneKey() {
00198     SDValue V;
00199     V.ResNo = -2U;
00200     return V;
00201   }
00202   static unsigned getHashValue(const SDValue &Val) {
00203     return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
00204             (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
00205   }
00206   static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
00207     return LHS == RHS;
00208   }
00209 };
00210 template <> struct isPodLike<SDValue> { static const bool value = true; };
00211 
00212 
00213 /// Allow casting operators to work directly on
00214 /// SDValues as if they were SDNode*'s.
00215 template<> struct simplify_type<SDValue> {
00216   typedef SDNode* SimpleType;
00217   static SimpleType getSimplifiedValue(SDValue &Val) {
00218     return Val.getNode();
00219   }
00220 };
00221 template<> struct simplify_type<const SDValue> {
00222   typedef /*const*/ SDNode* SimpleType;
00223   static SimpleType getSimplifiedValue(const SDValue &Val) {
00224     return Val.getNode();
00225   }
00226 };
00227 
00228 /// Represents a use of a SDNode. This class holds an SDValue,
00229 /// which records the SDNode being used and the result number, a
00230 /// pointer to the SDNode using the value, and Next and Prev pointers,
00231 /// which link together all the uses of an SDNode.
00232 ///
00233 class SDUse {
00234   /// Val - The value being used.
00235   SDValue Val;
00236   /// User - The user of this value.
00237   SDNode *User;
00238   /// Prev, Next - Pointers to the uses list of the SDNode referred by
00239   /// this operand.
00240   SDUse **Prev, *Next;
00241 
00242   SDUse(const SDUse &U) = delete;
00243   void operator=(const SDUse &U) = delete;
00244 
00245 public:
00246   SDUse() : Val(), User(nullptr), Prev(nullptr), Next(nullptr) {}
00247 
00248   /// Normally SDUse will just implicitly convert to an SDValue that it holds.
00249   operator const SDValue&() const { return Val; }
00250 
00251   /// If implicit conversion to SDValue doesn't work, the get() method returns
00252   /// the SDValue.
00253   const SDValue &get() const { return Val; }
00254 
00255   /// This returns the SDNode that contains this Use.
00256   SDNode *getUser() { return User; }
00257 
00258   /// Get the next SDUse in the use list.
00259   SDUse *getNext() const { return Next; }
00260 
00261   /// Convenience function for get().getNode().
00262   SDNode *getNode() const { return Val.getNode(); }
00263   /// Convenience function for get().getResNo().
00264   unsigned getResNo() const { return Val.getResNo(); }
00265   /// Convenience function for get().getValueType().
00266   EVT getValueType() const { return Val.getValueType(); }
00267 
00268   /// Convenience function for get().operator==
00269   bool operator==(const SDValue &V) const {
00270     return Val == V;
00271   }
00272 
00273   /// Convenience function for get().operator!=
00274   bool operator!=(const SDValue &V) const {
00275     return Val != V;
00276   }
00277 
00278   /// Convenience function for get().operator<
00279   bool operator<(const SDValue &V) const {
00280     return Val < V;
00281   }
00282 
00283 private:
00284   friend class SelectionDAG;
00285   friend class SDNode;
00286 
00287   void setUser(SDNode *p) { User = p; }
00288 
00289   /// Remove this use from its existing use list, assign it the
00290   /// given value, and add it to the new value's node's use list.
00291   inline void set(const SDValue &V);
00292   /// Like set, but only supports initializing a newly-allocated
00293   /// SDUse with a non-null value.
00294   inline void setInitial(const SDValue &V);
00295   /// Like set, but only sets the Node portion of the value,
00296   /// leaving the ResNo portion unmodified.
00297   inline void setNode(SDNode *N);
00298 
00299   void addToList(SDUse **List) {
00300     Next = *List;
00301     if (Next) Next->Prev = &Next;
00302     Prev = List;
00303     *List = this;
00304   }
00305 
00306   void removeFromList() {
00307     *Prev = Next;
00308     if (Next) Next->Prev = Prev;
00309   }
00310 };
00311 
00312 /// simplify_type specializations - Allow casting operators to work directly on
00313 /// SDValues as if they were SDNode*'s.
00314 template<> struct simplify_type<SDUse> {
00315   typedef SDNode* SimpleType;
00316   static SimpleType getSimplifiedValue(SDUse &Val) {
00317     return Val.getNode();
00318   }
00319 };
00320 
00321 
00322 /// Represents one node in the SelectionDAG.
00323 ///
00324 class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
00325 private:
00326   /// The operation that this node performs.
00327   int16_t NodeType;
00328 
00329   /// This is true if OperandList was new[]'d.  If true,
00330   /// then they will be delete[]'d when the node is destroyed.
00331   uint16_t OperandsNeedDelete : 1;
00332 
00333   /// This tracks whether this node has one or more dbg_value
00334   /// nodes corresponding to it.
00335   uint16_t HasDebugValue : 1;
00336 
00337 protected:
00338   /// This member is defined by this class, but is not used for
00339   /// anything.  Subclasses can use it to hold whatever state they find useful.
00340   /// This field is initialized to zero by the ctor.
00341   uint16_t SubclassData : 14;
00342 
00343 private:
00344   /// Unique id per SDNode in the DAG.
00345   int NodeId;
00346 
00347   /// The values that are used by this operation.
00348   SDUse *OperandList;
00349 
00350   /// The types of the values this node defines.  SDNode's may
00351   /// define multiple values simultaneously.
00352   const EVT *ValueList;
00353 
00354   /// List of uses for this SDNode.
00355   SDUse *UseList;
00356 
00357   /// The number of entries in the Operand/Value list.
00358   unsigned short NumOperands, NumValues;
00359 
00360   /// Source line information.
00361   DebugLoc debugLoc;
00362 
00363   // The ordering of the SDNodes. It roughly corresponds to the ordering of the
00364   // original LLVM instructions.
00365   // This is used for turning off scheduling, because we'll forgo
00366   // the normal scheduling algorithms and output the instructions according to
00367   // this ordering.
00368   unsigned IROrder;
00369 
00370   /// Return a pointer to the specified value type.
00371   static const EVT *getValueTypeList(EVT VT);
00372 
00373   friend class SelectionDAG;
00374   friend struct ilist_traits<SDNode>;
00375 
00376 public:
00377   //===--------------------------------------------------------------------===//
00378   //  Accessors
00379   //
00380 
00381   /// Return the SelectionDAG opcode value for this node. For
00382   /// pre-isel nodes (those for which isMachineOpcode returns false), these
00383   /// are the opcode values in the ISD and <target>ISD namespaces. For
00384   /// post-isel opcodes, see getMachineOpcode.
00385   unsigned getOpcode()  const { return (unsigned short)NodeType; }
00386 
00387   /// Test if this node has a target-specific opcode (in the
00388   /// <target>ISD namespace).
00389   bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
00390 
00391   /// Test if this node has a target-specific
00392   /// memory-referencing opcode (in the <target>ISD namespace and
00393   /// greater than FIRST_TARGET_MEMORY_OPCODE).
00394   bool isTargetMemoryOpcode() const {
00395     return NodeType >= ISD::FIRST_TARGET_MEMORY_OPCODE;
00396   }
00397 
00398   /// Test if this node is a memory intrinsic (with valid pointer information).
00399   /// INTRINSIC_W_CHAIN and INTRINSIC_VOID nodes are sometimes created for
00400   /// non-memory intrinsics (with chains) that are not really instances of
00401   /// MemSDNode. For such nodes, we need some extra state to determine the
00402   /// proper classof relationship.
00403   bool isMemIntrinsic() const {
00404     return (NodeType == ISD::INTRINSIC_W_CHAIN ||
00405             NodeType == ISD::INTRINSIC_VOID) && ((SubclassData >> 13) & 1);
00406   }
00407 
00408   /// Test if this node has a post-isel opcode, directly
00409   /// corresponding to a MachineInstr opcode.
00410   bool isMachineOpcode() const { return NodeType < 0; }
00411 
00412   /// This may only be called if isMachineOpcode returns
00413   /// true. It returns the MachineInstr opcode value that the node's opcode
00414   /// corresponds to.
00415   unsigned getMachineOpcode() const {
00416     assert(isMachineOpcode() && "Not a MachineInstr opcode!");
00417     return ~NodeType;
00418   }
00419 
00420   /// Get this bit.
00421   bool getHasDebugValue() const { return HasDebugValue; }
00422 
00423   /// Set this bit.
00424   void setHasDebugValue(bool b) { HasDebugValue = b; }
00425 
00426   /// Return true if there are no uses of this node.
00427   bool use_empty() const { return UseList == nullptr; }
00428 
00429   /// Return true if there is exactly one use of this node.
00430   bool hasOneUse() const {
00431     return !use_empty() && std::next(use_begin()) == use_end();
00432   }
00433 
00434   /// Return the number of uses of this node. This method takes
00435   /// time proportional to the number of uses.
00436   size_t use_size() const { return std::distance(use_begin(), use_end()); }
00437 
00438   /// Return the unique node id.
00439   int getNodeId() const { return NodeId; }
00440 
00441   /// Set unique node id.
00442   void setNodeId(int Id) { NodeId = Id; }
00443 
00444   /// Return the node ordering.
00445   unsigned getIROrder() const { return IROrder; }
00446 
00447   /// Set the node ordering.
00448   void setIROrder(unsigned Order) { IROrder = Order; }
00449 
00450   /// Return the source location info.
00451   const DebugLoc &getDebugLoc() const { return debugLoc; }
00452 
00453   /// Set source location info.  Try to avoid this, putting
00454   /// it in the constructor is preferable.
00455   void setDebugLoc(DebugLoc dl) { debugLoc = std::move(dl); }
00456 
00457   /// This class provides iterator support for SDUse
00458   /// operands that use a specific SDNode.
00459   class use_iterator
00460     : public std::iterator<std::forward_iterator_tag, SDUse, ptrdiff_t> {
00461     SDUse *Op;
00462     explicit use_iterator(SDUse *op) : Op(op) {
00463     }
00464     friend class SDNode;
00465   public:
00466     typedef std::iterator<std::forward_iterator_tag,
00467                           SDUse, ptrdiff_t>::reference reference;
00468     typedef std::iterator<std::forward_iterator_tag,
00469                           SDUse, ptrdiff_t>::pointer pointer;
00470 
00471     use_iterator(const use_iterator &I) : Op(I.Op) {}
00472     use_iterator() : Op(nullptr) {}
00473 
00474     bool operator==(const use_iterator &x) const {
00475       return Op == x.Op;
00476     }
00477     bool operator!=(const use_iterator &x) const {
00478       return !operator==(x);
00479     }
00480 
00481     /// Return true if this iterator is at the end of uses list.
00482     bool atEnd() const { return Op == nullptr; }
00483 
00484     // Iterator traversal: forward iteration only.
00485     use_iterator &operator++() {          // Preincrement
00486       assert(Op && "Cannot increment end iterator!");
00487       Op = Op->getNext();
00488       return *this;
00489     }
00490 
00491     use_iterator operator++(int) {        // Postincrement
00492       use_iterator tmp = *this; ++*this; return tmp;
00493     }
00494 
00495     /// Retrieve a pointer to the current user node.
00496     SDNode *operator*() const {
00497       assert(Op && "Cannot dereference end iterator!");
00498       return Op->getUser();
00499     }
00500 
00501     SDNode *operator->() const { return operator*(); }
00502 
00503     SDUse &getUse() const { return *Op; }
00504 
00505     /// Retrieve the operand # of this use in its user.
00506     unsigned getOperandNo() const {
00507       assert(Op && "Cannot dereference end iterator!");
00508       return (unsigned)(Op - Op->getUser()->OperandList);
00509     }
00510   };
00511 
00512   /// Provide iteration support to walk over all uses of an SDNode.
00513   use_iterator use_begin() const {
00514     return use_iterator(UseList);
00515   }
00516 
00517   static use_iterator use_end() { return use_iterator(nullptr); }
00518 
00519   inline iterator_range<use_iterator> uses() {
00520     return iterator_range<use_iterator>(use_begin(), use_end());
00521   }
00522   inline iterator_range<use_iterator> uses() const {
00523     return iterator_range<use_iterator>(use_begin(), use_end());
00524   }
00525 
00526   /// Return true if there are exactly NUSES uses of the indicated value.
00527   /// This method ignores uses of other values defined by this operation.
00528   bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
00529 
00530   /// Return true if there are any use of the indicated value.
00531   /// This method ignores uses of other values defined by this operation.
00532   bool hasAnyUseOfValue(unsigned Value) const;
00533 
00534   /// Return true if this node is the only use of N.
00535   bool isOnlyUserOf(SDNode *N) const;
00536 
00537   /// Return true if this node is an operand of N.
00538   bool isOperandOf(SDNode *N) const;
00539 
00540   /// Return true if this node is a predecessor of N.
00541   /// NOTE: Implemented on top of hasPredecessor and every bit as
00542   /// expensive. Use carefully.
00543   bool isPredecessorOf(const SDNode *N) const {
00544     return N->hasPredecessor(this);
00545   }
00546 
00547   /// Return true if N is a predecessor of this node.
00548   /// N is either an operand of this node, or can be reached by recursively
00549   /// traversing up the operands.
00550   /// NOTE: This is an expensive method. Use it carefully.
00551   bool hasPredecessor(const SDNode *N) const;
00552 
00553   /// Return true if N is a predecessor of this node.
00554   /// N is either an operand of this node, or can be reached by recursively
00555   /// traversing up the operands.
00556   /// In this helper the Visited and worklist sets are held externally to
00557   /// cache predecessors over multiple invocations. If you want to test for
00558   /// multiple predecessors this method is preferable to multiple calls to
00559   /// hasPredecessor. Be sure to clear Visited and Worklist if the DAG
00560   /// changes.
00561   /// NOTE: This is still very expensive. Use carefully.
00562   bool hasPredecessorHelper(const SDNode *N,
00563                             SmallPtrSetImpl<const SDNode *> &Visited,
00564                             SmallVectorImpl<const SDNode *> &Worklist) const;
00565 
00566   /// Return the number of values used by this operation.
00567   unsigned getNumOperands() const { return NumOperands; }
00568 
00569   /// Helper method returns the integer value of a ConstantSDNode operand.
00570   uint64_t getConstantOperandVal(unsigned Num) const;
00571 
00572   const SDValue &getOperand(unsigned Num) const {
00573     assert(Num < NumOperands && "Invalid child # of SDNode!");
00574     return OperandList[Num];
00575   }
00576 
00577   typedef SDUse* op_iterator;
00578   op_iterator op_begin() const { return OperandList; }
00579   op_iterator op_end() const { return OperandList+NumOperands; }
00580   ArrayRef<SDUse> ops() const { return makeArrayRef(op_begin(), op_end()); }
00581 
00582   SDVTList getVTList() const {
00583     SDVTList X = { ValueList, NumValues };
00584     return X;
00585   }
00586 
00587   /// If this node has a glue operand, return the node
00588   /// to which the glue operand points. Otherwise return NULL.
00589   SDNode *getGluedNode() const {
00590     if (getNumOperands() != 0 &&
00591       getOperand(getNumOperands()-1).getValueType() == MVT::Glue)
00592       return getOperand(getNumOperands()-1).getNode();
00593     return nullptr;
00594   }
00595 
00596   // If this is a pseudo op, like copyfromreg, look to see if there is a
00597   // real target node glued to it.  If so, return the target node.
00598   const SDNode *getGluedMachineNode() const {
00599     const SDNode *FoundNode = this;
00600 
00601     // Climb up glue edges until a machine-opcode node is found, or the
00602     // end of the chain is reached.
00603     while (!FoundNode->isMachineOpcode()) {
00604       const SDNode *N = FoundNode->getGluedNode();
00605       if (!N) break;
00606       FoundNode = N;
00607     }
00608 
00609     return FoundNode;
00610   }
00611 
00612   /// If this node has a glue value with a user, return
00613   /// the user (there is at most one). Otherwise return NULL.
00614   SDNode *getGluedUser() const {
00615     for (use_iterator UI = use_begin(), UE = use_end(); UI != UE; ++UI)
00616       if (UI.getUse().get().getValueType() == MVT::Glue)
00617         return *UI;
00618     return nullptr;
00619   }
00620 
00621   /// Return the number of values defined/returned by this operator.
00622   unsigned getNumValues() const { return NumValues; }
00623 
00624   /// Return the type of a specified result.
00625   EVT getValueType(unsigned ResNo) const {
00626     assert(ResNo < NumValues && "Illegal result number!");
00627     return ValueList[ResNo];
00628   }
00629 
00630   /// Return the type of a specified result as a simple type.
00631   MVT getSimpleValueType(unsigned ResNo) const {
00632     return getValueType(ResNo).getSimpleVT();
00633   }
00634 
00635   /// Returns MVT::getSizeInBits(getValueType(ResNo)).
00636   unsigned getValueSizeInBits(unsigned ResNo) const {
00637     return getValueType(ResNo).getSizeInBits();
00638   }
00639 
00640   typedef const EVT* value_iterator;
00641   value_iterator value_begin() const { return ValueList; }
00642   value_iterator value_end() const { return ValueList+NumValues; }
00643 
00644   /// Return the opcode of this operation for printing.
00645   std::string getOperationName(const SelectionDAG *G = nullptr) const;
00646   static const char* getIndexedModeName(ISD::MemIndexedMode AM);
00647   void print_types(raw_ostream &OS, const SelectionDAG *G) const;
00648   void print_details(raw_ostream &OS, const SelectionDAG *G) const;
00649   void print(raw_ostream &OS, const SelectionDAG *G = nullptr) const;
00650   void printr(raw_ostream &OS, const SelectionDAG *G = nullptr) const;
00651 
00652   /// Print a SelectionDAG node and all children down to
00653   /// the leaves.  The given SelectionDAG allows target-specific nodes
00654   /// to be printed in human-readable form.  Unlike printr, this will
00655   /// print the whole DAG, including children that appear multiple
00656   /// times.
00657   ///
00658   void printrFull(raw_ostream &O, const SelectionDAG *G = nullptr) const;
00659 
00660   /// Print a SelectionDAG node and children up to
00661   /// depth "depth."  The given SelectionDAG allows target-specific
00662   /// nodes to be printed in human-readable form.  Unlike printr, this
00663   /// will print children that appear multiple times wherever they are
00664   /// used.
00665   ///
00666   void printrWithDepth(raw_ostream &O, const SelectionDAG *G = nullptr,
00667                        unsigned depth = 100) const;
00668 
00669 
00670   /// Dump this node, for debugging.
00671   void dump() const;
00672 
00673   /// Dump (recursively) this node and its use-def subgraph.
00674   void dumpr() const;
00675 
00676   /// Dump this node, for debugging.
00677   /// The given SelectionDAG allows target-specific nodes to be printed
00678   /// in human-readable form.
00679   void dump(const SelectionDAG *G) const;
00680 
00681   /// Dump (recursively) this node and its use-def subgraph.
00682   /// The given SelectionDAG allows target-specific nodes to be printed
00683   /// in human-readable form.
00684   void dumpr(const SelectionDAG *G) const;
00685 
00686   /// printrFull to dbgs().  The given SelectionDAG allows
00687   /// target-specific nodes to be printed in human-readable form.
00688   /// Unlike dumpr, this will print the whole DAG, including children
00689   /// that appear multiple times.
00690   void dumprFull(const SelectionDAG *G = nullptr) const;
00691 
00692   /// printrWithDepth to dbgs().  The given
00693   /// SelectionDAG allows target-specific nodes to be printed in
00694   /// human-readable form.  Unlike dumpr, this will print children
00695   /// that appear multiple times wherever they are used.
00696   ///
00697   void dumprWithDepth(const SelectionDAG *G = nullptr,
00698                       unsigned depth = 100) const;
00699 
00700   /// Gather unique data for the node.
00701   void Profile(FoldingSetNodeID &ID) const;
00702 
00703   /// This method should only be used by the SDUse class.
00704   void addUse(SDUse &U) { U.addToList(&UseList); }
00705 
00706 protected:
00707   static SDVTList getSDVTList(EVT VT) {
00708     SDVTList Ret = { getValueTypeList(VT), 1 };
00709     return Ret;
00710   }
00711 
00712   SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
00713          ArrayRef<SDValue> Ops)
00714       : NodeType(Opc), OperandsNeedDelete(true), HasDebugValue(false),
00715         SubclassData(0), NodeId(-1),
00716         OperandList(Ops.size() ? new SDUse[Ops.size()] : nullptr),
00717         ValueList(VTs.VTs), UseList(nullptr), NumOperands(Ops.size()),
00718         NumValues(VTs.NumVTs), debugLoc(std::move(dl)), IROrder(Order) {
00719     assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
00720     assert(NumOperands == Ops.size() &&
00721            "NumOperands wasn't wide enough for its operands!");
00722     assert(NumValues == VTs.NumVTs &&
00723            "NumValues wasn't wide enough for its operands!");
00724     for (unsigned i = 0; i != Ops.size(); ++i) {
00725       assert(OperandList && "no operands available");
00726       OperandList[i].setUser(this);
00727       OperandList[i].setInitial(Ops[i]);
00728     }
00729     checkForCycles(this);
00730   }
00731 
00732   /// This constructor adds no operands itself; operands can be
00733   /// set later with InitOperands.
00734   SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs)
00735       : NodeType(Opc), OperandsNeedDelete(false), HasDebugValue(false),
00736         SubclassData(0), NodeId(-1), OperandList(nullptr), ValueList(VTs.VTs),
00737         UseList(nullptr), NumOperands(0), NumValues(VTs.NumVTs),
00738         debugLoc(std::move(dl)), IROrder(Order) {
00739     assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
00740     assert(NumValues == VTs.NumVTs &&
00741            "NumValues wasn't wide enough for its operands!");
00742   }
00743 
00744   /// Initialize the operands list of this with 1 operand.
00745   void InitOperands(SDUse *Ops, const SDValue &Op0) {
00746     Ops[0].setUser(this);
00747     Ops[0].setInitial(Op0);
00748     NumOperands = 1;
00749     OperandList = Ops;
00750     checkForCycles(this);
00751   }
00752 
00753   /// Initialize the operands list of this with 2 operands.
00754   void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) {
00755     Ops[0].setUser(this);
00756     Ops[0].setInitial(Op0);
00757     Ops[1].setUser(this);
00758     Ops[1].setInitial(Op1);
00759     NumOperands = 2;
00760     OperandList = Ops;
00761     checkForCycles(this);
00762   }
00763 
00764   /// Initialize the operands list of this with 3 operands.
00765   void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
00766                     const SDValue &Op2) {
00767     Ops[0].setUser(this);
00768     Ops[0].setInitial(Op0);
00769     Ops[1].setUser(this);
00770     Ops[1].setInitial(Op1);
00771     Ops[2].setUser(this);
00772     Ops[2].setInitial(Op2);
00773     NumOperands = 3;
00774     OperandList = Ops;
00775     checkForCycles(this);
00776   }
00777 
00778   /// Initialize the operands list of this with 4 operands.
00779   void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
00780                     const SDValue &Op2, const SDValue &Op3) {
00781     Ops[0].setUser(this);
00782     Ops[0].setInitial(Op0);
00783     Ops[1].setUser(this);
00784     Ops[1].setInitial(Op1);
00785     Ops[2].setUser(this);
00786     Ops[2].setInitial(Op2);
00787     Ops[3].setUser(this);
00788     Ops[3].setInitial(Op3);
00789     NumOperands = 4;
00790     OperandList = Ops;
00791     checkForCycles(this);
00792   }
00793 
00794   /// Initialize the operands list of this with N operands.
00795   void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) {
00796     for (unsigned i = 0; i != N; ++i) {
00797       Ops[i].setUser(this);
00798       Ops[i].setInitial(Vals[i]);
00799     }
00800     NumOperands = N;
00801     assert(NumOperands == N &&
00802            "NumOperands wasn't wide enough for its operands!");
00803     OperandList = Ops;
00804     checkForCycles(this);
00805   }
00806 
00807   /// Release the operands and set this node to have zero operands.
00808   void DropOperands();
00809 };
00810 
00811 /// Wrapper class for IR location info (IR ordering and DebugLoc) to be passed
00812 /// into SDNode creation functions.
00813 /// When an SDNode is created from the DAGBuilder, the DebugLoc is extracted
00814 /// from the original Instruction, and IROrder is the ordinal position of
00815 /// the instruction.
00816 /// When an SDNode is created after the DAG is being built, both DebugLoc and
00817 /// the IROrder are propagated from the original SDNode.
00818 /// So SDLoc class provides two constructors besides the default one, one to
00819 /// be used by the DAGBuilder, the other to be used by others.
00820 class SDLoc {
00821 private:
00822   // Ptr could be used for either Instruction* or SDNode*. It is used for
00823   // Instruction* if IROrder is not -1.
00824   const void *Ptr;
00825   int IROrder;
00826 
00827 public:
00828   SDLoc() : Ptr(nullptr), IROrder(0) {}
00829   SDLoc(const SDNode *N) : Ptr(N), IROrder(-1) {
00830     assert(N && "null SDNode");
00831   }
00832   SDLoc(const SDValue V) : Ptr(V.getNode()), IROrder(-1) {
00833     assert(Ptr && "null SDNode");
00834   }
00835   SDLoc(const Instruction *I, int Order) : Ptr(I), IROrder(Order) {
00836     assert(Order >= 0 && "bad IROrder");
00837   }
00838   unsigned getIROrder() {
00839     if (IROrder >= 0 || Ptr == nullptr) {
00840       return (unsigned)IROrder;
00841     }
00842     const SDNode *N = (const SDNode*)(Ptr);
00843     return N->getIROrder();
00844   }
00845   DebugLoc getDebugLoc() {
00846     if (!Ptr) {
00847       return DebugLoc();
00848     }
00849     if (IROrder >= 0) {
00850       const Instruction *I = (const Instruction*)(Ptr);
00851       return I->getDebugLoc();
00852     }
00853     const SDNode *N = (const SDNode*)(Ptr);
00854     return N->getDebugLoc();
00855   }
00856 };
00857 
00858 
00859 // Define inline functions from the SDValue class.
00860 
00861 inline SDValue::SDValue(SDNode *node, unsigned resno)
00862     : Node(node), ResNo(resno) {
00863   assert((!Node || ResNo < Node->getNumValues()) &&
00864          "Invalid result number for the given node!");
00865   assert(ResNo < -2U && "Cannot use result numbers reserved for DenseMaps.");
00866 }
00867 
00868 inline unsigned SDValue::getOpcode() const {
00869   return Node->getOpcode();
00870 }
00871 inline EVT SDValue::getValueType() const {
00872   return Node->getValueType(ResNo);
00873 }
00874 inline unsigned SDValue::getNumOperands() const {
00875   return Node->getNumOperands();
00876 }
00877 inline const SDValue &SDValue::getOperand(unsigned i) const {
00878   return Node->getOperand(i);
00879 }
00880 inline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
00881   return Node->getConstantOperandVal(i);
00882 }
00883 inline bool SDValue::isTargetOpcode() const {
00884   return Node->isTargetOpcode();
00885 }
00886 inline bool SDValue::isTargetMemoryOpcode() const {
00887   return Node->isTargetMemoryOpcode();
00888 }
00889 inline bool SDValue::isMachineOpcode() const {
00890   return Node->isMachineOpcode();
00891 }
00892 inline unsigned SDValue::getMachineOpcode() const {
00893   return Node->getMachineOpcode();
00894 }
00895 inline bool SDValue::use_empty() const {
00896   return !Node->hasAnyUseOfValue(ResNo);
00897 }
00898 inline bool SDValue::hasOneUse() const {
00899   return Node->hasNUsesOfValue(1, ResNo);
00900 }
00901 inline const DebugLoc &SDValue::getDebugLoc() const {
00902   return Node->getDebugLoc();
00903 }
00904 inline void SDValue::dump() const {
00905   return Node->dump();
00906 }
00907 inline void SDValue::dumpr() const {
00908   return Node->dumpr();
00909 }
00910 // Define inline functions from the SDUse class.
00911 
00912 inline void SDUse::set(const SDValue &V) {
00913   if (Val.getNode()) removeFromList();
00914   Val = V;
00915   if (V.getNode()) V.getNode()->addUse(*this);
00916 }
00917 
00918 inline void SDUse::setInitial(const SDValue &V) {
00919   Val = V;
00920   V.getNode()->addUse(*this);
00921 }
00922 
00923 inline void SDUse::setNode(SDNode *N) {
00924   if (Val.getNode()) removeFromList();
00925   Val.setNode(N);
00926   if (N) N->addUse(*this);
00927 }
00928 
00929 /// These are IR-level optimization flags that may be propagated to SDNodes.
00930 /// TODO: This data structure should be shared by the IR optimizer and the
00931 /// the backend.
00932 struct SDNodeFlags {
00933 private:
00934   bool NoUnsignedWrap : 1;
00935   bool NoSignedWrap : 1;
00936   bool Exact : 1;
00937   bool UnsafeAlgebra : 1;
00938   bool NoNaNs : 1;
00939   bool NoInfs : 1;
00940   bool NoSignedZeros : 1;
00941   bool AllowReciprocal : 1;
00942 
00943 public:
00944   /// Default constructor turns off all optimization flags.
00945   SDNodeFlags() {
00946     NoUnsignedWrap = false;
00947     NoSignedWrap = false;
00948     Exact = false;
00949     UnsafeAlgebra = false;
00950     NoNaNs = false;
00951     NoInfs = false;
00952     NoSignedZeros = false;
00953     AllowReciprocal = false;
00954   }
00955 
00956   // These are mutators for each flag.
00957   void setNoUnsignedWrap(bool b) { NoUnsignedWrap = b; }
00958   void setNoSignedWrap(bool b) { NoSignedWrap = b; }
00959   void setExact(bool b) { Exact = b; }
00960   void setUnsafeAlgebra(bool b) { UnsafeAlgebra = b; }
00961   void setNoNaNs(bool b) { NoNaNs = b; }
00962   void setNoInfs(bool b) { NoInfs = b; }
00963   void setNoSignedZeros(bool b) { NoSignedZeros = b; }
00964   void setAllowReciprocal(bool b) { AllowReciprocal = b; }
00965 
00966   // These are accessors for each flag.
00967   bool hasNoUnsignedWrap() const { return NoUnsignedWrap; }
00968   bool hasNoSignedWrap() const { return NoSignedWrap; }
00969   bool hasExact() const { return Exact; }
00970   bool hasUnsafeAlgebra() const { return UnsafeAlgebra; }
00971   bool hasNoNaNs() const { return NoNaNs; }
00972   bool hasNoInfs() const { return NoInfs; }
00973   bool hasNoSignedZeros() const { return NoSignedZeros; }
00974   bool hasAllowReciprocal() const { return AllowReciprocal; }
00975 
00976   /// Return a raw encoding of the flags.
00977   /// This function should only be used to add data to the NodeID value.
00978   unsigned getRawFlags() const {
00979     return (NoUnsignedWrap << 0) | (NoSignedWrap << 1) | (Exact << 2) |
00980            (UnsafeAlgebra << 3) | (NoNaNs << 4) | (NoInfs << 5) |
00981            (NoSignedZeros << 6) | (AllowReciprocal << 7);
00982   }
00983 };
00984 
00985 /// This class is used for single-operand SDNodes.  This is solely
00986 /// to allow co-allocation of node operands with the node itself.
00987 class UnarySDNode : public SDNode {
00988   SDUse Op;
00989 public:
00990   UnarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
00991               SDValue X)
00992     : SDNode(Opc, Order, dl, VTs) {
00993     InitOperands(&Op, X);
00994   }
00995 };
00996 
00997 /// This class is used for two-operand SDNodes.  This is solely
00998 /// to allow co-allocation of node operands with the node itself.
00999 class BinarySDNode : public SDNode {
01000   SDUse Ops[2];
01001 public:
01002   BinarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
01003                SDValue X, SDValue Y)
01004     : SDNode(Opc, Order, dl, VTs) {
01005     InitOperands(Ops, X, Y);
01006   }
01007 };
01008 
01009 /// Returns true if the opcode is a binary operation with flags.
01010 static bool isBinOpWithFlags(unsigned Opcode) {
01011   switch (Opcode) {
01012   case ISD::SDIV:
01013   case ISD::UDIV:
01014   case ISD::SRA:
01015   case ISD::SRL:
01016   case ISD::MUL:
01017   case ISD::ADD:
01018   case ISD::SUB:
01019   case ISD::SHL:
01020   case ISD::FADD:
01021   case ISD::FDIV:
01022   case ISD::FMUL:
01023   case ISD::FREM:
01024   case ISD::FSUB:
01025     return true;
01026   default:
01027     return false;
01028   }
01029 }
01030 
01031 /// This class is an extension of BinarySDNode
01032 /// used from those opcodes that have associated extra flags.
01033 class BinaryWithFlagsSDNode : public BinarySDNode {
01034 public:
01035   SDNodeFlags Flags;
01036   BinaryWithFlagsSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
01037                         SDValue X, SDValue Y, const SDNodeFlags &NodeFlags)
01038       : BinarySDNode(Opc, Order, dl, VTs, X, Y), Flags(NodeFlags) {}
01039   static bool classof(const SDNode *N) {
01040     return isBinOpWithFlags(N->getOpcode());
01041   }
01042 };
01043 
01044 /// This class is used for three-operand SDNodes. This is solely
01045 /// to allow co-allocation of node operands with the node itself.
01046 class TernarySDNode : public SDNode {
01047   SDUse Ops[3];
01048 public:
01049   TernarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
01050                 SDValue X, SDValue Y, SDValue Z)
01051     : SDNode(Opc, Order, dl, VTs) {
01052     InitOperands(Ops, X, Y, Z);
01053   }
01054 };
01055 
01056 
01057 /// This class is used to form a handle around another node that
01058 /// is persistent and is updated across invocations of replaceAllUsesWith on its
01059 /// operand.  This node should be directly created by end-users and not added to
01060 /// the AllNodes list.
01061 class HandleSDNode : public SDNode {
01062   SDUse Op;
01063 public:
01064   explicit HandleSDNode(SDValue X)
01065     : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) {
01066     InitOperands(&Op, X);
01067   }
01068   ~HandleSDNode();
01069   const SDValue &getValue() const { return Op; }
01070 };
01071 
01072 class AddrSpaceCastSDNode : public UnarySDNode {
01073 private:
01074   unsigned SrcAddrSpace;
01075   unsigned DestAddrSpace;
01076 
01077 public:
01078   AddrSpaceCastSDNode(unsigned Order, DebugLoc dl, EVT VT, SDValue X,
01079                       unsigned SrcAS, unsigned DestAS);
01080 
01081   unsigned getSrcAddressSpace() const { return SrcAddrSpace; }
01082   unsigned getDestAddressSpace() const { return DestAddrSpace; }
01083 
01084   static bool classof(const SDNode *N) {
01085     return N->getOpcode() == ISD::ADDRSPACECAST;
01086   }
01087 };
01088 
01089 /// This is an abstract virtual class for memory operations.
01090 class MemSDNode : public SDNode {
01091 private:
01092   // VT of in-memory value.
01093   EVT MemoryVT;
01094 
01095 protected:
01096   /// Memory reference information.
01097   MachineMemOperand *MMO;
01098 
01099 public:
01100   MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
01101             EVT MemoryVT, MachineMemOperand *MMO);
01102 
01103   MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
01104             ArrayRef<SDValue> Ops, EVT MemoryVT, MachineMemOperand *MMO);
01105 
01106   bool readMem() const { return MMO->isLoad(); }
01107   bool writeMem() const { return MMO->isStore(); }
01108 
01109   /// Returns alignment and volatility of the memory access
01110   unsigned getOriginalAlignment() const {
01111     return MMO->getBaseAlignment();
01112   }
01113   unsigned getAlignment() const {
01114     return MMO->getAlignment();
01115   }
01116 
01117   /// Return the SubclassData value, which contains an
01118   /// encoding of the volatile flag, as well as bits used by subclasses. This
01119   /// function should only be used to compute a FoldingSetNodeID value.
01120   unsigned getRawSubclassData() const {
01121     return SubclassData;
01122   }
01123 
01124   // We access subclass data here so that we can check consistency
01125   // with MachineMemOperand information.
01126   bool isVolatile() const { return (SubclassData >> 5) & 1; }
01127   bool isNonTemporal() const { return (SubclassData >> 6) & 1; }
01128   bool isInvariant() const { return (SubclassData >> 7) & 1; }
01129 
01130   AtomicOrdering getOrdering() const {
01131     return AtomicOrdering((SubclassData >> 8) & 15);
01132   }
01133   SynchronizationScope getSynchScope() const {
01134     return SynchronizationScope((SubclassData >> 12) & 1);
01135   }
01136 
01137   // Returns the offset from the location of the access.
01138   int64_t getSrcValueOffset() const { return MMO->getOffset(); }
01139 
01140   /// Returns the AA info that describes the dereference.
01141   AAMDNodes getAAInfo() const { return MMO->getAAInfo(); }
01142 
01143   /// Returns the Ranges that describes the dereference.
01144   const MDNode *getRanges() const { return MMO->getRanges(); }
01145 
01146   /// Return the type of the in-memory value.
01147   EVT getMemoryVT() const { return MemoryVT; }
01148 
01149   /// Return a MachineMemOperand object describing the memory
01150   /// reference performed by operation.
01151   MachineMemOperand *getMemOperand() const { return MMO; }
01152 
01153   const MachinePointerInfo &getPointerInfo() const {
01154     return MMO->getPointerInfo();
01155   }
01156 
01157   /// Return the address space for the associated pointer
01158   unsigned getAddressSpace() const {
01159     return getPointerInfo().getAddrSpace();
01160   }
01161 
01162   /// Update this MemSDNode's MachineMemOperand information
01163   /// to reflect the alignment of NewMMO, if it has a greater alignment.
01164   /// This must only be used when the new alignment applies to all users of
01165   /// this MachineMemOperand.
01166   void refineAlignment(const MachineMemOperand *NewMMO) {
01167     MMO->refineAlignment(NewMMO);
01168   }
01169 
01170   const SDValue &getChain() const { return getOperand(0); }
01171   const SDValue &getBasePtr() const {
01172     return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
01173   }
01174 
01175   // Methods to support isa and dyn_cast
01176   static bool classof(const SDNode *N) {
01177     // For some targets, we lower some target intrinsics to a MemIntrinsicNode
01178     // with either an intrinsic or a target opcode.
01179     return N->getOpcode() == ISD::LOAD                ||
01180            N->getOpcode() == ISD::STORE               ||
01181            N->getOpcode() == ISD::PREFETCH            ||
01182            N->getOpcode() == ISD::ATOMIC_CMP_SWAP     ||
01183            N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS ||
01184            N->getOpcode() == ISD::ATOMIC_SWAP         ||
01185            N->getOpcode() == ISD::ATOMIC_LOAD_ADD     ||
01186            N->getOpcode() == ISD::ATOMIC_LOAD_SUB     ||
01187            N->getOpcode() == ISD::ATOMIC_LOAD_AND     ||
01188            N->getOpcode() == ISD::ATOMIC_LOAD_OR      ||
01189            N->getOpcode() == ISD::ATOMIC_LOAD_XOR     ||
01190            N->getOpcode() == ISD::ATOMIC_LOAD_NAND    ||
01191            N->getOpcode() == ISD::ATOMIC_LOAD_MIN     ||
01192            N->getOpcode() == ISD::ATOMIC_LOAD_MAX     ||
01193            N->getOpcode() == ISD::ATOMIC_LOAD_UMIN    ||
01194            N->getOpcode() == ISD::ATOMIC_LOAD_UMAX    ||
01195            N->getOpcode() == ISD::ATOMIC_LOAD         ||
01196            N->getOpcode() == ISD::ATOMIC_STORE        ||
01197            N->getOpcode() == ISD::MLOAD               ||
01198            N->getOpcode() == ISD::MSTORE              ||
01199            N->getOpcode() == ISD::MGATHER             ||
01200            N->getOpcode() == ISD::MSCATTER            ||
01201            N->isMemIntrinsic()                        ||
01202            N->isTargetMemoryOpcode();
01203   }
01204 };
01205 
01206 /// This is an SDNode representing atomic operations.
01207 class AtomicSDNode : public MemSDNode {
01208   SDUse Ops[4];
01209 
01210   /// For cmpxchg instructions, the ordering requirements when a store does not
01211   /// occur.
01212   AtomicOrdering FailureOrdering;
01213 
01214   void InitAtomic(AtomicOrdering SuccessOrdering,
01215                   AtomicOrdering FailureOrdering,
01216                   SynchronizationScope SynchScope) {
01217     // This must match encodeMemSDNodeFlags() in SelectionDAG.cpp.
01218     assert((SuccessOrdering & 15) == SuccessOrdering &&
01219            "Ordering may not require more than 4 bits!");
01220     assert((FailureOrdering & 15) == FailureOrdering &&
01221            "Ordering may not require more than 4 bits!");
01222     assert((SynchScope & 1) == SynchScope &&
01223            "SynchScope may not require more than 1 bit!");
01224     SubclassData |= SuccessOrdering << 8;
01225     SubclassData |= SynchScope << 12;
01226     this->FailureOrdering = FailureOrdering;
01227     assert(getSuccessOrdering() == SuccessOrdering &&
01228            "Ordering encoding error!");
01229     assert(getFailureOrdering() == FailureOrdering &&
01230            "Ordering encoding error!");
01231     assert(getSynchScope() == SynchScope && "Synch-scope encoding error!");
01232   }
01233 
01234 public:
01235   // Opc:   opcode for atomic
01236   // VTL:    value type list
01237   // Chain:  memory chain for operaand
01238   // Ptr:    address to update as a SDValue
01239   // Cmp:    compare value
01240   // Swp:    swap value
01241   // SrcVal: address to update as a Value (used for MemOperand)
01242   // Align:  alignment of memory
01243   AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
01244                EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp,
01245                MachineMemOperand *MMO, AtomicOrdering Ordering,
01246                SynchronizationScope SynchScope)
01247       : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
01248     InitAtomic(Ordering, Ordering, SynchScope);
01249     InitOperands(Ops, Chain, Ptr, Cmp, Swp);
01250   }
01251   AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
01252                EVT MemVT,
01253                SDValue Chain, SDValue Ptr,
01254                SDValue Val, MachineMemOperand *MMO,
01255                AtomicOrdering Ordering, SynchronizationScope SynchScope)
01256     : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
01257     InitAtomic(Ordering, Ordering, SynchScope);
01258     InitOperands(Ops, Chain, Ptr, Val);
01259   }
01260   AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
01261                EVT MemVT,
01262                SDValue Chain, SDValue Ptr,
01263                MachineMemOperand *MMO,
01264                AtomicOrdering Ordering, SynchronizationScope SynchScope)
01265     : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
01266     InitAtomic(Ordering, Ordering, SynchScope);
01267     InitOperands(Ops, Chain, Ptr);
01268   }
01269   AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT,
01270                const SDValue* AllOps, SDUse *DynOps, unsigned NumOps,
01271                MachineMemOperand *MMO,
01272                AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
01273                SynchronizationScope SynchScope)
01274     : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
01275     InitAtomic(SuccessOrdering, FailureOrdering, SynchScope);
01276     assert((DynOps || NumOps <= array_lengthof(Ops)) &&
01277            "Too many ops for internal storage!");
01278     InitOperands(DynOps ? DynOps : Ops, AllOps, NumOps);
01279   }
01280 
01281   const SDValue &getBasePtr() const { return getOperand(1); }
01282   const SDValue &getVal() const { return getOperand(2); }
01283 
01284   AtomicOrdering getSuccessOrdering() const {
01285     return getOrdering();
01286   }
01287 
01288   // Not quite enough room in SubclassData for everything, so failure gets its
01289   // own field.
01290   AtomicOrdering getFailureOrdering() const {
01291     return FailureOrdering;
01292   }
01293 
01294   bool isCompareAndSwap() const {
01295     unsigned Op = getOpcode();
01296     return Op == ISD::ATOMIC_CMP_SWAP || Op == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS;
01297   }
01298 
01299   // Methods to support isa and dyn_cast
01300   static bool classof(const SDNode *N) {
01301     return N->getOpcode() == ISD::ATOMIC_CMP_SWAP     ||
01302            N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS ||
01303            N->getOpcode() == ISD::ATOMIC_SWAP         ||
01304            N->getOpcode() == ISD::ATOMIC_LOAD_ADD     ||
01305            N->getOpcode() == ISD::ATOMIC_LOAD_SUB     ||
01306            N->getOpcode() == ISD::ATOMIC_LOAD_AND     ||
01307            N->getOpcode() == ISD::ATOMIC_LOAD_OR      ||
01308            N->getOpcode() == ISD::ATOMIC_LOAD_XOR     ||
01309            N->getOpcode() == ISD::ATOMIC_LOAD_NAND    ||
01310            N->getOpcode() == ISD::ATOMIC_LOAD_MIN     ||
01311            N->getOpcode() == ISD::ATOMIC_LOAD_MAX     ||
01312            N->getOpcode() == ISD::ATOMIC_LOAD_UMIN    ||
01313            N->getOpcode() == ISD::ATOMIC_LOAD_UMAX    ||
01314            N->getOpcode() == ISD::ATOMIC_LOAD         ||
01315            N->getOpcode() == ISD::ATOMIC_STORE;
01316   }
01317 };
01318 
01319 /// This SDNode is used for target intrinsics that touch
01320 /// memory and need an associated MachineMemOperand. Its opcode may be
01321 /// INTRINSIC_VOID, INTRINSIC_W_CHAIN, PREFETCH, or a target-specific opcode
01322 /// with a value not less than FIRST_TARGET_MEMORY_OPCODE.
01323 class MemIntrinsicSDNode : public MemSDNode {
01324 public:
01325   MemIntrinsicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
01326                      ArrayRef<SDValue> Ops, EVT MemoryVT,
01327                      MachineMemOperand *MMO)
01328     : MemSDNode(Opc, Order, dl, VTs, Ops, MemoryVT, MMO) {
01329     SubclassData |= 1u << 13;
01330   }
01331 
01332   // Methods to support isa and dyn_cast
01333   static bool classof(const SDNode *N) {
01334     // We lower some target intrinsics to their target opcode
01335     // early a node with a target opcode can be of this class
01336     return N->isMemIntrinsic()             ||
01337            N->getOpcode() == ISD::PREFETCH ||
01338            N->isTargetMemoryOpcode();
01339   }
01340 };
01341 
01342 /// This SDNode is used to implement the code generator
01343 /// support for the llvm IR shufflevector instruction.  It combines elements
01344 /// from two input vectors into a new input vector, with the selection and
01345 /// ordering of elements determined by an array of integers, referred to as
01346 /// the shuffle mask.  For input vectors of width N, mask indices of 0..N-1
01347 /// refer to elements from the LHS input, and indices from N to 2N-1 the RHS.
01348 /// An index of -1 is treated as undef, such that the code generator may put
01349 /// any value in the corresponding element of the result.
01350 class ShuffleVectorSDNode : public SDNode {
01351   SDUse Ops[2];
01352 
01353   // The memory for Mask is owned by the SelectionDAG's OperandAllocator, and
01354   // is freed when the SelectionDAG object is destroyed.
01355   const int *Mask;
01356 protected:
01357   friend class SelectionDAG;
01358   ShuffleVectorSDNode(EVT VT, unsigned Order, DebugLoc dl, SDValue N1,
01359                       SDValue N2, const int *M)
01360     : SDNode(ISD::VECTOR_SHUFFLE, Order, dl, getSDVTList(VT)), Mask(M) {
01361     InitOperands(Ops, N1, N2);
01362   }
01363 public:
01364 
01365   ArrayRef<int> getMask() const {
01366     EVT VT = getValueType(0);
01367     return makeArrayRef(Mask, VT.getVectorNumElements());
01368   }
01369   int getMaskElt(unsigned Idx) const {
01370     assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!");
01371     return Mask[Idx];
01372   }
01373 
01374   bool isSplat() const { return isSplatMask(Mask, getValueType(0)); }
01375   int  getSplatIndex() const {
01376     assert(isSplat() && "Cannot get splat index for non-splat!");
01377     EVT VT = getValueType(0);
01378     for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
01379       if (Mask[i] >= 0)
01380         return Mask[i];
01381     }
01382     llvm_unreachable("Splat with all undef indices?");
01383   }
01384   static bool isSplatMask(const int *Mask, EVT VT);
01385 
01386   /// Change values in a shuffle permute mask assuming
01387   /// the two vector operands have swapped position.
01388   static void commuteMask(SmallVectorImpl<int> &Mask) {
01389     unsigned NumElems = Mask.size();
01390     for (unsigned i = 0; i != NumElems; ++i) {
01391       int idx = Mask[i];
01392       if (idx < 0)
01393         continue;
01394       else if (idx < (int)NumElems)
01395         Mask[i] = idx + NumElems;
01396       else
01397         Mask[i] = idx - NumElems;
01398     }
01399   }
01400 
01401   static bool classof(const SDNode *N) {
01402     return N->getOpcode() == ISD::VECTOR_SHUFFLE;
01403   }
01404 };
01405 
01406 class ConstantSDNode : public SDNode {
01407   const ConstantInt *Value;
01408   friend class SelectionDAG;
01409   ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val,
01410                  DebugLoc DL, EVT VT)
01411     : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant,
01412              0, DL, getSDVTList(VT)), Value(val) {
01413     SubclassData |= (uint16_t)isOpaque;
01414   }
01415 public:
01416 
01417   const ConstantInt *getConstantIntValue() const { return Value; }
01418   const APInt &getAPIntValue() const { return Value->getValue(); }
01419   uint64_t getZExtValue() const { return Value->getZExtValue(); }
01420   int64_t getSExtValue() const { return Value->getSExtValue(); }
01421 
01422   bool isOne() const { return Value->isOne(); }
01423   bool isNullValue() const { return Value->isNullValue(); }
01424   bool isAllOnesValue() const { return Value->isAllOnesValue(); }
01425 
01426   bool isOpaque() const { return SubclassData & 1; }
01427 
01428   static bool classof(const SDNode *N) {
01429     return N->getOpcode() == ISD::Constant ||
01430            N->getOpcode() == ISD::TargetConstant;
01431   }
01432 };
01433 
01434 class ConstantFPSDNode : public SDNode {
01435   const ConstantFP *Value;
01436   friend class SelectionDAG;
01437   ConstantFPSDNode(bool isTarget, const ConstantFP *val, DebugLoc DL, EVT VT)
01438     : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
01439              0, DL, getSDVTList(VT)), Value(val) {
01440   }
01441 public:
01442 
01443   const APFloat& getValueAPF() const { return Value->getValueAPF(); }
01444   const ConstantFP *getConstantFPValue() const { return Value; }
01445 
01446   /// Return true if the value is positive or negative zero.
01447   bool isZero() const { return Value->isZero(); }
01448 
01449   /// Return true if the value is a NaN.
01450   bool isNaN() const { return Value->isNaN(); }
01451 
01452   /// Return true if the value is an infinity
01453   bool isInfinity() const { return Value->isInfinity(); }
01454 
01455   /// Return true if the value is negative.
01456   bool isNegative() const { return Value->isNegative(); }
01457 
01458   /// We don't rely on operator== working on double values, as
01459   /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
01460   /// As such, this method can be used to do an exact bit-for-bit comparison of
01461   /// two floating point values.
01462 
01463   /// We leave the version with the double argument here because it's just so
01464   /// convenient to write "2.0" and the like.  Without this function we'd
01465   /// have to duplicate its logic everywhere it's called.
01466   bool isExactlyValue(double V) const {
01467     bool ignored;
01468     APFloat Tmp(V);
01469     Tmp.convert(Value->getValueAPF().getSemantics(),
01470                 APFloat::rmNearestTiesToEven, &ignored);
01471     return isExactlyValue(Tmp);
01472   }
01473   bool isExactlyValue(const APFloat& V) const;
01474 
01475   static bool isValueValidForType(EVT VT, const APFloat& Val);
01476 
01477   static bool classof(const SDNode *N) {
01478     return N->getOpcode() == ISD::ConstantFP ||
01479            N->getOpcode() == ISD::TargetConstantFP;
01480   }
01481 };
01482 
01483 class GlobalAddressSDNode : public SDNode {
01484   const GlobalValue *TheGlobal;
01485   int64_t Offset;
01486   unsigned char TargetFlags;
01487   friend class SelectionDAG;
01488   GlobalAddressSDNode(unsigned Opc, unsigned Order, DebugLoc DL,
01489                       const GlobalValue *GA, EVT VT, int64_t o,
01490                       unsigned char TargetFlags);
01491 public:
01492 
01493   const GlobalValue *getGlobal() const { return TheGlobal; }
01494   int64_t getOffset() const { return Offset; }
01495   unsigned char getTargetFlags() const { return TargetFlags; }
01496   // Return the address space this GlobalAddress belongs to.
01497   unsigned getAddressSpace() const;
01498 
01499   static bool classof(const SDNode *N) {
01500     return N->getOpcode() == ISD::GlobalAddress ||
01501            N->getOpcode() == ISD::TargetGlobalAddress ||
01502            N->getOpcode() == ISD::GlobalTLSAddress ||
01503            N->getOpcode() == ISD::TargetGlobalTLSAddress;
01504   }
01505 };
01506 
01507 class FrameIndexSDNode : public SDNode {
01508   int FI;
01509   friend class SelectionDAG;
01510   FrameIndexSDNode(int fi, EVT VT, bool isTarg)
01511     : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex,
01512       0, DebugLoc(), getSDVTList(VT)), FI(fi) {
01513   }
01514 public:
01515 
01516   int getIndex() const { return FI; }
01517 
01518   static bool classof(const SDNode *N) {
01519     return N->getOpcode() == ISD::FrameIndex ||
01520            N->getOpcode() == ISD::TargetFrameIndex;
01521   }
01522 };
01523 
01524 class JumpTableSDNode : public SDNode {
01525   int JTI;
01526   unsigned char TargetFlags;
01527   friend class SelectionDAG;
01528   JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF)
01529     : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable,
01530       0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) {
01531   }
01532 public:
01533 
01534   int getIndex() const { return JTI; }
01535   unsigned char getTargetFlags() const { return TargetFlags; }
01536 
01537   static bool classof(const SDNode *N) {
01538     return N->getOpcode() == ISD::JumpTable ||
01539            N->getOpcode() == ISD::TargetJumpTable;
01540   }
01541 };
01542 
01543 class ConstantPoolSDNode : public SDNode {
01544   union {
01545     const Constant *ConstVal;
01546     MachineConstantPoolValue *MachineCPVal;
01547   } Val;
01548   int Offset;  // It's a MachineConstantPoolValue if top bit is set.
01549   unsigned Alignment;  // Minimum alignment requirement of CP (not log2 value).
01550   unsigned char TargetFlags;
01551   friend class SelectionDAG;
01552   ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o,
01553                      unsigned Align, unsigned char TF)
01554     : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
01555              DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align),
01556              TargetFlags(TF) {
01557     assert(Offset >= 0 && "Offset is too large");
01558     Val.ConstVal = c;
01559   }
01560   ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
01561                      EVT VT, int o, unsigned Align, unsigned char TF)
01562     : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
01563              DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align),
01564              TargetFlags(TF) {
01565     assert(Offset >= 0 && "Offset is too large");
01566     Val.MachineCPVal = v;
01567     Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1);
01568   }
01569 public:
01570 
01571   bool isMachineConstantPoolEntry() const {
01572     return Offset < 0;
01573   }
01574 
01575   const Constant *getConstVal() const {
01576     assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
01577     return Val.ConstVal;
01578   }
01579 
01580   MachineConstantPoolValue *getMachineCPVal() const {
01581     assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
01582     return Val.MachineCPVal;
01583   }
01584 
01585   int getOffset() const {
01586     return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1));
01587   }
01588 
01589   // Return the alignment of this constant pool object, which is either 0 (for
01590   // default alignment) or the desired value.
01591   unsigned getAlignment() const { return Alignment; }
01592   unsigned char getTargetFlags() const { return TargetFlags; }
01593 
01594   Type *getType() const;
01595 
01596   static bool classof(const SDNode *N) {
01597     return N->getOpcode() == ISD::ConstantPool ||
01598            N->getOpcode() == ISD::TargetConstantPool;
01599   }
01600 };
01601 
01602 /// Completely target-dependent object reference.
01603 class TargetIndexSDNode : public SDNode {
01604   unsigned char TargetFlags;
01605   int Index;
01606   int64_t Offset;
01607   friend class SelectionDAG;
01608 public:
01609 
01610   TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF)
01611     : SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)),
01612       TargetFlags(TF), Index(Idx), Offset(Ofs) {}
01613 public:
01614 
01615   unsigned char getTargetFlags() const { return TargetFlags; }
01616   int getIndex() const { return Index; }
01617   int64_t getOffset() const { return Offset; }
01618 
01619   static bool classof(const SDNode *N) {
01620     return N->getOpcode() == ISD::TargetIndex;
01621   }
01622 };
01623 
01624 class BasicBlockSDNode : public SDNode {
01625   MachineBasicBlock *MBB;
01626   friend class SelectionDAG;
01627   /// Debug info is meaningful and potentially useful here, but we create
01628   /// blocks out of order when they're jumped to, which makes it a bit
01629   /// harder.  Let's see if we need it first.
01630   explicit BasicBlockSDNode(MachineBasicBlock *mbb)
01631     : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb)
01632   {}
01633 public:
01634 
01635   MachineBasicBlock *getBasicBlock() const { return MBB; }
01636 
01637   static bool classof(const SDNode *N) {
01638     return N->getOpcode() == ISD::BasicBlock;
01639   }
01640 };
01641 
01642 /// A "pseudo-class" with methods for operating on BUILD_VECTORs.
01643 class BuildVectorSDNode : public SDNode {
01644   // These are constructed as SDNodes and then cast to BuildVectorSDNodes.
01645   explicit BuildVectorSDNode() = delete;
01646 public:
01647   /// Check if this is a constant splat, and if so, find the
01648   /// smallest element size that splats the vector.  If MinSplatBits is
01649   /// nonzero, the element size must be at least that large.  Note that the
01650   /// splat element may be the entire vector (i.e., a one element vector).
01651   /// Returns the splat element value in SplatValue.  Any undefined bits in
01652   /// that value are zero, and the corresponding bits in the SplatUndef mask
01653   /// are set.  The SplatBitSize value is set to the splat element size in
01654   /// bits.  HasAnyUndefs is set to true if any bits in the vector are
01655   /// undefined.  isBigEndian describes the endianness of the target.
01656   bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef,
01657                        unsigned &SplatBitSize, bool &HasAnyUndefs,
01658                        unsigned MinSplatBits = 0,
01659                        bool isBigEndian = false) const;
01660 
01661   /// \brief Returns the splatted value or a null value if this is not a splat.
01662   ///
01663   /// If passed a non-null UndefElements bitvector, it will resize it to match
01664   /// the vector width and set the bits where elements are undef.
01665   SDValue getSplatValue(BitVector *UndefElements = nullptr) const;
01666 
01667   /// \brief Returns the splatted constant or null if this is not a constant
01668   /// splat.
01669   ///
01670   /// If passed a non-null UndefElements bitvector, it will resize it to match
01671   /// the vector width and set the bits where elements are undef.
01672   ConstantSDNode *
01673   getConstantSplatNode(BitVector *UndefElements = nullptr) const;
01674 
01675   /// \brief Returns the splatted constant FP or null if this is not a constant
01676   /// FP splat.
01677   ///
01678   /// If passed a non-null UndefElements bitvector, it will resize it to match
01679   /// the vector width and set the bits where elements are undef.
01680   ConstantFPSDNode *
01681   getConstantFPSplatNode(BitVector *UndefElements = nullptr) const;
01682 
01683   bool isConstant() const;
01684 
01685   static inline bool classof(const SDNode *N) {
01686     return N->getOpcode() == ISD::BUILD_VECTOR;
01687   }
01688 };
01689 
01690 /// An SDNode that holds an arbitrary LLVM IR Value. This is
01691 /// used when the SelectionDAG needs to make a simple reference to something
01692 /// in the LLVM IR representation.
01693 ///
01694 class SrcValueSDNode : public SDNode {
01695   const Value *V;
01696   friend class SelectionDAG;
01697   /// Create a SrcValue for a general value.
01698   explicit SrcValueSDNode(const Value *v)
01699     : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {}
01700 
01701 public:
01702   /// Return the contained Value.
01703   const Value *getValue() const { return V; }
01704 
01705   static bool classof(const SDNode *N) {
01706     return N->getOpcode() == ISD::SRCVALUE;
01707   }
01708 };
01709 
01710 class MDNodeSDNode : public SDNode {
01711   const MDNode *MD;
01712   friend class SelectionDAG;
01713   explicit MDNodeSDNode(const MDNode *md)
01714   : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md)
01715   {}
01716 public:
01717 
01718   const MDNode *getMD() const { return MD; }
01719 
01720   static bool classof(const SDNode *N) {
01721     return N->getOpcode() == ISD::MDNODE_SDNODE;
01722   }
01723 };
01724 
01725 class RegisterSDNode : public SDNode {
01726   unsigned Reg;
01727   friend class SelectionDAG;
01728   RegisterSDNode(unsigned reg, EVT VT)
01729     : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {
01730   }
01731 public:
01732 
01733   unsigned getReg() const { return Reg; }
01734 
01735   static bool classof(const SDNode *N) {
01736     return N->getOpcode() == ISD::Register;
01737   }
01738 };
01739 
01740 class RegisterMaskSDNode : public SDNode {
01741   // The memory for RegMask is not owned by the node.
01742   const uint32_t *RegMask;
01743   friend class SelectionDAG;
01744   RegisterMaskSDNode(const uint32_t *mask)
01745     : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)),
01746       RegMask(mask) {}
01747 public:
01748 
01749   const uint32_t *getRegMask() const { return RegMask; }
01750 
01751   static bool classof(const SDNode *N) {
01752     return N->getOpcode() == ISD::RegisterMask;
01753   }
01754 };
01755 
01756 class BlockAddressSDNode : public SDNode {
01757   const BlockAddress *BA;
01758   int64_t Offset;
01759   unsigned char TargetFlags;
01760   friend class SelectionDAG;
01761   BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba,
01762                      int64_t o, unsigned char Flags)
01763     : SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)),
01764              BA(ba), Offset(o), TargetFlags(Flags) {
01765   }
01766 public:
01767   const BlockAddress *getBlockAddress() const { return BA; }
01768   int64_t getOffset() const { return Offset; }
01769   unsigned char getTargetFlags() const { return TargetFlags; }
01770 
01771   static bool classof(const SDNode *N) {
01772     return N->getOpcode() == ISD::BlockAddress ||
01773            N->getOpcode() == ISD::TargetBlockAddress;
01774   }
01775 };
01776 
01777 class EHLabelSDNode : public SDNode {
01778   SDUse Chain;
01779   MCSymbol *Label;
01780   friend class SelectionDAG;
01781   EHLabelSDNode(unsigned Order, DebugLoc dl, SDValue ch, MCSymbol *L)
01782     : SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {
01783     InitOperands(&Chain, ch);
01784   }
01785 public:
01786   MCSymbol *getLabel() const { return Label; }
01787 
01788   static bool classof(const SDNode *N) {
01789     return N->getOpcode() == ISD::EH_LABEL;
01790   }
01791 };
01792 
01793 class ExternalSymbolSDNode : public SDNode {
01794   const char *Symbol;
01795   unsigned char TargetFlags;
01796 
01797   friend class SelectionDAG;
01798   ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT)
01799     : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
01800              0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) {
01801   }
01802 public:
01803 
01804   const char *getSymbol() const { return Symbol; }
01805   unsigned char getTargetFlags() const { return TargetFlags; }
01806 
01807   static bool classof(const SDNode *N) {
01808     return N->getOpcode() == ISD::ExternalSymbol ||
01809            N->getOpcode() == ISD::TargetExternalSymbol;
01810   }
01811 };
01812 
01813 class MCSymbolSDNode : public SDNode {
01814   MCSymbol *Symbol;
01815 
01816   friend class SelectionDAG;
01817   MCSymbolSDNode(MCSymbol *Symbol, EVT VT)
01818       : SDNode(ISD::MCSymbol, 0, DebugLoc(), getSDVTList(VT)), Symbol(Symbol) {}
01819 
01820 public:
01821   MCSymbol *getMCSymbol() const { return Symbol; }
01822 
01823   static bool classof(const SDNode *N) {
01824     return N->getOpcode() == ISD::MCSymbol;
01825   }
01826 };
01827 
01828 class CondCodeSDNode : public SDNode {
01829   ISD::CondCode Condition;
01830   friend class SelectionDAG;
01831   explicit CondCodeSDNode(ISD::CondCode Cond)
01832     : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)),
01833       Condition(Cond) {
01834   }
01835 public:
01836 
01837   ISD::CondCode get() const { return Condition; }
01838 
01839   static bool classof(const SDNode *N) {
01840     return N->getOpcode() == ISD::CONDCODE;
01841   }
01842 };
01843 
01844 /// NOTE: avoid using this node as this may disappear in the
01845 /// future and most targets don't support it.
01846 class CvtRndSatSDNode : public SDNode {
01847   ISD::CvtCode CvtCode;
01848   friend class SelectionDAG;
01849   explicit CvtRndSatSDNode(EVT VT, unsigned Order, DebugLoc dl,
01850                            ArrayRef<SDValue> Ops, ISD::CvtCode Code)
01851     : SDNode(ISD::CONVERT_RNDSAT, Order, dl, getSDVTList(VT), Ops),
01852       CvtCode(Code) {
01853     assert(Ops.size() == 5 && "wrong number of operations");
01854   }
01855 public:
01856   ISD::CvtCode getCvtCode() const { return CvtCode; }
01857 
01858   static bool classof(const SDNode *N) {
01859     return N->getOpcode() == ISD::CONVERT_RNDSAT;
01860   }
01861 };
01862 
01863 /// This class is used to represent EVT's, which are used
01864 /// to parameterize some operations.
01865 class VTSDNode : public SDNode {
01866   EVT ValueType;
01867   friend class SelectionDAG;
01868   explicit VTSDNode(EVT VT)
01869     : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)),
01870       ValueType(VT) {
01871   }
01872 public:
01873 
01874   EVT getVT() const { return ValueType; }
01875 
01876   static bool classof(const SDNode *N) {
01877     return N->getOpcode() == ISD::VALUETYPE;
01878   }
01879 };
01880 
01881 /// Base class for LoadSDNode and StoreSDNode
01882 class LSBaseSDNode : public MemSDNode {
01883   //! Operand array for load and store
01884   /*!
01885     \note Moving this array to the base class captures more
01886     common functionality shared between LoadSDNode and
01887     StoreSDNode
01888    */
01889   SDUse Ops[4];
01890 public:
01891   LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, DebugLoc dl,
01892                SDValue *Operands, unsigned numOperands,
01893                SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT,
01894                MachineMemOperand *MMO)
01895     : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
01896     SubclassData |= AM << 2;
01897     assert(getAddressingMode() == AM && "MemIndexedMode encoding error!");
01898     InitOperands(Ops, Operands, numOperands);
01899     assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
01900            "Only indexed loads and stores have a non-undef offset operand");
01901   }
01902 
01903   const SDValue &getOffset() const {
01904     return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
01905   }
01906 
01907   /// Return the addressing mode for this load or store:
01908   /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
01909   ISD::MemIndexedMode getAddressingMode() const {
01910     return ISD::MemIndexedMode((SubclassData >> 2) & 7);
01911   }
01912 
01913   /// Return true if this is a pre/post inc/dec load/store.
01914   bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
01915 
01916   /// Return true if this is NOT a pre/post inc/dec load/store.
01917   bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
01918 
01919   static bool classof(const SDNode *N) {
01920     return N->getOpcode() == ISD::LOAD ||
01921            N->getOpcode() == ISD::STORE;
01922   }
01923 };
01924 
01925 /// This class is used to represent ISD::LOAD nodes.
01926 class LoadSDNode : public LSBaseSDNode {
01927   friend class SelectionDAG;
01928   LoadSDNode(SDValue *ChainPtrOff, unsigned Order, DebugLoc dl, SDVTList VTs,
01929              ISD::MemIndexedMode AM, ISD::LoadExtType ETy, EVT MemVT,
01930              MachineMemOperand *MMO)
01931     : LSBaseSDNode(ISD::LOAD, Order, dl, ChainPtrOff, 3, VTs, AM, MemVT, MMO) {
01932     SubclassData |= (unsigned short)ETy;
01933     assert(getExtensionType() == ETy && "LoadExtType encoding error!");
01934     assert(readMem() && "Load MachineMemOperand is not a load!");
01935     assert(!writeMem() && "Load MachineMemOperand is a store!");
01936   }
01937 public:
01938 
01939   /// Return whether this is a plain node,
01940   /// or one of the varieties of value-extending loads.
01941   ISD::LoadExtType getExtensionType() const {
01942     return ISD::LoadExtType(SubclassData & 3);
01943   }
01944 
01945   const SDValue &getBasePtr() const { return getOperand(1); }
01946   const SDValue &getOffset() const { return getOperand(2); }
01947 
01948   static bool classof(const SDNode *N) {
01949     return N->getOpcode() == ISD::LOAD;
01950   }
01951 };
01952 
01953 /// This class is used to represent ISD::STORE nodes.
01954 class StoreSDNode : public LSBaseSDNode {
01955   friend class SelectionDAG;
01956   StoreSDNode(SDValue *ChainValuePtrOff, unsigned Order, DebugLoc dl,
01957               SDVTList VTs, ISD::MemIndexedMode AM, bool isTrunc, EVT MemVT,
01958               MachineMemOperand *MMO)
01959     : LSBaseSDNode(ISD::STORE, Order, dl, ChainValuePtrOff, 4,
01960                    VTs, AM, MemVT, MMO) {
01961     SubclassData |= (unsigned short)isTrunc;
01962     assert(isTruncatingStore() == isTrunc && "isTrunc encoding error!");
01963     assert(!readMem() && "Store MachineMemOperand is a load!");
01964     assert(writeMem() && "Store MachineMemOperand is not a store!");
01965   }
01966 public:
01967 
01968   /// Return true if the op does a truncation before store.
01969   /// For integers this is the same as doing a TRUNCATE and storing the result.
01970   /// For floats, it is the same as doing an FP_ROUND and storing the result.
01971   bool isTruncatingStore() const { return SubclassData & 1; }
01972 
01973   const SDValue &getValue() const { return getOperand(1); }
01974   const SDValue &getBasePtr() const { return getOperand(2); }
01975   const SDValue &getOffset() const { return getOperand(3); }
01976 
01977   static bool classof(const SDNode *N) {
01978     return N->getOpcode() == ISD::STORE;
01979   }
01980 };
01981 
01982 /// This base class is used to represent MLOAD and MSTORE nodes
01983 class MaskedLoadStoreSDNode : public MemSDNode {
01984   // Operands
01985   SDUse Ops[4];
01986 public:
01987   friend class SelectionDAG;
01988   MaskedLoadStoreSDNode(ISD::NodeType NodeTy, unsigned Order, DebugLoc dl,
01989                    SDValue *Operands, unsigned numOperands, 
01990                    SDVTList VTs, EVT MemVT, MachineMemOperand *MMO)
01991     : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
01992     InitOperands(Ops, Operands, numOperands);
01993   }
01994 
01995   // In the both nodes address is Op1, mask is Op2:
01996   // MaskedLoadSDNode (Chain, ptr, mask, src0), src0 is a passthru value
01997   // MaskedStoreSDNode (Chain, ptr, mask, data)
01998   // Mask is a vector of i1 elements
01999   const SDValue &getBasePtr() const { return getOperand(1); }
02000   const SDValue &getMask() const    { return getOperand(2); }
02001 
02002   static bool classof(const SDNode *N) {
02003     return N->getOpcode() == ISD::MLOAD ||
02004            N->getOpcode() == ISD::MSTORE;
02005   }
02006 };
02007 
02008 /// This class is used to represent an MLOAD node
02009 class MaskedLoadSDNode : public MaskedLoadStoreSDNode {
02010 public:
02011   friend class SelectionDAG;
02012   MaskedLoadSDNode(unsigned Order, DebugLoc dl, SDValue *Operands,
02013                    unsigned numOperands, SDVTList VTs, ISD::LoadExtType ETy,
02014                    EVT MemVT, MachineMemOperand *MMO)
02015     : MaskedLoadStoreSDNode(ISD::MLOAD, Order, dl, Operands, numOperands,
02016                             VTs, MemVT, MMO) {
02017     SubclassData |= (unsigned short)ETy;
02018   }
02019 
02020   ISD::LoadExtType getExtensionType() const {
02021     return ISD::LoadExtType(SubclassData & 3);
02022   } 
02023   const SDValue &getSrc0() const { return getOperand(3); }
02024   static bool classof(const SDNode *N) {
02025     return N->getOpcode() == ISD::MLOAD;
02026   }
02027 };
02028 
02029 /// This class is used to represent an MSTORE node
02030 class MaskedStoreSDNode : public MaskedLoadStoreSDNode {
02031 
02032 public:
02033   friend class SelectionDAG;
02034   MaskedStoreSDNode(unsigned Order, DebugLoc dl, SDValue *Operands,
02035                     unsigned numOperands, SDVTList VTs, bool isTrunc, EVT MemVT,
02036                     MachineMemOperand *MMO)
02037     : MaskedLoadStoreSDNode(ISD::MSTORE, Order, dl, Operands, numOperands,
02038                             VTs, MemVT, MMO) {
02039       SubclassData |= (unsigned short)isTrunc;
02040   }
02041   /// Return true if the op does a truncation before store.
02042   /// For integers this is the same as doing a TRUNCATE and storing the result.
02043   /// For floats, it is the same as doing an FP_ROUND and storing the result.
02044   bool isTruncatingStore() const { return SubclassData & 1; }
02045 
02046   const SDValue &getValue() const { return getOperand(3); }
02047 
02048   static bool classof(const SDNode *N) {
02049     return N->getOpcode() == ISD::MSTORE;
02050   }
02051 };
02052 
02053 /// This is a base class used to represent
02054 /// MGATHER and MSCATTER nodes
02055 ///
02056 class MaskedGatherScatterSDNode : public MemSDNode {
02057   // Operands
02058   SDUse Ops[5];
02059 public:
02060   friend class SelectionDAG;
02061   MaskedGatherScatterSDNode(ISD::NodeType NodeTy, unsigned Order, DebugLoc dl,
02062                             ArrayRef<SDValue> Operands, SDVTList VTs, EVT MemVT,
02063                             MachineMemOperand *MMO)
02064     : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
02065     assert(Operands.size() == 5 && "Incompatible number of operands");
02066     InitOperands(Ops, Operands.data(), Operands.size());
02067   }
02068 
02069   // In the both nodes address is Op1, mask is Op2:
02070   // MaskedGatherSDNode  (Chain, src0, mask, base, index), src0 is a passthru value
02071   // MaskedScatterSDNode (Chain, value, mask, base, index)
02072   // Mask is a vector of i1 elements
02073   const SDValue &getBasePtr() const { return getOperand(3); }
02074   const SDValue &getIndex()   const { return getOperand(4); }
02075   const SDValue &getMask()    const { return getOperand(2); }
02076   const SDValue &getValue()   const { return getOperand(1); }
02077 
02078   static bool classof(const SDNode *N) {
02079     return N->getOpcode() == ISD::MGATHER ||
02080            N->getOpcode() == ISD::MSCATTER;
02081   }
02082 };
02083 
02084 /// This class is used to represent an MGATHER node
02085 ///
02086 class MaskedGatherSDNode : public MaskedGatherScatterSDNode {
02087 public:
02088   friend class SelectionDAG;
02089   MaskedGatherSDNode(unsigned Order, DebugLoc dl, ArrayRef<SDValue> Operands, 
02090                      SDVTList VTs, EVT MemVT, MachineMemOperand *MMO)
02091     : MaskedGatherScatterSDNode(ISD::MGATHER, Order, dl, Operands, VTs, MemVT,
02092                                 MMO) {
02093     assert(getValue().getValueType() == getValueType(0) &&
02094            "Incompatible type of the PathThru value in MaskedGatherSDNode");
02095     assert(getMask().getValueType().getVectorNumElements() == 
02096            getValueType(0).getVectorNumElements() && 
02097            "Vector width mismatch between mask and data");
02098     assert(getMask().getValueType().getScalarType() == MVT::i1 && 
02099            "Vector width mismatch between mask and data");
02100   }
02101 
02102   static bool classof(const SDNode *N) {
02103     return N->getOpcode() == ISD::MGATHER;
02104   }
02105 };
02106 
02107 /// This class is used to represent an MSCATTER node
02108 ///
02109 class MaskedScatterSDNode : public MaskedGatherScatterSDNode {
02110 
02111 public:
02112   friend class SelectionDAG;
02113   MaskedScatterSDNode(unsigned Order, DebugLoc dl,ArrayRef<SDValue> Operands,
02114                       SDVTList VTs, EVT MemVT, MachineMemOperand *MMO)
02115     : MaskedGatherScatterSDNode(ISD::MSCATTER, Order, dl, Operands, VTs, MemVT,
02116                                 MMO) {
02117     assert(getMask().getValueType().getVectorNumElements() == 
02118            getValue().getValueType().getVectorNumElements() && 
02119            "Vector width mismatch between mask and data");
02120     assert(getMask().getValueType().getScalarType() == MVT::i1 && 
02121            "Vector width mismatch between mask and data");
02122   }
02123 
02124   static bool classof(const SDNode *N) {
02125     return N->getOpcode() == ISD::MSCATTER;
02126   }
02127 };
02128 
02129 /// An SDNode that represents everything that will be needed
02130 /// to construct a MachineInstr. These nodes are created during the
02131 /// instruction selection proper phase.
02132 class MachineSDNode : public SDNode {
02133 public:
02134   typedef MachineMemOperand **mmo_iterator;
02135 
02136 private:
02137   friend class SelectionDAG;
02138   MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc DL, SDVTList VTs)
02139     : SDNode(Opc, Order, DL, VTs), MemRefs(nullptr), MemRefsEnd(nullptr) {}
02140 
02141   /// Operands for this instruction, if they fit here. If
02142   /// they don't, this field is unused.
02143   SDUse LocalOperands[4];
02144 
02145   /// Memory reference descriptions for this instruction.
02146   mmo_iterator MemRefs;
02147   mmo_iterator MemRefsEnd;
02148 
02149 public:
02150   mmo_iterator memoperands_begin() const { return MemRefs; }
02151   mmo_iterator memoperands_end() const { return MemRefsEnd; }
02152   bool memoperands_empty() const { return MemRefsEnd == MemRefs; }
02153 
02154   /// Assign this MachineSDNodes's memory reference descriptor
02155   /// list. This does not transfer ownership.
02156   void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd) {
02157     for (mmo_iterator MMI = NewMemRefs, MME = NewMemRefsEnd; MMI != MME; ++MMI)
02158       assert(*MMI && "Null mem ref detected!");
02159     MemRefs = NewMemRefs;
02160     MemRefsEnd = NewMemRefsEnd;
02161   }
02162 
02163   static bool classof(const SDNode *N) {
02164     return N->isMachineOpcode();
02165   }
02166 };
02167 
02168 class SDNodeIterator : public std::iterator<std::forward_iterator_tag,
02169                                             SDNode, ptrdiff_t> {
02170   const SDNode *Node;
02171   unsigned Operand;
02172 
02173   SDNodeIterator(const SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
02174 public:
02175   bool operator==(const SDNodeIterator& x) const {
02176     return Operand == x.Operand;
02177   }
02178   bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
02179 
02180   pointer operator*() const {
02181     return Node->getOperand(Operand).getNode();
02182   }
02183   pointer operator->() const { return operator*(); }
02184 
02185   SDNodeIterator& operator++() {                // Preincrement
02186     ++Operand;
02187     return *this;
02188   }
02189   SDNodeIterator operator++(int) { // Postincrement
02190     SDNodeIterator tmp = *this; ++*this; return tmp;
02191   }
02192   size_t operator-(SDNodeIterator Other) const {
02193     assert(Node == Other.Node &&
02194            "Cannot compare iterators of two different nodes!");
02195     return Operand - Other.Operand;
02196   }
02197 
02198   static SDNodeIterator begin(const SDNode *N) { return SDNodeIterator(N, 0); }
02199   static SDNodeIterator end  (const SDNode *N) {
02200     return SDNodeIterator(N, N->getNumOperands());
02201   }
02202 
02203   unsigned getOperand() const { return Operand; }
02204   const SDNode *getNode() const { return Node; }
02205 };
02206 
02207 template <> struct GraphTraits<SDNode*> {
02208   typedef SDNode NodeType;
02209   typedef SDNodeIterator ChildIteratorType;
02210   static inline NodeType *getEntryNode(SDNode *N) { return N; }
02211   static inline ChildIteratorType child_begin(NodeType *N) {
02212     return SDNodeIterator::begin(N);
02213   }
02214   static inline ChildIteratorType child_end(NodeType *N) {
02215     return SDNodeIterator::end(N);
02216   }
02217 };
02218 
02219 /// The largest SDNode class.
02220 typedef MaskedGatherScatterSDNode LargestSDNode;
02221 
02222 /// The SDNode class with the greatest alignment requirement.
02223 typedef GlobalAddressSDNode MostAlignedSDNode;
02224 
02225 namespace ISD {
02226   /// Returns true if the specified node is a non-extending and unindexed load.
02227   inline bool isNormalLoad(const SDNode *N) {
02228     const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
02229     return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
02230       Ld->getAddressingMode() == ISD::UNINDEXED;
02231   }
02232 
02233   /// Returns true if the specified node is a non-extending load.
02234   inline bool isNON_EXTLoad(const SDNode *N) {
02235     return isa<LoadSDNode>(N) &&
02236       cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
02237   }
02238 
02239   /// Returns true if the specified node is a EXTLOAD.
02240   inline bool isEXTLoad(const SDNode *N) {
02241     return isa<LoadSDNode>(N) &&
02242       cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
02243   }
02244 
02245   /// Returns true if the specified node is a SEXTLOAD.
02246   inline bool isSEXTLoad(const SDNode *N) {
02247     return isa<LoadSDNode>(N) &&
02248       cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
02249   }
02250 
02251   /// Returns true if the specified node is a ZEXTLOAD.
02252   inline bool isZEXTLoad(const SDNode *N) {
02253     return isa<LoadSDNode>(N) &&
02254       cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
02255   }
02256 
02257   /// Returns true if the specified node is an unindexed load.
02258   inline bool isUNINDEXEDLoad(const SDNode *N) {
02259     return isa<LoadSDNode>(N) &&
02260       cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
02261   }
02262 
02263   /// Returns true if the specified node is a non-truncating
02264   /// and unindexed store.
02265   inline bool isNormalStore(const SDNode *N) {
02266     const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
02267     return St && !St->isTruncatingStore() &&
02268       St->getAddressingMode() == ISD::UNINDEXED;
02269   }
02270 
02271   /// Returns true if the specified node is a non-truncating store.
02272   inline bool isNON_TRUNCStore(const SDNode *N) {
02273     return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
02274   }
02275 
02276   /// Returns true if the specified node is a truncating store.
02277   inline bool isTRUNCStore(const SDNode *N) {
02278     return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
02279   }
02280 
02281   /// Returns true if the specified node is an unindexed store.
02282   inline bool isUNINDEXEDStore(const SDNode *N) {
02283     return isa<StoreSDNode>(N) &&
02284       cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
02285   }
02286 }
02287 
02288 } // end llvm namespace
02289 
02290 #endif