1 //===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file declares the SDNode class and derived classes, which are used to 11 // represent the nodes and operations present in a SelectionDAG. These nodes 12 // and operations are machine code level operations, with some similarities to 13 // the GCC RTL representation. 14 // 15 // Clients should include the SelectionDAG.h file instead of this file directly. 16 // 17 //===----------------------------------------------------------------------===// 18 19 #ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H 20 #define LLVM_CODEGEN_SELECTIONDAGNODES_H 21 22 #include "llvm/Constants.h" 23 #include "llvm/ADT/FoldingSet.h" 24 #include "llvm/ADT/GraphTraits.h" 25 #include "llvm/ADT/ilist_node.h" 26 #include "llvm/ADT/SmallPtrSet.h" 27 #include "llvm/ADT/SmallVector.h" 28 #include "llvm/ADT/STLExtras.h" 29 #include "llvm/CodeGen/ISDOpcodes.h" 30 #include "llvm/CodeGen/ValueTypes.h" 31 #include "llvm/CodeGen/MachineMemOperand.h" 32 #include "llvm/Support/MathExtras.h" 33 #include "llvm/Support/DataTypes.h" 34 #include "llvm/Support/DebugLoc.h" 35 #include <cassert> 36 37 namespace llvm { 38 39 class SelectionDAG; 40 class GlobalValue; 41 class MachineBasicBlock; 42 class MachineConstantPoolValue; 43 class SDNode; 44 class Value; 45 class MCSymbol; 46 template <typename T> struct DenseMapInfo; 47 template <typename T> struct simplify_type; 48 template <typename T> struct ilist_traits; 49 50 void checkForCycles(const SDNode *N); 51 52 /// SDVTList - This represents a list of ValueType's that has been intern'd by 53 /// a SelectionDAG. Instances of this simple value class are returned by 54 /// SelectionDAG::getVTList(...). 55 /// 56 struct SDVTList { 57 const EVT *VTs; 58 unsigned int NumVTs; 59 }; 60 61 namespace ISD { 62 /// Node predicates 63 64 /// isBuildVectorAllOnes - Return true if the specified node is a 65 /// BUILD_VECTOR where all of the elements are ~0 or undef. 66 bool isBuildVectorAllOnes(const SDNode *N); 67 68 /// isBuildVectorAllZeros - Return true if the specified node is a 69 /// BUILD_VECTOR where all of the elements are 0 or undef. 70 bool isBuildVectorAllZeros(const SDNode *N); 71 72 /// isScalarToVector - Return true if the specified node is a 73 /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low 74 /// element is not an undef. 75 bool isScalarToVector(const SDNode *N); 76 } // end llvm:ISD namespace 77 78 //===----------------------------------------------------------------------===// 79 /// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple 80 /// values as the result of a computation. Many nodes return multiple values, 81 /// from loads (which define a token and a return value) to ADDC (which returns 82 /// a result and a carry value), to calls (which may return an arbitrary number 83 /// of values). 84 /// 85 /// As such, each use of a SelectionDAG computation must indicate the node that 86 /// computes it as well as which return value to use from that node. This pair 87 /// of information is represented with the SDValue value type. 88 /// 89 class SDValue { 90 SDNode *Node; // The node defining the value we are using. 91 unsigned ResNo; // Which return value of the node we are using. 92 public: 93 SDValue() : Node(0), ResNo(0) {} 94 SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {} 95 96 /// get the index which selects a specific result in the SDNode 97 unsigned getResNo() const { return ResNo; } 98 99 /// get the SDNode which holds the desired result 100 SDNode *getNode() const { return Node; } 101 102 /// set the SDNode 103 void setNode(SDNode *N) { Node = N; } 104 105 inline SDNode *operator->() const { return Node; } 106 107 bool operator==(const SDValue &O) const { 108 return Node == O.Node && ResNo == O.ResNo; 109 } 110 bool operator!=(const SDValue &O) const { 111 return !operator==(O); 112 } 113 bool operator<(const SDValue &O) const { 114 return Node < O.Node || (Node == O.Node && ResNo < O.ResNo); 115 } 116 117 SDValue getValue(unsigned R) const { 118 return SDValue(Node, R); 119 } 120 121 // isOperandOf - Return true if this node is an operand of N. 122 bool isOperandOf(SDNode *N) const; 123 124 /// getValueType - Return the ValueType of the referenced return value. 125 /// 126 inline EVT getValueType() const; 127 128 /// getValueSizeInBits - Returns the size of the value in bits. 129 /// 130 unsigned getValueSizeInBits() const { 131 return getValueType().getSizeInBits(); 132 } 133 134 // Forwarding methods - These forward to the corresponding methods in SDNode. 135 inline unsigned getOpcode() const; 136 inline unsigned getNumOperands() const; 137 inline const SDValue &getOperand(unsigned i) const; 138 inline uint64_t getConstantOperandVal(unsigned i) const; 139 inline bool isTargetMemoryOpcode() const; 140 inline bool isTargetOpcode() const; 141 inline bool isMachineOpcode() const; 142 inline unsigned getMachineOpcode() const; 143 inline const DebugLoc getDebugLoc() const; 144 145 146 /// reachesChainWithoutSideEffects - Return true if this operand (which must 147 /// be a chain) reaches the specified operand without crossing any 148 /// side-effecting instructions. In practice, this looks through token 149 /// factors and non-volatile loads. In order to remain efficient, this only 150 /// looks a couple of nodes in, it does not do an exhaustive search. 151 bool reachesChainWithoutSideEffects(SDValue Dest, 152 unsigned Depth = 2) const; 153 154 /// use_empty - Return true if there are no nodes using value ResNo 155 /// of Node. 156 /// 157 inline bool use_empty() const; 158 159 /// hasOneUse - Return true if there is exactly one node using value 160 /// ResNo of Node. 161 /// 162 inline bool hasOneUse() const; 163 }; 164 165 166 template<> struct DenseMapInfo<SDValue> { 167 static inline SDValue getEmptyKey() { 168 return SDValue((SDNode*)-1, -1U); 169 } 170 static inline SDValue getTombstoneKey() { 171 return SDValue((SDNode*)-1, 0); 172 } 173 static unsigned getHashValue(const SDValue &Val) { 174 return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^ 175 (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo(); 176 } 177 static bool isEqual(const SDValue &LHS, const SDValue &RHS) { 178 return LHS == RHS; 179 } 180 }; 181 template <> struct isPodLike<SDValue> { static const bool value = true; }; 182 183 184 /// simplify_type specializations - Allow casting operators to work directly on 185 /// SDValues as if they were SDNode*'s. 186 template<> struct simplify_type<SDValue> { 187 typedef SDNode* SimpleType; 188 static SimpleType getSimplifiedValue(const SDValue &Val) { 189 return static_cast<SimpleType>(Val.getNode()); 190 } 191 }; 192 template<> struct simplify_type<const SDValue> { 193 typedef SDNode* SimpleType; 194 static SimpleType getSimplifiedValue(const SDValue &Val) { 195 return static_cast<SimpleType>(Val.getNode()); 196 } 197 }; 198 199 /// SDUse - Represents a use of a SDNode. This class holds an SDValue, 200 /// which records the SDNode being used and the result number, a 201 /// pointer to the SDNode using the value, and Next and Prev pointers, 202 /// which link together all the uses of an SDNode. 203 /// 204 class SDUse { 205 /// Val - The value being used. 206 SDValue Val; 207 /// User - The user of this value. 208 SDNode *User; 209 /// Prev, Next - Pointers to the uses list of the SDNode referred by 210 /// this operand. 211 SDUse **Prev, *Next; 212 213 SDUse(const SDUse &U); // Do not implement 214 void operator=(const SDUse &U); // Do not implement 215 216 public: 217 SDUse() : Val(), User(NULL), Prev(NULL), Next(NULL) {} 218 219 /// Normally SDUse will just implicitly convert to an SDValue that it holds. 220 operator const SDValue&() const { return Val; } 221 222 /// If implicit conversion to SDValue doesn't work, the get() method returns 223 /// the SDValue. 224 const SDValue &get() const { return Val; } 225 226 /// getUser - This returns the SDNode that contains this Use. 227 SDNode *getUser() { return User; } 228 229 /// getNext - Get the next SDUse in the use list. 230 SDUse *getNext() const { return Next; } 231 232 /// getNode - Convenience function for get().getNode(). 233 SDNode *getNode() const { return Val.getNode(); } 234 /// getResNo - Convenience function for get().getResNo(). 235 unsigned getResNo() const { return Val.getResNo(); } 236 /// getValueType - Convenience function for get().getValueType(). 237 EVT getValueType() const { return Val.getValueType(); } 238 239 /// operator== - Convenience function for get().operator== 240 bool operator==(const SDValue &V) const { 241 return Val == V; 242 } 243 244 /// operator!= - Convenience function for get().operator!= 245 bool operator!=(const SDValue &V) const { 246 return Val != V; 247 } 248 249 /// operator< - Convenience function for get().operator< 250 bool operator<(const SDValue &V) const { 251 return Val < V; 252 } 253 254 private: 255 friend class SelectionDAG; 256 friend class SDNode; 257 258 void setUser(SDNode *p) { User = p; } 259 260 /// set - Remove this use from its existing use list, assign it the 261 /// given value, and add it to the new value's node's use list. 262 inline void set(const SDValue &V); 263 /// setInitial - like set, but only supports initializing a newly-allocated 264 /// SDUse with a non-null value. 265 inline void setInitial(const SDValue &V); 266 /// setNode - like set, but only sets the Node portion of the value, 267 /// leaving the ResNo portion unmodified. 268 inline void setNode(SDNode *N); 269 270 void addToList(SDUse **List) { 271 Next = *List; 272 if (Next) Next->Prev = &Next; 273 Prev = List; 274 *List = this; 275 } 276 277 void removeFromList() { 278 *Prev = Next; 279 if (Next) Next->Prev = Prev; 280 } 281 }; 282 283 /// simplify_type specializations - Allow casting operators to work directly on 284 /// SDValues as if they were SDNode*'s. 285 template<> struct simplify_type<SDUse> { 286 typedef SDNode* SimpleType; 287 static SimpleType getSimplifiedValue(const SDUse &Val) { 288 return static_cast<SimpleType>(Val.getNode()); 289 } 290 }; 291 template<> struct simplify_type<const SDUse> { 292 typedef SDNode* SimpleType; 293 static SimpleType getSimplifiedValue(const SDUse &Val) { 294 return static_cast<SimpleType>(Val.getNode()); 295 } 296 }; 297 298 299 /// SDNode - Represents one node in the SelectionDAG. 300 /// 301 class SDNode : public FoldingSetNode, public ilist_node<SDNode> { 302 private: 303 /// NodeType - The operation that this node performs. 304 /// 305 int16_t NodeType; 306 307 /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true, 308 /// then they will be delete[]'d when the node is destroyed. 309 uint16_t OperandsNeedDelete : 1; 310 311 /// HasDebugValue - This tracks whether this node has one or more dbg_value 312 /// nodes corresponding to it. 313 uint16_t HasDebugValue : 1; 314 315 protected: 316 /// SubclassData - This member is defined by this class, but is not used for 317 /// anything. Subclasses can use it to hold whatever state they find useful. 318 /// This field is initialized to zero by the ctor. 319 uint16_t SubclassData : 14; 320 321 private: 322 /// NodeId - Unique id per SDNode in the DAG. 323 int NodeId; 324 325 /// OperandList - The values that are used by this operation. 326 /// 327 SDUse *OperandList; 328 329 /// ValueList - The types of the values this node defines. SDNode's may 330 /// define multiple values simultaneously. 331 const EVT *ValueList; 332 333 /// UseList - List of uses for this SDNode. 334 SDUse *UseList; 335 336 /// NumOperands/NumValues - The number of entries in the Operand/Value list. 337 unsigned short NumOperands, NumValues; 338 339 /// debugLoc - source line information. 340 DebugLoc debugLoc; 341 342 /// getValueTypeList - Return a pointer to the specified value type. 343 static const EVT *getValueTypeList(EVT VT); 344 345 friend class SelectionDAG; 346 friend struct ilist_traits<SDNode>; 347 348 public: 349 //===--------------------------------------------------------------------===// 350 // Accessors 351 // 352 353 /// getOpcode - Return the SelectionDAG opcode value for this node. For 354 /// pre-isel nodes (those for which isMachineOpcode returns false), these 355 /// are the opcode values in the ISD and <target>ISD namespaces. For 356 /// post-isel opcodes, see getMachineOpcode. 357 unsigned getOpcode() const { return (unsigned short)NodeType; } 358 359 /// isTargetOpcode - Test if this node has a target-specific opcode (in the 360 /// \<target\>ISD namespace). 361 bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } 362 363 /// isTargetMemoryOpcode - Test if this node has a target-specific 364 /// memory-referencing opcode (in the \<target\>ISD namespace and 365 /// greater than FIRST_TARGET_MEMORY_OPCODE). 366 bool isTargetMemoryOpcode() const { 367 return NodeType >= ISD::FIRST_TARGET_MEMORY_OPCODE; 368 } 369 370 /// isMachineOpcode - Test if this node has a post-isel opcode, directly 371 /// corresponding to a MachineInstr opcode. 372 bool isMachineOpcode() const { return NodeType < 0; } 373 374 /// getMachineOpcode - This may only be called if isMachineOpcode returns 375 /// true. It returns the MachineInstr opcode value that the node's opcode 376 /// corresponds to. 377 unsigned getMachineOpcode() const { 378 assert(isMachineOpcode() && "Not a MachineInstr opcode!"); 379 return ~NodeType; 380 } 381 382 /// getHasDebugValue - get this bit. 383 bool getHasDebugValue() const { return HasDebugValue; } 384 385 /// setHasDebugValue - set this bit. 386 void setHasDebugValue(bool b) { HasDebugValue = b; } 387 388 /// use_empty - Return true if there are no uses of this node. 389 /// 390 bool use_empty() const { return UseList == NULL; } 391 392 /// hasOneUse - Return true if there is exactly one use of this node. 393 /// 394 bool hasOneUse() const { 395 return !use_empty() && llvm::next(use_begin()) == use_end(); 396 } 397 398 /// use_size - Return the number of uses of this node. This method takes 399 /// time proportional to the number of uses. 400 /// 401 size_t use_size() const { return std::distance(use_begin(), use_end()); } 402 403 /// getNodeId - Return the unique node id. 404 /// 405 int getNodeId() const { return NodeId; } 406 407 /// setNodeId - Set unique node id. 408 void setNodeId(int Id) { NodeId = Id; } 409 410 /// getDebugLoc - Return the source location info. 411 const DebugLoc getDebugLoc() const { return debugLoc; } 412 413 /// setDebugLoc - Set source location info. Try to avoid this, putting 414 /// it in the constructor is preferable. 415 void setDebugLoc(const DebugLoc dl) { debugLoc = dl; } 416 417 /// use_iterator - This class provides iterator support for SDUse 418 /// operands that use a specific SDNode. 419 class use_iterator 420 : public std::iterator<std::forward_iterator_tag, SDUse, ptrdiff_t> { 421 SDUse *Op; 422 explicit use_iterator(SDUse *op) : Op(op) { 423 } 424 friend class SDNode; 425 public: 426 typedef std::iterator<std::forward_iterator_tag, 427 SDUse, ptrdiff_t>::reference reference; 428 typedef std::iterator<std::forward_iterator_tag, 429 SDUse, ptrdiff_t>::pointer pointer; 430 431 use_iterator(const use_iterator &I) : Op(I.Op) {} 432 use_iterator() : Op(0) {} 433 434 bool operator==(const use_iterator &x) const { 435 return Op == x.Op; 436 } 437 bool operator!=(const use_iterator &x) const { 438 return !operator==(x); 439 } 440 441 /// atEnd - return true if this iterator is at the end of uses list. 442 bool atEnd() const { return Op == 0; } 443 444 // Iterator traversal: forward iteration only. 445 use_iterator &operator++() { // Preincrement 446 assert(Op && "Cannot increment end iterator!"); 447 Op = Op->getNext(); 448 return *this; 449 } 450 451 use_iterator operator++(int) { // Postincrement 452 use_iterator tmp = *this; ++*this; return tmp; 453 } 454 455 /// Retrieve a pointer to the current user node. 456 SDNode *operator*() const { 457 assert(Op && "Cannot dereference end iterator!"); 458 return Op->getUser(); 459 } 460 461 SDNode *operator->() const { return operator*(); } 462 463 SDUse &getUse() const { return *Op; } 464 465 /// getOperandNo - Retrieve the operand # of this use in its user. 466 /// 467 unsigned getOperandNo() const { 468 assert(Op && "Cannot dereference end iterator!"); 469 return (unsigned)(Op - Op->getUser()->OperandList); 470 } 471 }; 472 473 /// use_begin/use_end - Provide iteration support to walk over all uses 474 /// of an SDNode. 475 476 use_iterator use_begin() const { 477 return use_iterator(UseList); 478 } 479 480 static use_iterator use_end() { return use_iterator(0); } 481 482 483 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the 484 /// indicated value. This method ignores uses of other values defined by this 485 /// operation. 486 bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; 487 488 /// hasAnyUseOfValue - Return true if there are any use of the indicated 489 /// value. This method ignores uses of other values defined by this operation. 490 bool hasAnyUseOfValue(unsigned Value) const; 491 492 /// isOnlyUserOf - Return true if this node is the only use of N. 493 /// 494 bool isOnlyUserOf(SDNode *N) const; 495 496 /// isOperandOf - Return true if this node is an operand of N. 497 /// 498 bool isOperandOf(SDNode *N) const; 499 500 /// isPredecessorOf - Return true if this node is a predecessor of N. 501 /// NOTE: Implemented on top of hasPredecessor and every bit as 502 /// expensive. Use carefully. 503 bool isPredecessorOf(const SDNode *N) const { return N->hasPredecessor(this); } 504 505 /// hasPredecessor - Return true if N is a predecessor of this node. 506 /// N is either an operand of this node, or can be reached by recursively 507 /// traversing up the operands. 508 /// NOTE: This is an expensive method. Use it carefully. 509 bool hasPredecessor(const SDNode *N) const; 510 511 /// hasPredecesorHelper - Return true if N is a predecessor of this node. 512 /// N is either an operand of this node, or can be reached by recursively 513 /// traversing up the operands. 514 /// In this helper the Visited and worklist sets are held externally to 515 /// cache predecessors over multiple invocations. If you want to test for 516 /// multiple predecessors this method is preferable to multiple calls to 517 /// hasPredecessor. Be sure to clear Visited and Worklist if the DAG 518 /// changes. 519 /// NOTE: This is still very expensive. Use carefully. 520 bool hasPredecessorHelper(const SDNode *N, 521 SmallPtrSet<const SDNode *, 32> &Visited, 522 SmallVector<const SDNode *, 16> &Worklist) const; 523 524 /// getNumOperands - Return the number of values used by this operation. 525 /// 526 unsigned getNumOperands() const { return NumOperands; } 527 528 /// getConstantOperandVal - Helper method returns the integer value of a 529 /// ConstantSDNode operand. 530 uint64_t getConstantOperandVal(unsigned Num) const; 531 532 const SDValue &getOperand(unsigned Num) const { 533 assert(Num < NumOperands && "Invalid child # of SDNode!"); 534 return OperandList[Num]; 535 } 536 537 typedef SDUse* op_iterator; 538 op_iterator op_begin() const { return OperandList; } 539 op_iterator op_end() const { return OperandList+NumOperands; } 540 541 SDVTList getVTList() const { 542 SDVTList X = { ValueList, NumValues }; 543 return X; 544 } 545 546 /// getGluedNode - If this node has a glue operand, return the node 547 /// to which the glue operand points. Otherwise return NULL. 548 SDNode *getGluedNode() const { 549 if (getNumOperands() != 0 && 550 getOperand(getNumOperands()-1).getValueType() == MVT::Glue) 551 return getOperand(getNumOperands()-1).getNode(); 552 return 0; 553 } 554 555 // If this is a pseudo op, like copyfromreg, look to see if there is a 556 // real target node glued to it. If so, return the target node. 557 const SDNode *getGluedMachineNode() const { 558 const SDNode *FoundNode = this; 559 560 // Climb up glue edges until a machine-opcode node is found, or the 561 // end of the chain is reached. 562 while (!FoundNode->isMachineOpcode()) { 563 const SDNode *N = FoundNode->getGluedNode(); 564 if (!N) break; 565 FoundNode = N; 566 } 567 568 return FoundNode; 569 } 570 571 /// getGluedUser - If this node has a glue value with a user, return 572 /// the user (there is at most one). Otherwise return NULL. 573 SDNode *getGluedUser() const { 574 for (use_iterator UI = use_begin(), UE = use_end(); UI != UE; ++UI) 575 if (UI.getUse().get().getValueType() == MVT::Glue) 576 return *UI; 577 return 0; 578 } 579 580 /// getNumValues - Return the number of values defined/returned by this 581 /// operator. 582 /// 583 unsigned getNumValues() const { return NumValues; } 584 585 /// getValueType - Return the type of a specified result. 586 /// 587 EVT getValueType(unsigned ResNo) const { 588 assert(ResNo < NumValues && "Illegal result number!"); 589 return ValueList[ResNo]; 590 } 591 592 /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)). 593 /// 594 unsigned getValueSizeInBits(unsigned ResNo) const { 595 return getValueType(ResNo).getSizeInBits(); 596 } 597 598 typedef const EVT* value_iterator; 599 value_iterator value_begin() const { return ValueList; } 600 value_iterator value_end() const { return ValueList+NumValues; } 601 602 /// getOperationName - Return the opcode of this operation for printing. 603 /// 604 std::string getOperationName(const SelectionDAG *G = 0) const; 605 static const char* getIndexedModeName(ISD::MemIndexedMode AM); 606 void print_types(raw_ostream &OS, const SelectionDAG *G) const; 607 void print_details(raw_ostream &OS, const SelectionDAG *G) const; 608 void print(raw_ostream &OS, const SelectionDAG *G = 0) const; 609 void printr(raw_ostream &OS, const SelectionDAG *G = 0) const; 610 611 /// printrFull - Print a SelectionDAG node and all children down to 612 /// the leaves. The given SelectionDAG allows target-specific nodes 613 /// to be printed in human-readable form. Unlike printr, this will 614 /// print the whole DAG, including children that appear multiple 615 /// times. 616 /// 617 void printrFull(raw_ostream &O, const SelectionDAG *G = 0) const; 618 619 /// printrWithDepth - Print a SelectionDAG node and children up to 620 /// depth "depth." The given SelectionDAG allows target-specific 621 /// nodes to be printed in human-readable form. Unlike printr, this 622 /// will print children that appear multiple times wherever they are 623 /// used. 624 /// 625 void printrWithDepth(raw_ostream &O, const SelectionDAG *G = 0, 626 unsigned depth = 100) const; 627 628 629 /// dump - Dump this node, for debugging. 630 void dump() const; 631 632 /// dumpr - Dump (recursively) this node and its use-def subgraph. 633 void dumpr() const; 634 635 /// dump - Dump this node, for debugging. 636 /// The given SelectionDAG allows target-specific nodes to be printed 637 /// in human-readable form. 638 void dump(const SelectionDAG *G) const; 639 640 /// dumpr - Dump (recursively) this node and its use-def subgraph. 641 /// The given SelectionDAG allows target-specific nodes to be printed 642 /// in human-readable form. 643 void dumpr(const SelectionDAG *G) const; 644 645 /// dumprFull - printrFull to dbgs(). The given SelectionDAG allows 646 /// target-specific nodes to be printed in human-readable form. 647 /// Unlike dumpr, this will print the whole DAG, including children 648 /// that appear multiple times. 649 /// 650 void dumprFull(const SelectionDAG *G = 0) const; 651 652 /// dumprWithDepth - printrWithDepth to dbgs(). The given 653 /// SelectionDAG allows target-specific nodes to be printed in 654 /// human-readable form. Unlike dumpr, this will print children 655 /// that appear multiple times wherever they are used. 656 /// 657 void dumprWithDepth(const SelectionDAG *G = 0, unsigned depth = 100) const; 658 659 660 static bool classof(const SDNode *) { return true; } 661 662 /// Profile - Gather unique data for the node. 663 /// 664 void Profile(FoldingSetNodeID &ID) const; 665 666 /// addUse - This method should only be used by the SDUse class. 667 /// 668 void addUse(SDUse &U) { U.addToList(&UseList); } 669 670 protected: 671 static SDVTList getSDVTList(EVT VT) { 672 SDVTList Ret = { getValueTypeList(VT), 1 }; 673 return Ret; 674 } 675 676 SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs, const SDValue *Ops, 677 unsigned NumOps) 678 : NodeType(Opc), OperandsNeedDelete(true), HasDebugValue(false), 679 SubclassData(0), NodeId(-1), 680 OperandList(NumOps ? new SDUse[NumOps] : 0), 681 ValueList(VTs.VTs), UseList(NULL), 682 NumOperands(NumOps), NumValues(VTs.NumVTs), 683 debugLoc(dl) { 684 for (unsigned i = 0; i != NumOps; ++i) { 685 OperandList[i].setUser(this); 686 OperandList[i].setInitial(Ops[i]); 687 } 688 checkForCycles(this); 689 } 690 691 /// This constructor adds no operands itself; operands can be 692 /// set later with InitOperands. 693 SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs) 694 : NodeType(Opc), OperandsNeedDelete(false), HasDebugValue(false), 695 SubclassData(0), NodeId(-1), OperandList(0), ValueList(VTs.VTs), 696 UseList(NULL), NumOperands(0), NumValues(VTs.NumVTs), 697 debugLoc(dl) {} 698 699 /// InitOperands - Initialize the operands list of this with 1 operand. 700 void InitOperands(SDUse *Ops, const SDValue &Op0) { 701 Ops[0].setUser(this); 702 Ops[0].setInitial(Op0); 703 NumOperands = 1; 704 OperandList = Ops; 705 checkForCycles(this); 706 } 707 708 /// InitOperands - Initialize the operands list of this with 2 operands. 709 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) { 710 Ops[0].setUser(this); 711 Ops[0].setInitial(Op0); 712 Ops[1].setUser(this); 713 Ops[1].setInitial(Op1); 714 NumOperands = 2; 715 OperandList = Ops; 716 checkForCycles(this); 717 } 718 719 /// InitOperands - Initialize the operands list of this with 3 operands. 720 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1, 721 const SDValue &Op2) { 722 Ops[0].setUser(this); 723 Ops[0].setInitial(Op0); 724 Ops[1].setUser(this); 725 Ops[1].setInitial(Op1); 726 Ops[2].setUser(this); 727 Ops[2].setInitial(Op2); 728 NumOperands = 3; 729 OperandList = Ops; 730 checkForCycles(this); 731 } 732 733 /// InitOperands - Initialize the operands list of this with 4 operands. 734 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1, 735 const SDValue &Op2, const SDValue &Op3) { 736 Ops[0].setUser(this); 737 Ops[0].setInitial(Op0); 738 Ops[1].setUser(this); 739 Ops[1].setInitial(Op1); 740 Ops[2].setUser(this); 741 Ops[2].setInitial(Op2); 742 Ops[3].setUser(this); 743 Ops[3].setInitial(Op3); 744 NumOperands = 4; 745 OperandList = Ops; 746 checkForCycles(this); 747 } 748 749 /// InitOperands - Initialize the operands list of this with N operands. 750 void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) { 751 for (unsigned i = 0; i != N; ++i) { 752 Ops[i].setUser(this); 753 Ops[i].setInitial(Vals[i]); 754 } 755 NumOperands = N; 756 OperandList = Ops; 757 checkForCycles(this); 758 } 759 760 /// DropOperands - Release the operands and set this node to have 761 /// zero operands. 762 void DropOperands(); 763 }; 764 765 766 // Define inline functions from the SDValue class. 767 768 inline unsigned SDValue::getOpcode() const { 769 return Node->getOpcode(); 770 } 771 inline EVT SDValue::getValueType() const { 772 return Node->getValueType(ResNo); 773 } 774 inline unsigned SDValue::getNumOperands() const { 775 return Node->getNumOperands(); 776 } 777 inline const SDValue &SDValue::getOperand(unsigned i) const { 778 return Node->getOperand(i); 779 } 780 inline uint64_t SDValue::getConstantOperandVal(unsigned i) const { 781 return Node->getConstantOperandVal(i); 782 } 783 inline bool SDValue::isTargetOpcode() const { 784 return Node->isTargetOpcode(); 785 } 786 inline bool SDValue::isTargetMemoryOpcode() const { 787 return Node->isTargetMemoryOpcode(); 788 } 789 inline bool SDValue::isMachineOpcode() const { 790 return Node->isMachineOpcode(); 791 } 792 inline unsigned SDValue::getMachineOpcode() const { 793 return Node->getMachineOpcode(); 794 } 795 inline bool SDValue::use_empty() const { 796 return !Node->hasAnyUseOfValue(ResNo); 797 } 798 inline bool SDValue::hasOneUse() const { 799 return Node->hasNUsesOfValue(1, ResNo); 800 } 801 inline const DebugLoc SDValue::getDebugLoc() const { 802 return Node->getDebugLoc(); 803 } 804 805 // Define inline functions from the SDUse class. 806 807 inline void SDUse::set(const SDValue &V) { 808 if (Val.getNode()) removeFromList(); 809 Val = V; 810 if (V.getNode()) V.getNode()->addUse(*this); 811 } 812 813 inline void SDUse::setInitial(const SDValue &V) { 814 Val = V; 815 V.getNode()->addUse(*this); 816 } 817 818 inline void SDUse::setNode(SDNode *N) { 819 if (Val.getNode()) removeFromList(); 820 Val.setNode(N); 821 if (N) N->addUse(*this); 822 } 823 824 /// UnarySDNode - This class is used for single-operand SDNodes. This is solely 825 /// to allow co-allocation of node operands with the node itself. 826 class UnarySDNode : public SDNode { 827 SDUse Op; 828 public: 829 UnarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X) 830 : SDNode(Opc, dl, VTs) { 831 InitOperands(&Op, X); 832 } 833 }; 834 835 /// BinarySDNode - This class is used for two-operand SDNodes. This is solely 836 /// to allow co-allocation of node operands with the node itself. 837 class BinarySDNode : public SDNode { 838 SDUse Ops[2]; 839 public: 840 BinarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X, SDValue Y) 841 : SDNode(Opc, dl, VTs) { 842 InitOperands(Ops, X, Y); 843 } 844 }; 845 846 /// TernarySDNode - This class is used for three-operand SDNodes. This is solely 847 /// to allow co-allocation of node operands with the node itself. 848 class TernarySDNode : public SDNode { 849 SDUse Ops[3]; 850 public: 851 TernarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X, SDValue Y, 852 SDValue Z) 853 : SDNode(Opc, dl, VTs) { 854 InitOperands(Ops, X, Y, Z); 855 } 856 }; 857 858 859 /// HandleSDNode - This class is used to form a handle around another node that 860 /// is persistent and is updated across invocations of replaceAllUsesWith on its 861 /// operand. This node should be directly created by end-users and not added to 862 /// the AllNodes list. 863 class HandleSDNode : public SDNode { 864 SDUse Op; 865 public: 866 // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is 867 // fixed. 868 #if __GNUC__==4 && __GNUC_MINOR__==2 && defined(__APPLE__) && !defined(__llvm__) 869 explicit __attribute__((__noinline__)) HandleSDNode(SDValue X) 870 #else 871 explicit HandleSDNode(SDValue X) 872 #endif 873 : SDNode(ISD::HANDLENODE, DebugLoc(), getSDVTList(MVT::Other)) { 874 InitOperands(&Op, X); 875 } 876 ~HandleSDNode(); 877 const SDValue &getValue() const { return Op; } 878 }; 879 880 /// Abstact virtual class for operations for memory operations 881 class MemSDNode : public SDNode { 882 private: 883 // MemoryVT - VT of in-memory value. 884 EVT MemoryVT; 885 886 protected: 887 /// MMO - Memory reference information. 888 MachineMemOperand *MMO; 889 890 public: 891 MemSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, EVT MemoryVT, 892 MachineMemOperand *MMO); 893 894 MemSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, const SDValue *Ops, 895 unsigned NumOps, EVT MemoryVT, MachineMemOperand *MMO); 896 897 bool readMem() const { return MMO->isLoad(); } 898 bool writeMem() const { return MMO->isStore(); } 899 900 /// Returns alignment and volatility of the memory access 901 unsigned getOriginalAlignment() const { 902 return MMO->getBaseAlignment(); 903 } 904 unsigned getAlignment() const { 905 return MMO->getAlignment(); 906 } 907 908 /// getRawSubclassData - Return the SubclassData value, which contains an 909 /// encoding of the volatile flag, as well as bits used by subclasses. This 910 /// function should only be used to compute a FoldingSetNodeID value. 911 unsigned getRawSubclassData() const { 912 return SubclassData; 913 } 914 915 // We access subclass data here so that we can check consistency 916 // with MachineMemOperand information. 917 bool isVolatile() const { return (SubclassData >> 5) & 1; } 918 bool isNonTemporal() const { return (SubclassData >> 6) & 1; } 919 920 /// Returns the SrcValue and offset that describes the location of the access 921 const Value *getSrcValue() const { return MMO->getValue(); } 922 int64_t getSrcValueOffset() const { return MMO->getOffset(); } 923 924 /// Returns the TBAAInfo that describes the dereference. 925 const MDNode *getTBAAInfo() const { return MMO->getTBAAInfo(); } 926 927 /// getMemoryVT - Return the type of the in-memory value. 928 EVT getMemoryVT() const { return MemoryVT; } 929 930 /// getMemOperand - Return a MachineMemOperand object describing the memory 931 /// reference performed by operation. 932 MachineMemOperand *getMemOperand() const { return MMO; } 933 934 const MachinePointerInfo &getPointerInfo() const { 935 return MMO->getPointerInfo(); 936 } 937 938 /// refineAlignment - Update this MemSDNode's MachineMemOperand information 939 /// to reflect the alignment of NewMMO, if it has a greater alignment. 940 /// This must only be used when the new alignment applies to all users of 941 /// this MachineMemOperand. 942 void refineAlignment(const MachineMemOperand *NewMMO) { 943 MMO->refineAlignment(NewMMO); 944 } 945 946 const SDValue &getChain() const { return getOperand(0); } 947 const SDValue &getBasePtr() const { 948 return getOperand(getOpcode() == ISD::STORE ? 2 : 1); 949 } 950 951 // Methods to support isa and dyn_cast 952 static bool classof(const MemSDNode *) { return true; } 953 static bool classof(const SDNode *N) { 954 // For some targets, we lower some target intrinsics to a MemIntrinsicNode 955 // with either an intrinsic or a target opcode. 956 return N->getOpcode() == ISD::LOAD || 957 N->getOpcode() == ISD::STORE || 958 N->getOpcode() == ISD::PREFETCH || 959 N->getOpcode() == ISD::ATOMIC_CMP_SWAP || 960 N->getOpcode() == ISD::ATOMIC_SWAP || 961 N->getOpcode() == ISD::ATOMIC_LOAD_ADD || 962 N->getOpcode() == ISD::ATOMIC_LOAD_SUB || 963 N->getOpcode() == ISD::ATOMIC_LOAD_AND || 964 N->getOpcode() == ISD::ATOMIC_LOAD_OR || 965 N->getOpcode() == ISD::ATOMIC_LOAD_XOR || 966 N->getOpcode() == ISD::ATOMIC_LOAD_NAND || 967 N->getOpcode() == ISD::ATOMIC_LOAD_MIN || 968 N->getOpcode() == ISD::ATOMIC_LOAD_MAX || 969 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || 970 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX || 971 N->isTargetMemoryOpcode(); 972 } 973 }; 974 975 /// AtomicSDNode - A SDNode reprenting atomic operations. 976 /// 977 class AtomicSDNode : public MemSDNode { 978 SDUse Ops[4]; 979 980 public: 981 // Opc: opcode for atomic 982 // VTL: value type list 983 // Chain: memory chain for operaand 984 // Ptr: address to update as a SDValue 985 // Cmp: compare value 986 // Swp: swap value 987 // SrcVal: address to update as a Value (used for MemOperand) 988 // Align: alignment of memory 989 AtomicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTL, EVT MemVT, 990 SDValue Chain, SDValue Ptr, 991 SDValue Cmp, SDValue Swp, MachineMemOperand *MMO) 992 : MemSDNode(Opc, dl, VTL, MemVT, MMO) { 993 assert(readMem() && "Atomic MachineMemOperand is not a load!"); 994 assert(writeMem() && "Atomic MachineMemOperand is not a store!"); 995 InitOperands(Ops, Chain, Ptr, Cmp, Swp); 996 } 997 AtomicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTL, EVT MemVT, 998 SDValue Chain, SDValue Ptr, 999 SDValue Val, MachineMemOperand *MMO) 1000 : MemSDNode(Opc, dl, VTL, MemVT, MMO) { 1001 assert(readMem() && "Atomic MachineMemOperand is not a load!"); 1002 assert(writeMem() && "Atomic MachineMemOperand is not a store!"); 1003 InitOperands(Ops, Chain, Ptr, Val); 1004 } 1005 1006 const SDValue &getBasePtr() const { return getOperand(1); } 1007 const SDValue &getVal() const { return getOperand(2); } 1008 1009 bool isCompareAndSwap() const { 1010 unsigned Op = getOpcode(); 1011 return Op == ISD::ATOMIC_CMP_SWAP; 1012 } 1013 1014 // Methods to support isa and dyn_cast 1015 static bool classof(const AtomicSDNode *) { return true; } 1016 static bool classof(const SDNode *N) { 1017 return N->getOpcode() == ISD::ATOMIC_CMP_SWAP || 1018 N->getOpcode() == ISD::ATOMIC_SWAP || 1019 N->getOpcode() == ISD::ATOMIC_LOAD_ADD || 1020 N->getOpcode() == ISD::ATOMIC_LOAD_SUB || 1021 N->getOpcode() == ISD::ATOMIC_LOAD_AND || 1022 N->getOpcode() == ISD::ATOMIC_LOAD_OR || 1023 N->getOpcode() == ISD::ATOMIC_LOAD_XOR || 1024 N->getOpcode() == ISD::ATOMIC_LOAD_NAND || 1025 N->getOpcode() == ISD::ATOMIC_LOAD_MIN || 1026 N->getOpcode() == ISD::ATOMIC_LOAD_MAX || 1027 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || 1028 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX; 1029 } 1030 }; 1031 1032 /// MemIntrinsicSDNode - This SDNode is used for target intrinsics that touch 1033 /// memory and need an associated MachineMemOperand. Its opcode may be 1034 /// INTRINSIC_VOID, INTRINSIC_W_CHAIN, PREFETCH, or a target-specific opcode 1035 /// with a value not less than FIRST_TARGET_MEMORY_OPCODE. 1036 class MemIntrinsicSDNode : public MemSDNode { 1037 public: 1038 MemIntrinsicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, 1039 const SDValue *Ops, unsigned NumOps, 1040 EVT MemoryVT, MachineMemOperand *MMO) 1041 : MemSDNode(Opc, dl, VTs, Ops, NumOps, MemoryVT, MMO) { 1042 } 1043 1044 // Methods to support isa and dyn_cast 1045 static bool classof(const MemIntrinsicSDNode *) { return true; } 1046 static bool classof(const SDNode *N) { 1047 // We lower some target intrinsics to their target opcode 1048 // early a node with a target opcode can be of this class 1049 return N->getOpcode() == ISD::INTRINSIC_W_CHAIN || 1050 N->getOpcode() == ISD::INTRINSIC_VOID || 1051 N->getOpcode() == ISD::PREFETCH || 1052 N->isTargetMemoryOpcode(); 1053 } 1054 }; 1055 1056 /// ShuffleVectorSDNode - This SDNode is used to implement the code generator 1057 /// support for the llvm IR shufflevector instruction. It combines elements 1058 /// from two input vectors into a new input vector, with the selection and 1059 /// ordering of elements determined by an array of integers, referred to as 1060 /// the shuffle mask. For input vectors of width N, mask indices of 0..N-1 1061 /// refer to elements from the LHS input, and indices from N to 2N-1 the RHS. 1062 /// An index of -1 is treated as undef, such that the code generator may put 1063 /// any value in the corresponding element of the result. 1064 class ShuffleVectorSDNode : public SDNode { 1065 SDUse Ops[2]; 1066 1067 // The memory for Mask is owned by the SelectionDAG's OperandAllocator, and 1068 // is freed when the SelectionDAG object is destroyed. 1069 const int *Mask; 1070 protected: 1071 friend class SelectionDAG; 1072 ShuffleVectorSDNode(EVT VT, DebugLoc dl, SDValue N1, SDValue N2, 1073 const int *M) 1074 : SDNode(ISD::VECTOR_SHUFFLE, dl, getSDVTList(VT)), Mask(M) { 1075 InitOperands(Ops, N1, N2); 1076 } 1077 public: 1078 1079 void getMask(SmallVectorImpl<int> &M) const { 1080 EVT VT = getValueType(0); 1081 M.clear(); 1082 for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) 1083 M.push_back(Mask[i]); 1084 } 1085 int getMaskElt(unsigned Idx) const { 1086 assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!"); 1087 return Mask[Idx]; 1088 } 1089 1090 bool isSplat() const { return isSplatMask(Mask, getValueType(0)); } 1091 int getSplatIndex() const { 1092 assert(isSplat() && "Cannot get splat index for non-splat!"); 1093 EVT VT = getValueType(0); 1094 for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) { 1095 if (Mask[i] != -1) 1096 return Mask[i]; 1097 } 1098 return -1; 1099 } 1100 static bool isSplatMask(const int *Mask, EVT VT); 1101 1102 static bool classof(const ShuffleVectorSDNode *) { return true; } 1103 static bool classof(const SDNode *N) { 1104 return N->getOpcode() == ISD::VECTOR_SHUFFLE; 1105 } 1106 }; 1107 1108 class ConstantSDNode : public SDNode { 1109 const ConstantInt *Value; 1110 friend class SelectionDAG; 1111 ConstantSDNode(bool isTarget, const ConstantInt *val, EVT VT) 1112 : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 1113 DebugLoc(), getSDVTList(VT)), Value(val) { 1114 } 1115 public: 1116 1117 const ConstantInt *getConstantIntValue() const { return Value; } 1118 const APInt &getAPIntValue() const { return Value->getValue(); } 1119 uint64_t getZExtValue() const { return Value->getZExtValue(); } 1120 int64_t getSExtValue() const { return Value->getSExtValue(); } 1121 1122 bool isOne() const { return Value->isOne(); } 1123 bool isNullValue() const { return Value->isNullValue(); } 1124 bool isAllOnesValue() const { return Value->isAllOnesValue(); } 1125 1126 static bool classof(const ConstantSDNode *) { return true; } 1127 static bool classof(const SDNode *N) { 1128 return N->getOpcode() == ISD::Constant || 1129 N->getOpcode() == ISD::TargetConstant; 1130 } 1131 }; 1132 1133 class ConstantFPSDNode : public SDNode { 1134 const ConstantFP *Value; 1135 friend class SelectionDAG; 1136 ConstantFPSDNode(bool isTarget, const ConstantFP *val, EVT VT) 1137 : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 1138 DebugLoc(), getSDVTList(VT)), Value(val) { 1139 } 1140 public: 1141 1142 const APFloat& getValueAPF() const { return Value->getValueAPF(); } 1143 const ConstantFP *getConstantFPValue() const { return Value; } 1144 1145 /// isZero - Return true if the value is positive or negative zero. 1146 bool isZero() const { return Value->isZero(); } 1147 1148 /// isNaN - Return true if the value is a NaN. 1149 bool isNaN() const { return Value->isNaN(); } 1150 1151 /// isExactlyValue - We don't rely on operator== working on double values, as 1152 /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 1153 /// As such, this method can be used to do an exact bit-for-bit comparison of 1154 /// two floating point values. 1155 1156 /// We leave the version with the double argument here because it's just so 1157 /// convenient to write "2.0" and the like. Without this function we'd 1158 /// have to duplicate its logic everywhere it's called. 1159 bool isExactlyValue(double V) const { 1160 bool ignored; 1161 // convert is not supported on this type 1162 if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) 1163 return false; 1164 APFloat Tmp(V); 1165 Tmp.convert(Value->getValueAPF().getSemantics(), 1166 APFloat::rmNearestTiesToEven, &ignored); 1167 return isExactlyValue(Tmp); 1168 } 1169 bool isExactlyValue(const APFloat& V) const; 1170 1171 static bool isValueValidForType(EVT VT, const APFloat& Val); 1172 1173 static bool classof(const ConstantFPSDNode *) { return true; } 1174 static bool classof(const SDNode *N) { 1175 return N->getOpcode() == ISD::ConstantFP || 1176 N->getOpcode() == ISD::TargetConstantFP; 1177 } 1178 }; 1179 1180 class GlobalAddressSDNode : public SDNode { 1181 const GlobalValue *TheGlobal; 1182 int64_t Offset; 1183 unsigned char TargetFlags; 1184 friend class SelectionDAG; 1185 GlobalAddressSDNode(unsigned Opc, DebugLoc DL, const GlobalValue *GA, EVT VT, 1186 int64_t o, unsigned char TargetFlags); 1187 public: 1188 1189 const GlobalValue *getGlobal() const { return TheGlobal; } 1190 int64_t getOffset() const { return Offset; } 1191 unsigned char getTargetFlags() const { return TargetFlags; } 1192 // Return the address space this GlobalAddress belongs to. 1193 unsigned getAddressSpace() const; 1194 1195 static bool classof(const GlobalAddressSDNode *) { return true; } 1196 static bool classof(const SDNode *N) { 1197 return N->getOpcode() == ISD::GlobalAddress || 1198 N->getOpcode() == ISD::TargetGlobalAddress || 1199 N->getOpcode() == ISD::GlobalTLSAddress || 1200 N->getOpcode() == ISD::TargetGlobalTLSAddress; 1201 } 1202 }; 1203 1204 class FrameIndexSDNode : public SDNode { 1205 int FI; 1206 friend class SelectionDAG; 1207 FrameIndexSDNode(int fi, EVT VT, bool isTarg) 1208 : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, 1209 DebugLoc(), getSDVTList(VT)), FI(fi) { 1210 } 1211 public: 1212 1213 int getIndex() const { return FI; } 1214 1215 static bool classof(const FrameIndexSDNode *) { return true; } 1216 static bool classof(const SDNode *N) { 1217 return N->getOpcode() == ISD::FrameIndex || 1218 N->getOpcode() == ISD::TargetFrameIndex; 1219 } 1220 }; 1221 1222 class JumpTableSDNode : public SDNode { 1223 int JTI; 1224 unsigned char TargetFlags; 1225 friend class SelectionDAG; 1226 JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF) 1227 : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, 1228 DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) { 1229 } 1230 public: 1231 1232 int getIndex() const { return JTI; } 1233 unsigned char getTargetFlags() const { return TargetFlags; } 1234 1235 static bool classof(const JumpTableSDNode *) { return true; } 1236 static bool classof(const SDNode *N) { 1237 return N->getOpcode() == ISD::JumpTable || 1238 N->getOpcode() == ISD::TargetJumpTable; 1239 } 1240 }; 1241 1242 class ConstantPoolSDNode : public SDNode { 1243 union { 1244 const Constant *ConstVal; 1245 MachineConstantPoolValue *MachineCPVal; 1246 } Val; 1247 int Offset; // It's a MachineConstantPoolValue if top bit is set. 1248 unsigned Alignment; // Minimum alignment requirement of CP (not log2 value). 1249 unsigned char TargetFlags; 1250 friend class SelectionDAG; 1251 ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o, 1252 unsigned Align, unsigned char TF) 1253 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1254 DebugLoc(), 1255 getSDVTList(VT)), Offset(o), Alignment(Align), TargetFlags(TF) { 1256 assert((int)Offset >= 0 && "Offset is too large"); 1257 Val.ConstVal = c; 1258 } 1259 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1260 EVT VT, int o, unsigned Align, unsigned char TF) 1261 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1262 DebugLoc(), 1263 getSDVTList(VT)), Offset(o), Alignment(Align), TargetFlags(TF) { 1264 assert((int)Offset >= 0 && "Offset is too large"); 1265 Val.MachineCPVal = v; 1266 Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1); 1267 } 1268 public: 1269 1270 1271 bool isMachineConstantPoolEntry() const { 1272 return (int)Offset < 0; 1273 } 1274 1275 const Constant *getConstVal() const { 1276 assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1277 return Val.ConstVal; 1278 } 1279 1280 MachineConstantPoolValue *getMachineCPVal() const { 1281 assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1282 return Val.MachineCPVal; 1283 } 1284 1285 int getOffset() const { 1286 return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1)); 1287 } 1288 1289 // Return the alignment of this constant pool object, which is either 0 (for 1290 // default alignment) or the desired value. 1291 unsigned getAlignment() const { return Alignment; } 1292 unsigned char getTargetFlags() const { return TargetFlags; } 1293 1294 Type *getType() const; 1295 1296 static bool classof(const ConstantPoolSDNode *) { return true; } 1297 static bool classof(const SDNode *N) { 1298 return N->getOpcode() == ISD::ConstantPool || 1299 N->getOpcode() == ISD::TargetConstantPool; 1300 } 1301 }; 1302 1303 class BasicBlockSDNode : public SDNode { 1304 MachineBasicBlock *MBB; 1305 friend class SelectionDAG; 1306 /// Debug info is meaningful and potentially useful here, but we create 1307 /// blocks out of order when they're jumped to, which makes it a bit 1308 /// harder. Let's see if we need it first. 1309 explicit BasicBlockSDNode(MachineBasicBlock *mbb) 1310 : SDNode(ISD::BasicBlock, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb) { 1311 } 1312 public: 1313 1314 MachineBasicBlock *getBasicBlock() const { return MBB; } 1315 1316 static bool classof(const BasicBlockSDNode *) { return true; } 1317 static bool classof(const SDNode *N) { 1318 return N->getOpcode() == ISD::BasicBlock; 1319 } 1320 }; 1321 1322 /// BuildVectorSDNode - A "pseudo-class" with methods for operating on 1323 /// BUILD_VECTORs. 1324 class BuildVectorSDNode : public SDNode { 1325 // These are constructed as SDNodes and then cast to BuildVectorSDNodes. 1326 explicit BuildVectorSDNode(); // Do not implement 1327 public: 1328 /// isConstantSplat - Check if this is a constant splat, and if so, find the 1329 /// smallest element size that splats the vector. If MinSplatBits is 1330 /// nonzero, the element size must be at least that large. Note that the 1331 /// splat element may be the entire vector (i.e., a one element vector). 1332 /// Returns the splat element value in SplatValue. Any undefined bits in 1333 /// that value are zero, and the corresponding bits in the SplatUndef mask 1334 /// are set. The SplatBitSize value is set to the splat element size in 1335 /// bits. HasAnyUndefs is set to true if any bits in the vector are 1336 /// undefined. isBigEndian describes the endianness of the target. 1337 bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, 1338 unsigned &SplatBitSize, bool &HasAnyUndefs, 1339 unsigned MinSplatBits = 0, bool isBigEndian = false); 1340 1341 static inline bool classof(const BuildVectorSDNode *) { return true; } 1342 static inline bool classof(const SDNode *N) { 1343 return N->getOpcode() == ISD::BUILD_VECTOR; 1344 } 1345 }; 1346 1347 /// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is 1348 /// used when the SelectionDAG needs to make a simple reference to something 1349 /// in the LLVM IR representation. 1350 /// 1351 class SrcValueSDNode : public SDNode { 1352 const Value *V; 1353 friend class SelectionDAG; 1354 /// Create a SrcValue for a general value. 1355 explicit SrcValueSDNode(const Value *v) 1356 : SDNode(ISD::SRCVALUE, DebugLoc(), getSDVTList(MVT::Other)), V(v) {} 1357 1358 public: 1359 /// getValue - return the contained Value. 1360 const Value *getValue() const { return V; } 1361 1362 static bool classof(const SrcValueSDNode *) { return true; } 1363 static bool classof(const SDNode *N) { 1364 return N->getOpcode() == ISD::SRCVALUE; 1365 } 1366 }; 1367 1368 class MDNodeSDNode : public SDNode { 1369 const MDNode *MD; 1370 friend class SelectionDAG; 1371 explicit MDNodeSDNode(const MDNode *md) 1372 : SDNode(ISD::MDNODE_SDNODE, DebugLoc(), getSDVTList(MVT::Other)), MD(md) {} 1373 public: 1374 1375 const MDNode *getMD() const { return MD; } 1376 1377 static bool classof(const MDNodeSDNode *) { return true; } 1378 static bool classof(const SDNode *N) { 1379 return N->getOpcode() == ISD::MDNODE_SDNODE; 1380 } 1381 }; 1382 1383 1384 class RegisterSDNode : public SDNode { 1385 unsigned Reg; 1386 friend class SelectionDAG; 1387 RegisterSDNode(unsigned reg, EVT VT) 1388 : SDNode(ISD::Register, DebugLoc(), getSDVTList(VT)), Reg(reg) { 1389 } 1390 public: 1391 1392 unsigned getReg() const { return Reg; } 1393 1394 static bool classof(const RegisterSDNode *) { return true; } 1395 static bool classof(const SDNode *N) { 1396 return N->getOpcode() == ISD::Register; 1397 } 1398 }; 1399 1400 class BlockAddressSDNode : public SDNode { 1401 const BlockAddress *BA; 1402 unsigned char TargetFlags; 1403 friend class SelectionDAG; 1404 BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba, 1405 unsigned char Flags) 1406 : SDNode(NodeTy, DebugLoc(), getSDVTList(VT)), 1407 BA(ba), TargetFlags(Flags) { 1408 } 1409 public: 1410 const BlockAddress *getBlockAddress() const { return BA; } 1411 unsigned char getTargetFlags() const { return TargetFlags; } 1412 1413 static bool classof(const BlockAddressSDNode *) { return true; } 1414 static bool classof(const SDNode *N) { 1415 return N->getOpcode() == ISD::BlockAddress || 1416 N->getOpcode() == ISD::TargetBlockAddress; 1417 } 1418 }; 1419 1420 class EHLabelSDNode : public SDNode { 1421 SDUse Chain; 1422 MCSymbol *Label; 1423 friend class SelectionDAG; 1424 EHLabelSDNode(DebugLoc dl, SDValue ch, MCSymbol *L) 1425 : SDNode(ISD::EH_LABEL, dl, getSDVTList(MVT::Other)), Label(L) { 1426 InitOperands(&Chain, ch); 1427 } 1428 public: 1429 MCSymbol *getLabel() const { return Label; } 1430 1431 static bool classof(const EHLabelSDNode *) { return true; } 1432 static bool classof(const SDNode *N) { 1433 return N->getOpcode() == ISD::EH_LABEL; 1434 } 1435 }; 1436 1437 class ExternalSymbolSDNode : public SDNode { 1438 const char *Symbol; 1439 unsigned char TargetFlags; 1440 1441 friend class SelectionDAG; 1442 ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT) 1443 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 1444 DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) { 1445 } 1446 public: 1447 1448 const char *getSymbol() const { return Symbol; } 1449 unsigned char getTargetFlags() const { return TargetFlags; } 1450 1451 static bool classof(const ExternalSymbolSDNode *) { return true; } 1452 static bool classof(const SDNode *N) { 1453 return N->getOpcode() == ISD::ExternalSymbol || 1454 N->getOpcode() == ISD::TargetExternalSymbol; 1455 } 1456 }; 1457 1458 class CondCodeSDNode : public SDNode { 1459 ISD::CondCode Condition; 1460 friend class SelectionDAG; 1461 explicit CondCodeSDNode(ISD::CondCode Cond) 1462 : SDNode(ISD::CONDCODE, DebugLoc(), getSDVTList(MVT::Other)), 1463 Condition(Cond) { 1464 } 1465 public: 1466 1467 ISD::CondCode get() const { return Condition; } 1468 1469 static bool classof(const CondCodeSDNode *) { return true; } 1470 static bool classof(const SDNode *N) { 1471 return N->getOpcode() == ISD::CONDCODE; 1472 } 1473 }; 1474 1475 /// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the 1476 /// future and most targets don't support it. 1477 class CvtRndSatSDNode : public SDNode { 1478 ISD::CvtCode CvtCode; 1479 friend class SelectionDAG; 1480 explicit CvtRndSatSDNode(EVT VT, DebugLoc dl, const SDValue *Ops, 1481 unsigned NumOps, ISD::CvtCode Code) 1482 : SDNode(ISD::CONVERT_RNDSAT, dl, getSDVTList(VT), Ops, NumOps), 1483 CvtCode(Code) { 1484 assert(NumOps == 5 && "wrong number of operations"); 1485 } 1486 public: 1487 ISD::CvtCode getCvtCode() const { return CvtCode; } 1488 1489 static bool classof(const CvtRndSatSDNode *) { return true; } 1490 static bool classof(const SDNode *N) { 1491 return N->getOpcode() == ISD::CONVERT_RNDSAT; 1492 } 1493 }; 1494 1495 /// VTSDNode - This class is used to represent EVT's, which are used 1496 /// to parameterize some operations. 1497 class VTSDNode : public SDNode { 1498 EVT ValueType; 1499 friend class SelectionDAG; 1500 explicit VTSDNode(EVT VT) 1501 : SDNode(ISD::VALUETYPE, DebugLoc(), getSDVTList(MVT::Other)), 1502 ValueType(VT) { 1503 } 1504 public: 1505 1506 EVT getVT() const { return ValueType; } 1507 1508 static bool classof(const VTSDNode *) { return true; } 1509 static bool classof(const SDNode *N) { 1510 return N->getOpcode() == ISD::VALUETYPE; 1511 } 1512 }; 1513 1514 /// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode 1515 /// 1516 class LSBaseSDNode : public MemSDNode { 1517 //! Operand array for load and store 1518 /*! 1519 \note Moving this array to the base class captures more 1520 common functionality shared between LoadSDNode and 1521 StoreSDNode 1522 */ 1523 SDUse Ops[4]; 1524 public: 1525 LSBaseSDNode(ISD::NodeType NodeTy, DebugLoc dl, SDValue *Operands, 1526 unsigned numOperands, SDVTList VTs, ISD::MemIndexedMode AM, 1527 EVT MemVT, MachineMemOperand *MMO) 1528 : MemSDNode(NodeTy, dl, VTs, MemVT, MMO) { 1529 SubclassData |= AM << 2; 1530 assert(getAddressingMode() == AM && "MemIndexedMode encoding error!"); 1531 InitOperands(Ops, Operands, numOperands); 1532 assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) && 1533 "Only indexed loads and stores have a non-undef offset operand"); 1534 } 1535 1536 const SDValue &getOffset() const { 1537 return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); 1538 } 1539 1540 /// getAddressingMode - Return the addressing mode for this load or store: 1541 /// unindexed, pre-inc, pre-dec, post-inc, or post-dec. 1542 ISD::MemIndexedMode getAddressingMode() const { 1543 return ISD::MemIndexedMode((SubclassData >> 2) & 7); 1544 } 1545 1546 /// isIndexed - Return true if this is a pre/post inc/dec load/store. 1547 bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; } 1548 1549 /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. 1550 bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; } 1551 1552 static bool classof(const LSBaseSDNode *) { return true; } 1553 static bool classof(const SDNode *N) { 1554 return N->getOpcode() == ISD::LOAD || 1555 N->getOpcode() == ISD::STORE; 1556 } 1557 }; 1558 1559 /// LoadSDNode - This class is used to represent ISD::LOAD nodes. 1560 /// 1561 class LoadSDNode : public LSBaseSDNode { 1562 friend class SelectionDAG; 1563 LoadSDNode(SDValue *ChainPtrOff, DebugLoc dl, SDVTList VTs, 1564 ISD::MemIndexedMode AM, ISD::LoadExtType ETy, EVT MemVT, 1565 MachineMemOperand *MMO) 1566 : LSBaseSDNode(ISD::LOAD, dl, ChainPtrOff, 3, 1567 VTs, AM, MemVT, MMO) { 1568 SubclassData |= (unsigned short)ETy; 1569 assert(getExtensionType() == ETy && "LoadExtType encoding error!"); 1570 assert(readMem() && "Load MachineMemOperand is not a load!"); 1571 assert(!writeMem() && "Load MachineMemOperand is a store!"); 1572 } 1573 public: 1574 1575 /// getExtensionType - Return whether this is a plain node, 1576 /// or one of the varieties of value-extending loads. 1577 ISD::LoadExtType getExtensionType() const { 1578 return ISD::LoadExtType(SubclassData & 3); 1579 } 1580 1581 const SDValue &getBasePtr() const { return getOperand(1); } 1582 const SDValue &getOffset() const { return getOperand(2); } 1583 1584 static bool classof(const LoadSDNode *) { return true; } 1585 static bool classof(const SDNode *N) { 1586 return N->getOpcode() == ISD::LOAD; 1587 } 1588 }; 1589 1590 /// StoreSDNode - This class is used to represent ISD::STORE nodes. 1591 /// 1592 class StoreSDNode : public LSBaseSDNode { 1593 friend class SelectionDAG; 1594 StoreSDNode(SDValue *ChainValuePtrOff, DebugLoc dl, SDVTList VTs, 1595 ISD::MemIndexedMode AM, bool isTrunc, EVT MemVT, 1596 MachineMemOperand *MMO) 1597 : LSBaseSDNode(ISD::STORE, dl, ChainValuePtrOff, 4, 1598 VTs, AM, MemVT, MMO) { 1599 SubclassData |= (unsigned short)isTrunc; 1600 assert(isTruncatingStore() == isTrunc && "isTrunc encoding error!"); 1601 assert(!readMem() && "Store MachineMemOperand is a load!"); 1602 assert(writeMem() && "Store MachineMemOperand is not a store!"); 1603 } 1604 public: 1605 1606 /// isTruncatingStore - Return true if the op does a truncation before store. 1607 /// For integers this is the same as doing a TRUNCATE and storing the result. 1608 /// For floats, it is the same as doing an FP_ROUND and storing the result. 1609 bool isTruncatingStore() const { return SubclassData & 1; } 1610 1611 const SDValue &getValue() const { return getOperand(1); } 1612 const SDValue &getBasePtr() const { return getOperand(2); } 1613 const SDValue &getOffset() const { return getOperand(3); } 1614 1615 static bool classof(const StoreSDNode *) { return true; } 1616 static bool classof(const SDNode *N) { 1617 return N->getOpcode() == ISD::STORE; 1618 } 1619 }; 1620 1621 /// MachineSDNode - An SDNode that represents everything that will be needed 1622 /// to construct a MachineInstr. These nodes are created during the 1623 /// instruction selection proper phase. 1624 /// 1625 class MachineSDNode : public SDNode { 1626 public: 1627 typedef MachineMemOperand **mmo_iterator; 1628 1629 private: 1630 friend class SelectionDAG; 1631 MachineSDNode(unsigned Opc, const DebugLoc DL, SDVTList VTs) 1632 : SDNode(Opc, DL, VTs), MemRefs(0), MemRefsEnd(0) {} 1633 1634 /// LocalOperands - Operands for this instruction, if they fit here. If 1635 /// they don't, this field is unused. 1636 SDUse LocalOperands[4]; 1637 1638 /// MemRefs - Memory reference descriptions for this instruction. 1639 mmo_iterator MemRefs; 1640 mmo_iterator MemRefsEnd; 1641 1642 public: 1643 mmo_iterator memoperands_begin() const { return MemRefs; } 1644 mmo_iterator memoperands_end() const { return MemRefsEnd; } 1645 bool memoperands_empty() const { return MemRefsEnd == MemRefs; } 1646 1647 /// setMemRefs - Assign this MachineSDNodes's memory reference descriptor 1648 /// list. This does not transfer ownership. 1649 void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd) { 1650 MemRefs = NewMemRefs; 1651 MemRefsEnd = NewMemRefsEnd; 1652 } 1653 1654 static bool classof(const MachineSDNode *) { return true; } 1655 static bool classof(const SDNode *N) { 1656 return N->isMachineOpcode(); 1657 } 1658 }; 1659 1660 class SDNodeIterator : public std::iterator<std::forward_iterator_tag, 1661 SDNode, ptrdiff_t> { 1662 SDNode *Node; 1663 unsigned Operand; 1664 1665 SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 1666 public: 1667 bool operator==(const SDNodeIterator& x) const { 1668 return Operand == x.Operand; 1669 } 1670 bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 1671 1672 const SDNodeIterator &operator=(const SDNodeIterator &I) { 1673 assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 1674 Operand = I.Operand; 1675 return *this; 1676 } 1677 1678 pointer operator*() const { 1679 return Node->getOperand(Operand).getNode(); 1680 } 1681 pointer operator->() const { return operator*(); } 1682 1683 SDNodeIterator& operator++() { // Preincrement 1684 ++Operand; 1685 return *this; 1686 } 1687 SDNodeIterator operator++(int) { // Postincrement 1688 SDNodeIterator tmp = *this; ++*this; return tmp; 1689 } 1690 size_t operator-(SDNodeIterator Other) const { 1691 assert(Node == Other.Node && 1692 "Cannot compare iterators of two different nodes!"); 1693 return Operand - Other.Operand; 1694 } 1695 1696 static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 1697 static SDNodeIterator end (SDNode *N) { 1698 return SDNodeIterator(N, N->getNumOperands()); 1699 } 1700 1701 unsigned getOperand() const { return Operand; } 1702 const SDNode *getNode() const { return Node; } 1703 }; 1704 1705 template <> struct GraphTraits<SDNode*> { 1706 typedef SDNode NodeType; 1707 typedef SDNodeIterator ChildIteratorType; 1708 static inline NodeType *getEntryNode(SDNode *N) { return N; } 1709 static inline ChildIteratorType child_begin(NodeType *N) { 1710 return SDNodeIterator::begin(N); 1711 } 1712 static inline ChildIteratorType child_end(NodeType *N) { 1713 return SDNodeIterator::end(N); 1714 } 1715 }; 1716 1717 /// LargestSDNode - The largest SDNode class. 1718 /// 1719 typedef LoadSDNode LargestSDNode; 1720 1721 /// MostAlignedSDNode - The SDNode class with the greatest alignment 1722 /// requirement. 1723 /// 1724 typedef GlobalAddressSDNode MostAlignedSDNode; 1725 1726 namespace ISD { 1727 /// isNormalLoad - Returns true if the specified node is a non-extending 1728 /// and unindexed load. 1729 inline bool isNormalLoad(const SDNode *N) { 1730 const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N); 1731 return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD && 1732 Ld->getAddressingMode() == ISD::UNINDEXED; 1733 } 1734 1735 /// isNON_EXTLoad - Returns true if the specified node is a non-extending 1736 /// load. 1737 inline bool isNON_EXTLoad(const SDNode *N) { 1738 return isa<LoadSDNode>(N) && 1739 cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 1740 } 1741 1742 /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 1743 /// 1744 inline bool isEXTLoad(const SDNode *N) { 1745 return isa<LoadSDNode>(N) && 1746 cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 1747 } 1748 1749 /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 1750 /// 1751 inline bool isSEXTLoad(const SDNode *N) { 1752 return isa<LoadSDNode>(N) && 1753 cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 1754 } 1755 1756 /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 1757 /// 1758 inline bool isZEXTLoad(const SDNode *N) { 1759 return isa<LoadSDNode>(N) && 1760 cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 1761 } 1762 1763 /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load. 1764 /// 1765 inline bool isUNINDEXEDLoad(const SDNode *N) { 1766 return isa<LoadSDNode>(N) && 1767 cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 1768 } 1769 1770 /// isNormalStore - Returns true if the specified node is a non-truncating 1771 /// and unindexed store. 1772 inline bool isNormalStore(const SDNode *N) { 1773 const StoreSDNode *St = dyn_cast<StoreSDNode>(N); 1774 return St && !St->isTruncatingStore() && 1775 St->getAddressingMode() == ISD::UNINDEXED; 1776 } 1777 1778 /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 1779 /// store. 1780 inline bool isNON_TRUNCStore(const SDNode *N) { 1781 return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore(); 1782 } 1783 1784 /// isTRUNCStore - Returns true if the specified node is a truncating 1785 /// store. 1786 inline bool isTRUNCStore(const SDNode *N) { 1787 return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore(); 1788 } 1789 1790 /// isUNINDEXEDStore - Returns true if the specified node is an 1791 /// unindexed store. 1792 inline bool isUNINDEXEDStore(const SDNode *N) { 1793 return isa<StoreSDNode>(N) && 1794 cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 1795 } 1796 } 1797 1798 } // end llvm namespace 1799 1800 #endif 1801