1 //===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the SDNode class and derived classes, which are used to
11 // represent the nodes and operations present in a SelectionDAG. These nodes
12 // and operations are machine code level operations, with some similarities to
13 // the GCC RTL representation.
15 // Clients should include the SelectionDAG.h file instead of this file directly.
17 //===----------------------------------------------------------------------===//
19 #ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
20 #define LLVM_CODEGEN_SELECTIONDAGNODES_H
22 #include "llvm/ADT/iterator_range.h"
23 #include "llvm/ADT/FoldingSet.h"
24 #include "llvm/ADT/GraphTraits.h"
25 #include "llvm/ADT/STLExtras.h"
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/ADT/ilist_node.h"
29 #include "llvm/CodeGen/ISDOpcodes.h"
30 #include "llvm/CodeGen/MachineMemOperand.h"
31 #include "llvm/CodeGen/ValueTypes.h"
32 #include "llvm/IR/Constants.h"
33 #include "llvm/IR/DebugLoc.h"
34 #include "llvm/IR/Instructions.h"
35 #include "llvm/Support/DataTypes.h"
36 #include "llvm/Support/MathExtras.h"
43 class MachineBasicBlock;
44 class MachineConstantPoolValue;
48 template <typename T> struct DenseMapInfo;
49 template <typename T> struct simplify_type;
50 template <typename T> struct ilist_traits;
52 void checkForCycles(const SDNode *N);
54 /// SDVTList - This represents a list of ValueType's that has been intern'd by
55 /// a SelectionDAG. Instances of this simple value class are returned by
56 /// SelectionDAG::getVTList(...).
66 /// isBuildVectorAllOnes - Return true if the specified node is a
67 /// BUILD_VECTOR where all of the elements are ~0 or undef.
68 bool isBuildVectorAllOnes(const SDNode *N);
70 /// isBuildVectorAllZeros - Return true if the specified node is a
71 /// BUILD_VECTOR where all of the elements are 0 or undef.
72 bool isBuildVectorAllZeros(const SDNode *N);
74 /// \brief Return true if the specified node is a BUILD_VECTOR node of
75 /// all ConstantSDNode or undef.
76 bool isBuildVectorOfConstantSDNodes(const SDNode *N);
78 /// isScalarToVector - Return true if the specified node is a
79 /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
80 /// element is not an undef.
81 bool isScalarToVector(const SDNode *N);
83 /// allOperandsUndef - Return true if the node has at least one operand
84 /// and all operands of the specified node are ISD::UNDEF.
85 bool allOperandsUndef(const SDNode *N);
86 } // end llvm:ISD namespace
88 //===----------------------------------------------------------------------===//
89 /// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple
90 /// values as the result of a computation. Many nodes return multiple values,
91 /// from loads (which define a token and a return value) to ADDC (which returns
92 /// a result and a carry value), to calls (which may return an arbitrary number
95 /// As such, each use of a SelectionDAG computation must indicate the node that
96 /// computes it as well as which return value to use from that node. This pair
97 /// of information is represented with the SDValue value type.
100 SDNode *Node; // The node defining the value we are using.
101 unsigned ResNo; // Which return value of the node we are using.
103 SDValue() : Node(0), ResNo(0) {}
104 SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {}
106 /// get the index which selects a specific result in the SDNode
107 unsigned getResNo() const { return ResNo; }
109 /// get the SDNode which holds the desired result
110 SDNode *getNode() const { return Node; }
113 void setNode(SDNode *N) { Node = N; }
115 inline SDNode *operator->() const { return Node; }
117 bool operator==(const SDValue &O) const {
118 return Node == O.Node && ResNo == O.ResNo;
120 bool operator!=(const SDValue &O) const {
121 return !operator==(O);
123 bool operator<(const SDValue &O) const {
124 return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo);
127 SDValue getValue(unsigned R) const {
128 return SDValue(Node, R);
131 // isOperandOf - Return true if this node is an operand of N.
132 bool isOperandOf(SDNode *N) const;
134 /// getValueType - Return the ValueType of the referenced return value.
136 inline EVT getValueType() const;
138 /// Return the simple ValueType of the referenced return value.
139 MVT getSimpleValueType() const {
140 return getValueType().getSimpleVT();
143 /// getValueSizeInBits - Returns the size of the value in bits.
145 unsigned getValueSizeInBits() const {
146 return getValueType().getSizeInBits();
149 unsigned getScalarValueSizeInBits() const {
150 return getValueType().getScalarType().getSizeInBits();
153 // Forwarding methods - These forward to the corresponding methods in SDNode.
154 inline unsigned getOpcode() const;
155 inline unsigned getNumOperands() const;
156 inline const SDValue &getOperand(unsigned i) const;
157 inline uint64_t getConstantOperandVal(unsigned i) const;
158 inline bool isTargetMemoryOpcode() const;
159 inline bool isTargetOpcode() const;
160 inline bool isMachineOpcode() const;
161 inline unsigned getMachineOpcode() const;
162 inline const DebugLoc getDebugLoc() const;
163 inline void dump() const;
164 inline void dumpr() const;
166 /// reachesChainWithoutSideEffects - Return true if this operand (which must
167 /// be a chain) reaches the specified operand without crossing any
168 /// side-effecting instructions. In practice, this looks through token
169 /// factors and non-volatile loads. In order to remain efficient, this only
170 /// looks a couple of nodes in, it does not do an exhaustive search.
171 bool reachesChainWithoutSideEffects(SDValue Dest,
172 unsigned Depth = 2) const;
174 /// use_empty - Return true if there are no nodes using value ResNo
177 inline bool use_empty() const;
179 /// hasOneUse - Return true if there is exactly one node using value
182 inline bool hasOneUse() const;
186 template<> struct DenseMapInfo<SDValue> {
187 static inline SDValue getEmptyKey() {
188 return SDValue((SDNode*)-1, -1U);
190 static inline SDValue getTombstoneKey() {
191 return SDValue((SDNode*)-1, 0);
193 static unsigned getHashValue(const SDValue &Val) {
194 return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
195 (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
197 static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
201 template <> struct isPodLike<SDValue> { static const bool value = true; };
204 /// simplify_type specializations - Allow casting operators to work directly on
205 /// SDValues as if they were SDNode*'s.
206 template<> struct simplify_type<SDValue> {
207 typedef SDNode* SimpleType;
208 static SimpleType getSimplifiedValue(SDValue &Val) {
209 return Val.getNode();
212 template<> struct simplify_type<const SDValue> {
213 typedef /*const*/ SDNode* SimpleType;
214 static SimpleType getSimplifiedValue(const SDValue &Val) {
215 return Val.getNode();
219 /// SDUse - Represents a use of a SDNode. This class holds an SDValue,
220 /// which records the SDNode being used and the result number, a
221 /// pointer to the SDNode using the value, and Next and Prev pointers,
222 /// which link together all the uses of an SDNode.
225 /// Val - The value being used.
227 /// User - The user of this value.
229 /// Prev, Next - Pointers to the uses list of the SDNode referred by
233 SDUse(const SDUse &U) LLVM_DELETED_FUNCTION;
234 void operator=(const SDUse &U) LLVM_DELETED_FUNCTION;
237 SDUse() : Val(), User(NULL), Prev(NULL), Next(NULL) {}
239 /// Normally SDUse will just implicitly convert to an SDValue that it holds.
240 operator const SDValue&() const { return Val; }
242 /// If implicit conversion to SDValue doesn't work, the get() method returns
244 const SDValue &get() const { return Val; }
246 /// getUser - This returns the SDNode that contains this Use.
247 SDNode *getUser() { return User; }
249 /// getNext - Get the next SDUse in the use list.
250 SDUse *getNext() const { return Next; }
252 /// getNode - Convenience function for get().getNode().
253 SDNode *getNode() const { return Val.getNode(); }
254 /// getResNo - Convenience function for get().getResNo().
255 unsigned getResNo() const { return Val.getResNo(); }
256 /// getValueType - Convenience function for get().getValueType().
257 EVT getValueType() const { return Val.getValueType(); }
259 /// operator== - Convenience function for get().operator==
260 bool operator==(const SDValue &V) const {
264 /// operator!= - Convenience function for get().operator!=
265 bool operator!=(const SDValue &V) const {
269 /// operator< - Convenience function for get().operator<
270 bool operator<(const SDValue &V) const {
275 friend class SelectionDAG;
278 void setUser(SDNode *p) { User = p; }
280 /// set - Remove this use from its existing use list, assign it the
281 /// given value, and add it to the new value's node's use list.
282 inline void set(const SDValue &V);
283 /// setInitial - like set, but only supports initializing a newly-allocated
284 /// SDUse with a non-null value.
285 inline void setInitial(const SDValue &V);
286 /// setNode - like set, but only sets the Node portion of the value,
287 /// leaving the ResNo portion unmodified.
288 inline void setNode(SDNode *N);
290 void addToList(SDUse **List) {
292 if (Next) Next->Prev = &Next;
297 void removeFromList() {
299 if (Next) Next->Prev = Prev;
303 /// simplify_type specializations - Allow casting operators to work directly on
304 /// SDValues as if they were SDNode*'s.
305 template<> struct simplify_type<SDUse> {
306 typedef SDNode* SimpleType;
307 static SimpleType getSimplifiedValue(SDUse &Val) {
308 return Val.getNode();
313 /// SDNode - Represents one node in the SelectionDAG.
315 class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
317 /// NodeType - The operation that this node performs.
321 /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true,
322 /// then they will be delete[]'d when the node is destroyed.
323 uint16_t OperandsNeedDelete : 1;
325 /// HasDebugValue - This tracks whether this node has one or more dbg_value
326 /// nodes corresponding to it.
327 uint16_t HasDebugValue : 1;
330 /// SubclassData - This member is defined by this class, but is not used for
331 /// anything. Subclasses can use it to hold whatever state they find useful.
332 /// This field is initialized to zero by the ctor.
333 uint16_t SubclassData : 14;
336 /// NodeId - Unique id per SDNode in the DAG.
339 /// OperandList - The values that are used by this operation.
343 /// ValueList - The types of the values this node defines. SDNode's may
344 /// define multiple values simultaneously.
345 const EVT *ValueList;
347 /// UseList - List of uses for this SDNode.
350 /// NumOperands/NumValues - The number of entries in the Operand/Value list.
351 unsigned short NumOperands, NumValues;
353 /// debugLoc - source line information.
356 // The ordering of the SDNodes. It roughly corresponds to the ordering of the
357 // original LLVM instructions.
358 // This is used for turning off scheduling, because we'll forgo
359 // the normal scheduling algorithms and output the instructions according to
363 /// getValueTypeList - Return a pointer to the specified value type.
364 static const EVT *getValueTypeList(EVT VT);
366 friend class SelectionDAG;
367 friend struct ilist_traits<SDNode>;
370 //===--------------------------------------------------------------------===//
374 /// getOpcode - Return the SelectionDAG opcode value for this node. For
375 /// pre-isel nodes (those for which isMachineOpcode returns false), these
376 /// are the opcode values in the ISD and <target>ISD namespaces. For
377 /// post-isel opcodes, see getMachineOpcode.
378 unsigned getOpcode() const { return (unsigned short)NodeType; }
380 /// isTargetOpcode - Test if this node has a target-specific opcode (in the
381 /// \<target\>ISD namespace).
382 bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
384 /// isTargetMemoryOpcode - Test if this node has a target-specific
385 /// memory-referencing opcode (in the \<target\>ISD namespace and
386 /// greater than FIRST_TARGET_MEMORY_OPCODE).
387 bool isTargetMemoryOpcode() const {
388 return NodeType >= ISD::FIRST_TARGET_MEMORY_OPCODE;
391 /// isMachineOpcode - Test if this node has a post-isel opcode, directly
392 /// corresponding to a MachineInstr opcode.
393 bool isMachineOpcode() const { return NodeType < 0; }
395 /// getMachineOpcode - This may only be called if isMachineOpcode returns
396 /// true. It returns the MachineInstr opcode value that the node's opcode
398 unsigned getMachineOpcode() const {
399 assert(isMachineOpcode() && "Not a MachineInstr opcode!");
403 /// getHasDebugValue - get this bit.
404 bool getHasDebugValue() const { return HasDebugValue; }
406 /// setHasDebugValue - set this bit.
407 void setHasDebugValue(bool b) { HasDebugValue = b; }
409 /// use_empty - Return true if there are no uses of this node.
411 bool use_empty() const { return UseList == NULL; }
413 /// hasOneUse - Return true if there is exactly one use of this node.
415 bool hasOneUse() const {
416 return !use_empty() && std::next(use_begin()) == use_end();
419 /// use_size - Return the number of uses of this node. This method takes
420 /// time proportional to the number of uses.
422 size_t use_size() const { return std::distance(use_begin(), use_end()); }
424 /// getNodeId - Return the unique node id.
426 int getNodeId() const { return NodeId; }
428 /// setNodeId - Set unique node id.
429 void setNodeId(int Id) { NodeId = Id; }
431 /// getIROrder - Return the node ordering.
433 unsigned getIROrder() const { return IROrder; }
435 /// setIROrder - Set the node ordering.
437 void setIROrder(unsigned Order) { IROrder = Order; }
439 /// getDebugLoc - Return the source location info.
440 const DebugLoc getDebugLoc() const { return debugLoc; }
442 /// setDebugLoc - Set source location info. Try to avoid this, putting
443 /// it in the constructor is preferable.
444 void setDebugLoc(const DebugLoc dl) { debugLoc = dl; }
446 /// use_iterator - This class provides iterator support for SDUse
447 /// operands that use a specific SDNode.
449 : public std::iterator<std::forward_iterator_tag, SDUse, ptrdiff_t> {
451 explicit use_iterator(SDUse *op) : Op(op) {
455 typedef std::iterator<std::forward_iterator_tag,
456 SDUse, ptrdiff_t>::reference reference;
457 typedef std::iterator<std::forward_iterator_tag,
458 SDUse, ptrdiff_t>::pointer pointer;
460 use_iterator(const use_iterator &I) : Op(I.Op) {}
461 use_iterator() : Op(0) {}
463 bool operator==(const use_iterator &x) const {
466 bool operator!=(const use_iterator &x) const {
467 return !operator==(x);
470 /// atEnd - return true if this iterator is at the end of uses list.
471 bool atEnd() const { return Op == 0; }
473 // Iterator traversal: forward iteration only.
474 use_iterator &operator++() { // Preincrement
475 assert(Op && "Cannot increment end iterator!");
480 use_iterator operator++(int) { // Postincrement
481 use_iterator tmp = *this; ++*this; return tmp;
484 /// Retrieve a pointer to the current user node.
485 SDNode *operator*() const {
486 assert(Op && "Cannot dereference end iterator!");
487 return Op->getUser();
490 SDNode *operator->() const { return operator*(); }
492 SDUse &getUse() const { return *Op; }
494 /// getOperandNo - Retrieve the operand # of this use in its user.
496 unsigned getOperandNo() const {
497 assert(Op && "Cannot dereference end iterator!");
498 return (unsigned)(Op - Op->getUser()->OperandList);
502 /// use_begin/use_end - Provide iteration support to walk over all uses
505 use_iterator use_begin() const {
506 return use_iterator(UseList);
509 static use_iterator use_end() { return use_iterator(0); }
511 inline iterator_range<use_iterator> uses() {
512 return iterator_range<use_iterator>(use_begin(), use_end());
514 inline iterator_range<use_iterator> uses() const {
515 return iterator_range<use_iterator>(use_begin(), use_end());
518 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
519 /// indicated value. This method ignores uses of other values defined by this
521 bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
523 /// hasAnyUseOfValue - Return true if there are any use of the indicated
524 /// value. This method ignores uses of other values defined by this operation.
525 bool hasAnyUseOfValue(unsigned Value) const;
527 /// isOnlyUserOf - Return true if this node is the only use of N.
529 bool isOnlyUserOf(SDNode *N) const;
531 /// isOperandOf - Return true if this node is an operand of N.
533 bool isOperandOf(SDNode *N) const;
535 /// isPredecessorOf - Return true if this node is a predecessor of N.
536 /// NOTE: Implemented on top of hasPredecessor and every bit as
537 /// expensive. Use carefully.
538 bool isPredecessorOf(const SDNode *N) const {
539 return N->hasPredecessor(this);
542 /// hasPredecessor - Return true if N is a predecessor of this node.
543 /// N is either an operand of this node, or can be reached by recursively
544 /// traversing up the operands.
545 /// NOTE: This is an expensive method. Use it carefully.
546 bool hasPredecessor(const SDNode *N) const;
548 /// hasPredecesorHelper - Return true if N is a predecessor of this node.
549 /// N is either an operand of this node, or can be reached by recursively
550 /// traversing up the operands.
551 /// In this helper the Visited and worklist sets are held externally to
552 /// cache predecessors over multiple invocations. If you want to test for
553 /// multiple predecessors this method is preferable to multiple calls to
554 /// hasPredecessor. Be sure to clear Visited and Worklist if the DAG
556 /// NOTE: This is still very expensive. Use carefully.
557 bool hasPredecessorHelper(const SDNode *N,
558 SmallPtrSet<const SDNode *, 32> &Visited,
559 SmallVectorImpl<const SDNode *> &Worklist) const;
561 /// getNumOperands - Return the number of values used by this operation.
563 unsigned getNumOperands() const { return NumOperands; }
565 /// getConstantOperandVal - Helper method returns the integer value of a
566 /// ConstantSDNode operand.
567 uint64_t getConstantOperandVal(unsigned Num) const;
569 const SDValue &getOperand(unsigned Num) const {
570 assert(Num < NumOperands && "Invalid child # of SDNode!");
571 return OperandList[Num];
574 typedef SDUse* op_iterator;
575 op_iterator op_begin() const { return OperandList; }
576 op_iterator op_end() const { return OperandList+NumOperands; }
578 SDVTList getVTList() const {
579 SDVTList X = { ValueList, NumValues };
583 /// getGluedNode - If this node has a glue operand, return the node
584 /// to which the glue operand points. Otherwise return NULL.
585 SDNode *getGluedNode() const {
586 if (getNumOperands() != 0 &&
587 getOperand(getNumOperands()-1).getValueType() == MVT::Glue)
588 return getOperand(getNumOperands()-1).getNode();
592 // If this is a pseudo op, like copyfromreg, look to see if there is a
593 // real target node glued to it. If so, return the target node.
594 const SDNode *getGluedMachineNode() const {
595 const SDNode *FoundNode = this;
597 // Climb up glue edges until a machine-opcode node is found, or the
598 // end of the chain is reached.
599 while (!FoundNode->isMachineOpcode()) {
600 const SDNode *N = FoundNode->getGluedNode();
608 /// getGluedUser - If this node has a glue value with a user, return
609 /// the user (there is at most one). Otherwise return NULL.
610 SDNode *getGluedUser() const {
611 for (use_iterator UI = use_begin(), UE = use_end(); UI != UE; ++UI)
612 if (UI.getUse().get().getValueType() == MVT::Glue)
617 /// getNumValues - Return the number of values defined/returned by this
620 unsigned getNumValues() const { return NumValues; }
622 /// getValueType - Return the type of a specified result.
624 EVT getValueType(unsigned ResNo) const {
625 assert(ResNo < NumValues && "Illegal result number!");
626 return ValueList[ResNo];
629 /// Return the type of a specified result as a simple type.
631 MVT getSimpleValueType(unsigned ResNo) const {
632 return getValueType(ResNo).getSimpleVT();
635 /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
637 unsigned getValueSizeInBits(unsigned ResNo) const {
638 return getValueType(ResNo).getSizeInBits();
641 typedef const EVT* value_iterator;
642 value_iterator value_begin() const { return ValueList; }
643 value_iterator value_end() const { return ValueList+NumValues; }
645 /// getOperationName - Return the opcode of this operation for printing.
647 std::string getOperationName(const SelectionDAG *G = 0) const;
648 static const char* getIndexedModeName(ISD::MemIndexedMode AM);
649 void print_types(raw_ostream &OS, const SelectionDAG *G) const;
650 void print_details(raw_ostream &OS, const SelectionDAG *G) const;
651 void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
652 void printr(raw_ostream &OS, const SelectionDAG *G = 0) const;
654 /// printrFull - Print a SelectionDAG node and all children down to
655 /// the leaves. The given SelectionDAG allows target-specific nodes
656 /// to be printed in human-readable form. Unlike printr, this will
657 /// print the whole DAG, including children that appear multiple
660 void printrFull(raw_ostream &O, const SelectionDAG *G = 0) const;
662 /// printrWithDepth - Print a SelectionDAG node and children up to
663 /// depth "depth." The given SelectionDAG allows target-specific
664 /// nodes to be printed in human-readable form. Unlike printr, this
665 /// will print children that appear multiple times wherever they are
668 void printrWithDepth(raw_ostream &O, const SelectionDAG *G = 0,
669 unsigned depth = 100) const;
672 /// dump - Dump this node, for debugging.
675 /// dumpr - Dump (recursively) this node and its use-def subgraph.
678 /// dump - Dump this node, for debugging.
679 /// The given SelectionDAG allows target-specific nodes to be printed
680 /// in human-readable form.
681 void dump(const SelectionDAG *G) const;
683 /// dumpr - Dump (recursively) this node and its use-def subgraph.
684 /// The given SelectionDAG allows target-specific nodes to be printed
685 /// in human-readable form.
686 void dumpr(const SelectionDAG *G) const;
688 /// dumprFull - printrFull to dbgs(). The given SelectionDAG allows
689 /// target-specific nodes to be printed in human-readable form.
690 /// Unlike dumpr, this will print the whole DAG, including children
691 /// that appear multiple times.
693 void dumprFull(const SelectionDAG *G = 0) const;
695 /// dumprWithDepth - printrWithDepth to dbgs(). The given
696 /// SelectionDAG allows target-specific nodes to be printed in
697 /// human-readable form. Unlike dumpr, this will print children
698 /// that appear multiple times wherever they are used.
700 void dumprWithDepth(const SelectionDAG *G = 0, unsigned depth = 100) const;
702 /// Profile - Gather unique data for the node.
704 void Profile(FoldingSetNodeID &ID) const;
706 /// addUse - This method should only be used by the SDUse class.
708 void addUse(SDUse &U) { U.addToList(&UseList); }
711 static SDVTList getSDVTList(EVT VT) {
712 SDVTList Ret = { getValueTypeList(VT), 1 };
716 SDNode(unsigned Opc, unsigned Order, const DebugLoc dl, SDVTList VTs,
717 const SDValue *Ops, unsigned NumOps)
718 : NodeType(Opc), OperandsNeedDelete(true), HasDebugValue(false),
719 SubclassData(0), NodeId(-1),
720 OperandList(NumOps ? new SDUse[NumOps] : 0),
721 ValueList(VTs.VTs), UseList(NULL),
722 NumOperands(NumOps), NumValues(VTs.NumVTs),
723 debugLoc(dl), IROrder(Order) {
724 for (unsigned i = 0; i != NumOps; ++i) {
725 OperandList[i].setUser(this);
726 OperandList[i].setInitial(Ops[i]);
728 checkForCycles(this);
731 /// This constructor adds no operands itself; operands can be
732 /// set later with InitOperands.
733 SDNode(unsigned Opc, unsigned Order, const DebugLoc dl, SDVTList VTs)
734 : NodeType(Opc), OperandsNeedDelete(false), HasDebugValue(false),
735 SubclassData(0), NodeId(-1), OperandList(0),
736 ValueList(VTs.VTs), UseList(NULL), NumOperands(0), NumValues(VTs.NumVTs),
737 debugLoc(dl), IROrder(Order) {}
739 /// InitOperands - Initialize the operands list of this with 1 operand.
740 void InitOperands(SDUse *Ops, const SDValue &Op0) {
741 Ops[0].setUser(this);
742 Ops[0].setInitial(Op0);
745 checkForCycles(this);
748 /// InitOperands - Initialize the operands list of this with 2 operands.
749 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) {
750 Ops[0].setUser(this);
751 Ops[0].setInitial(Op0);
752 Ops[1].setUser(this);
753 Ops[1].setInitial(Op1);
756 checkForCycles(this);
759 /// InitOperands - Initialize the operands list of this with 3 operands.
760 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
761 const SDValue &Op2) {
762 Ops[0].setUser(this);
763 Ops[0].setInitial(Op0);
764 Ops[1].setUser(this);
765 Ops[1].setInitial(Op1);
766 Ops[2].setUser(this);
767 Ops[2].setInitial(Op2);
770 checkForCycles(this);
773 /// InitOperands - Initialize the operands list of this with 4 operands.
774 void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
775 const SDValue &Op2, const SDValue &Op3) {
776 Ops[0].setUser(this);
777 Ops[0].setInitial(Op0);
778 Ops[1].setUser(this);
779 Ops[1].setInitial(Op1);
780 Ops[2].setUser(this);
781 Ops[2].setInitial(Op2);
782 Ops[3].setUser(this);
783 Ops[3].setInitial(Op3);
786 checkForCycles(this);
789 /// InitOperands - Initialize the operands list of this with N operands.
790 void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) {
791 for (unsigned i = 0; i != N; ++i) {
792 Ops[i].setUser(this);
793 Ops[i].setInitial(Vals[i]);
797 checkForCycles(this);
800 /// DropOperands - Release the operands and set this node to have
805 /// Wrapper class for IR location info (IR ordering and DebugLoc) to be passed
806 /// into SDNode creation functions.
807 /// When an SDNode is created from the DAGBuilder, the DebugLoc is extracted
808 /// from the original Instruction, and IROrder is the ordinal position of
810 /// When an SDNode is created after the DAG is being built, both DebugLoc and
811 /// the IROrder are propagated from the original SDNode.
812 /// So SDLoc class provides two constructors besides the default one, one to
813 /// be used by the DAGBuilder, the other to be used by others.
816 // Ptr could be used for either Instruction* or SDNode*. It is used for
817 // Instruction* if IROrder is not -1.
822 SDLoc() : Ptr(NULL), IROrder(0) {}
823 SDLoc(const SDNode *N) : Ptr(N), IROrder(-1) {
824 assert(N && "null SDNode");
826 SDLoc(const SDValue V) : Ptr(V.getNode()), IROrder(-1) {
827 assert(Ptr && "null SDNode");
829 SDLoc(const Instruction *I, int Order) : Ptr(I), IROrder(Order) {
830 assert(Order >= 0 && "bad IROrder");
832 unsigned getIROrder() {
833 if (IROrder >= 0 || Ptr == NULL) {
834 return (unsigned)IROrder;
836 const SDNode *N = (const SDNode*)(Ptr);
837 return N->getIROrder();
839 DebugLoc getDebugLoc() {
844 const Instruction *I = (const Instruction*)(Ptr);
845 return I->getDebugLoc();
847 const SDNode *N = (const SDNode*)(Ptr);
848 return N->getDebugLoc();
853 // Define inline functions from the SDValue class.
855 inline unsigned SDValue::getOpcode() const {
856 return Node->getOpcode();
858 inline EVT SDValue::getValueType() const {
859 return Node->getValueType(ResNo);
861 inline unsigned SDValue::getNumOperands() const {
862 return Node->getNumOperands();
864 inline const SDValue &SDValue::getOperand(unsigned i) const {
865 return Node->getOperand(i);
867 inline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
868 return Node->getConstantOperandVal(i);
870 inline bool SDValue::isTargetOpcode() const {
871 return Node->isTargetOpcode();
873 inline bool SDValue::isTargetMemoryOpcode() const {
874 return Node->isTargetMemoryOpcode();
876 inline bool SDValue::isMachineOpcode() const {
877 return Node->isMachineOpcode();
879 inline unsigned SDValue::getMachineOpcode() const {
880 return Node->getMachineOpcode();
882 inline bool SDValue::use_empty() const {
883 return !Node->hasAnyUseOfValue(ResNo);
885 inline bool SDValue::hasOneUse() const {
886 return Node->hasNUsesOfValue(1, ResNo);
888 inline const DebugLoc SDValue::getDebugLoc() const {
889 return Node->getDebugLoc();
891 inline void SDValue::dump() const {
894 inline void SDValue::dumpr() const {
895 return Node->dumpr();
897 // Define inline functions from the SDUse class.
899 inline void SDUse::set(const SDValue &V) {
900 if (Val.getNode()) removeFromList();
902 if (V.getNode()) V.getNode()->addUse(*this);
905 inline void SDUse::setInitial(const SDValue &V) {
907 V.getNode()->addUse(*this);
910 inline void SDUse::setNode(SDNode *N) {
911 if (Val.getNode()) removeFromList();
913 if (N) N->addUse(*this);
916 /// UnarySDNode - This class is used for single-operand SDNodes. This is solely
917 /// to allow co-allocation of node operands with the node itself.
918 class UnarySDNode : public SDNode {
921 UnarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
923 : SDNode(Opc, Order, dl, VTs) {
924 InitOperands(&Op, X);
928 /// BinarySDNode - This class is used for two-operand SDNodes. This is solely
929 /// to allow co-allocation of node operands with the node itself.
930 class BinarySDNode : public SDNode {
933 BinarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
934 SDValue X, SDValue Y)
935 : SDNode(Opc, Order, dl, VTs) {
936 InitOperands(Ops, X, Y);
940 /// TernarySDNode - This class is used for three-operand SDNodes. This is solely
941 /// to allow co-allocation of node operands with the node itself.
942 class TernarySDNode : public SDNode {
945 TernarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
946 SDValue X, SDValue Y, SDValue Z)
947 : SDNode(Opc, Order, dl, VTs) {
948 InitOperands(Ops, X, Y, Z);
953 /// HandleSDNode - This class is used to form a handle around another node that
954 /// is persistent and is updated across invocations of replaceAllUsesWith on its
955 /// operand. This node should be directly created by end-users and not added to
956 /// the AllNodes list.
957 class HandleSDNode : public SDNode {
960 explicit HandleSDNode(SDValue X)
961 : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) {
962 InitOperands(&Op, X);
965 const SDValue &getValue() const { return Op; }
968 class AddrSpaceCastSDNode : public UnarySDNode {
970 unsigned SrcAddrSpace;
971 unsigned DestAddrSpace;
974 AddrSpaceCastSDNode(unsigned Order, DebugLoc dl, EVT VT, SDValue X,
975 unsigned SrcAS, unsigned DestAS);
977 unsigned getSrcAddressSpace() const { return SrcAddrSpace; }
978 unsigned getDestAddressSpace() const { return DestAddrSpace; }
980 static bool classof(const SDNode *N) {
981 return N->getOpcode() == ISD::ADDRSPACECAST;
985 /// Abstact virtual class for operations for memory operations
986 class MemSDNode : public SDNode {
988 // MemoryVT - VT of in-memory value.
992 /// MMO - Memory reference information.
993 MachineMemOperand *MMO;
996 MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
997 EVT MemoryVT, MachineMemOperand *MMO);
999 MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1001 unsigned NumOps, EVT MemoryVT, MachineMemOperand *MMO);
1003 bool readMem() const { return MMO->isLoad(); }
1004 bool writeMem() const { return MMO->isStore(); }
1006 /// Returns alignment and volatility of the memory access
1007 unsigned getOriginalAlignment() const {
1008 return MMO->getBaseAlignment();
1010 unsigned getAlignment() const {
1011 return MMO->getAlignment();
1014 /// getRawSubclassData - Return the SubclassData value, which contains an
1015 /// encoding of the volatile flag, as well as bits used by subclasses. This
1016 /// function should only be used to compute a FoldingSetNodeID value.
1017 unsigned getRawSubclassData() const {
1018 return SubclassData;
1021 // We access subclass data here so that we can check consistency
1022 // with MachineMemOperand information.
1023 bool isVolatile() const { return (SubclassData >> 5) & 1; }
1024 bool isNonTemporal() const { return (SubclassData >> 6) & 1; }
1025 bool isInvariant() const { return (SubclassData >> 7) & 1; }
1027 AtomicOrdering getOrdering() const {
1028 return AtomicOrdering((SubclassData >> 8) & 15);
1030 SynchronizationScope getSynchScope() const {
1031 return SynchronizationScope((SubclassData >> 12) & 1);
1034 /// Returns the SrcValue and offset that describes the location of the access
1035 const Value *getSrcValue() const { return MMO->getValue(); }
1036 int64_t getSrcValueOffset() const { return MMO->getOffset(); }
1038 /// Returns the TBAAInfo that describes the dereference.
1039 const MDNode *getTBAAInfo() const { return MMO->getTBAAInfo(); }
1041 /// Returns the Ranges that describes the dereference.
1042 const MDNode *getRanges() const { return MMO->getRanges(); }
1044 /// getMemoryVT - Return the type of the in-memory value.
1045 EVT getMemoryVT() const { return MemoryVT; }
1047 /// getMemOperand - Return a MachineMemOperand object describing the memory
1048 /// reference performed by operation.
1049 MachineMemOperand *getMemOperand() const { return MMO; }
1051 const MachinePointerInfo &getPointerInfo() const {
1052 return MMO->getPointerInfo();
1055 /// getAddressSpace - Return the address space for the associated pointer
1056 unsigned getAddressSpace() const {
1057 return getPointerInfo().getAddrSpace();
1060 /// refineAlignment - Update this MemSDNode's MachineMemOperand information
1061 /// to reflect the alignment of NewMMO, if it has a greater alignment.
1062 /// This must only be used when the new alignment applies to all users of
1063 /// this MachineMemOperand.
1064 void refineAlignment(const MachineMemOperand *NewMMO) {
1065 MMO->refineAlignment(NewMMO);
1068 const SDValue &getChain() const { return getOperand(0); }
1069 const SDValue &getBasePtr() const {
1070 return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
1073 // Methods to support isa and dyn_cast
1074 static bool classof(const SDNode *N) {
1075 // For some targets, we lower some target intrinsics to a MemIntrinsicNode
1076 // with either an intrinsic or a target opcode.
1077 return N->getOpcode() == ISD::LOAD ||
1078 N->getOpcode() == ISD::STORE ||
1079 N->getOpcode() == ISD::PREFETCH ||
1080 N->getOpcode() == ISD::ATOMIC_CMP_SWAP ||
1081 N->getOpcode() == ISD::ATOMIC_SWAP ||
1082 N->getOpcode() == ISD::ATOMIC_LOAD_ADD ||
1083 N->getOpcode() == ISD::ATOMIC_LOAD_SUB ||
1084 N->getOpcode() == ISD::ATOMIC_LOAD_AND ||
1085 N->getOpcode() == ISD::ATOMIC_LOAD_OR ||
1086 N->getOpcode() == ISD::ATOMIC_LOAD_XOR ||
1087 N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1088 N->getOpcode() == ISD::ATOMIC_LOAD_MIN ||
1089 N->getOpcode() == ISD::ATOMIC_LOAD_MAX ||
1090 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1091 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX ||
1092 N->getOpcode() == ISD::ATOMIC_LOAD ||
1093 N->getOpcode() == ISD::ATOMIC_STORE ||
1094 N->isTargetMemoryOpcode();
1098 /// AtomicSDNode - A SDNode reprenting atomic operations.
1100 class AtomicSDNode : public MemSDNode {
1103 /// For cmpxchg instructions, the ordering requirements when a store does not
1105 AtomicOrdering FailureOrdering;
1107 void InitAtomic(AtomicOrdering SuccessOrdering,
1108 AtomicOrdering FailureOrdering,
1109 SynchronizationScope SynchScope) {
1110 // This must match encodeMemSDNodeFlags() in SelectionDAG.cpp.
1111 assert((SuccessOrdering & 15) == SuccessOrdering &&
1112 "Ordering may not require more than 4 bits!");
1113 assert((FailureOrdering & 15) == FailureOrdering &&
1114 "Ordering may not require more than 4 bits!");
1115 assert((SynchScope & 1) == SynchScope &&
1116 "SynchScope may not require more than 1 bit!");
1117 SubclassData |= SuccessOrdering << 8;
1118 SubclassData |= SynchScope << 12;
1119 this->FailureOrdering = FailureOrdering;
1120 assert(getSuccessOrdering() == SuccessOrdering &&
1121 "Ordering encoding error!");
1122 assert(getFailureOrdering() == FailureOrdering &&
1123 "Ordering encoding error!");
1124 assert(getSynchScope() == SynchScope && "Synch-scope encoding error!");
1128 // Opc: opcode for atomic
1129 // VTL: value type list
1130 // Chain: memory chain for operaand
1131 // Ptr: address to update as a SDValue
1132 // Cmp: compare value
1134 // SrcVal: address to update as a Value (used for MemOperand)
1135 // Align: alignment of memory
1136 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1137 EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp,
1138 MachineMemOperand *MMO, AtomicOrdering Ordering,
1139 SynchronizationScope SynchScope)
1140 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1141 InitAtomic(Ordering, Ordering, SynchScope);
1142 InitOperands(Ops, Chain, Ptr, Cmp, Swp);
1144 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1146 SDValue Chain, SDValue Ptr,
1147 SDValue Val, MachineMemOperand *MMO,
1148 AtomicOrdering Ordering, SynchronizationScope SynchScope)
1149 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1150 InitAtomic(Ordering, Ordering, SynchScope);
1151 InitOperands(Ops, Chain, Ptr, Val);
1153 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL,
1155 SDValue Chain, SDValue Ptr,
1156 MachineMemOperand *MMO,
1157 AtomicOrdering Ordering, SynchronizationScope SynchScope)
1158 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1159 InitAtomic(Ordering, Ordering, SynchScope);
1160 InitOperands(Ops, Chain, Ptr);
1162 AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT,
1163 SDValue* AllOps, SDUse *DynOps, unsigned NumOps,
1164 MachineMemOperand *MMO,
1165 AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
1166 SynchronizationScope SynchScope)
1167 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1168 InitAtomic(SuccessOrdering, FailureOrdering, SynchScope);
1169 assert((DynOps || NumOps <= array_lengthof(Ops)) &&
1170 "Too many ops for internal storage!");
1171 InitOperands(DynOps ? DynOps : Ops, AllOps, NumOps);
1174 const SDValue &getBasePtr() const { return getOperand(1); }
1175 const SDValue &getVal() const { return getOperand(2); }
1177 AtomicOrdering getSuccessOrdering() const {
1178 return getOrdering();
1181 // Not quite enough room in SubclassData for everything, so failure gets its
1183 AtomicOrdering getFailureOrdering() const {
1184 return FailureOrdering;
1187 bool isCompareAndSwap() const {
1188 unsigned Op = getOpcode();
1189 return Op == ISD::ATOMIC_CMP_SWAP;
1192 // Methods to support isa and dyn_cast
1193 static bool classof(const SDNode *N) {
1194 return N->getOpcode() == ISD::ATOMIC_CMP_SWAP ||
1195 N->getOpcode() == ISD::ATOMIC_SWAP ||
1196 N->getOpcode() == ISD::ATOMIC_LOAD_ADD ||
1197 N->getOpcode() == ISD::ATOMIC_LOAD_SUB ||
1198 N->getOpcode() == ISD::ATOMIC_LOAD_AND ||
1199 N->getOpcode() == ISD::ATOMIC_LOAD_OR ||
1200 N->getOpcode() == ISD::ATOMIC_LOAD_XOR ||
1201 N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1202 N->getOpcode() == ISD::ATOMIC_LOAD_MIN ||
1203 N->getOpcode() == ISD::ATOMIC_LOAD_MAX ||
1204 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1205 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX ||
1206 N->getOpcode() == ISD::ATOMIC_LOAD ||
1207 N->getOpcode() == ISD::ATOMIC_STORE;
1211 /// MemIntrinsicSDNode - This SDNode is used for target intrinsics that touch
1212 /// memory and need an associated MachineMemOperand. Its opcode may be
1213 /// INTRINSIC_VOID, INTRINSIC_W_CHAIN, PREFETCH, or a target-specific opcode
1214 /// with a value not less than FIRST_TARGET_MEMORY_OPCODE.
1215 class MemIntrinsicSDNode : public MemSDNode {
1217 MemIntrinsicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs,
1218 const SDValue *Ops, unsigned NumOps,
1219 EVT MemoryVT, MachineMemOperand *MMO)
1220 : MemSDNode(Opc, Order, dl, VTs, Ops, NumOps, MemoryVT, MMO) {
1223 // Methods to support isa and dyn_cast
1224 static bool classof(const SDNode *N) {
1225 // We lower some target intrinsics to their target opcode
1226 // early a node with a target opcode can be of this class
1227 return N->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1228 N->getOpcode() == ISD::INTRINSIC_VOID ||
1229 N->getOpcode() == ISD::PREFETCH ||
1230 N->isTargetMemoryOpcode();
1234 /// ShuffleVectorSDNode - This SDNode is used to implement the code generator
1235 /// support for the llvm IR shufflevector instruction. It combines elements
1236 /// from two input vectors into a new input vector, with the selection and
1237 /// ordering of elements determined by an array of integers, referred to as
1238 /// the shuffle mask. For input vectors of width N, mask indices of 0..N-1
1239 /// refer to elements from the LHS input, and indices from N to 2N-1 the RHS.
1240 /// An index of -1 is treated as undef, such that the code generator may put
1241 /// any value in the corresponding element of the result.
1242 class ShuffleVectorSDNode : public SDNode {
1245 // The memory for Mask is owned by the SelectionDAG's OperandAllocator, and
1246 // is freed when the SelectionDAG object is destroyed.
1249 friend class SelectionDAG;
1250 ShuffleVectorSDNode(EVT VT, unsigned Order, DebugLoc dl, SDValue N1,
1251 SDValue N2, const int *M)
1252 : SDNode(ISD::VECTOR_SHUFFLE, Order, dl, getSDVTList(VT)), Mask(M) {
1253 InitOperands(Ops, N1, N2);
1257 ArrayRef<int> getMask() const {
1258 EVT VT = getValueType(0);
1259 return makeArrayRef(Mask, VT.getVectorNumElements());
1261 int getMaskElt(unsigned Idx) const {
1262 assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!");
1266 bool isSplat() const { return isSplatMask(Mask, getValueType(0)); }
1267 int getSplatIndex() const {
1268 assert(isSplat() && "Cannot get splat index for non-splat!");
1269 EVT VT = getValueType(0);
1270 for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) {
1274 llvm_unreachable("Splat with all undef indices?");
1276 static bool isSplatMask(const int *Mask, EVT VT);
1278 static bool classof(const SDNode *N) {
1279 return N->getOpcode() == ISD::VECTOR_SHUFFLE;
1283 class ConstantSDNode : public SDNode {
1284 const ConstantInt *Value;
1285 friend class SelectionDAG;
1286 ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, EVT VT)
1287 : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant,
1288 0, DebugLoc(), getSDVTList(VT)), Value(val) {
1289 SubclassData |= (uint16_t)isOpaque;
1293 const ConstantInt *getConstantIntValue() const { return Value; }
1294 const APInt &getAPIntValue() const { return Value->getValue(); }
1295 uint64_t getZExtValue() const { return Value->getZExtValue(); }
1296 int64_t getSExtValue() const { return Value->getSExtValue(); }
1298 bool isOne() const { return Value->isOne(); }
1299 bool isNullValue() const { return Value->isNullValue(); }
1300 bool isAllOnesValue() const { return Value->isAllOnesValue(); }
1302 bool isOpaque() const { return SubclassData & 1; }
1304 static bool classof(const SDNode *N) {
1305 return N->getOpcode() == ISD::Constant ||
1306 N->getOpcode() == ISD::TargetConstant;
1310 class ConstantFPSDNode : public SDNode {
1311 const ConstantFP *Value;
1312 friend class SelectionDAG;
1313 ConstantFPSDNode(bool isTarget, const ConstantFP *val, EVT VT)
1314 : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
1315 0, DebugLoc(), getSDVTList(VT)), Value(val) {
1319 const APFloat& getValueAPF() const { return Value->getValueAPF(); }
1320 const ConstantFP *getConstantFPValue() const { return Value; }
1322 /// isZero - Return true if the value is positive or negative zero.
1323 bool isZero() const { return Value->isZero(); }
1325 /// isNaN - Return true if the value is a NaN.
1326 bool isNaN() const { return Value->isNaN(); }
1328 /// isExactlyValue - We don't rely on operator== working on double values, as
1329 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1330 /// As such, this method can be used to do an exact bit-for-bit comparison of
1331 /// two floating point values.
1333 /// We leave the version with the double argument here because it's just so
1334 /// convenient to write "2.0" and the like. Without this function we'd
1335 /// have to duplicate its logic everywhere it's called.
1336 bool isExactlyValue(double V) const {
1339 Tmp.convert(Value->getValueAPF().getSemantics(),
1340 APFloat::rmNearestTiesToEven, &ignored);
1341 return isExactlyValue(Tmp);
1343 bool isExactlyValue(const APFloat& V) const;
1345 static bool isValueValidForType(EVT VT, const APFloat& Val);
1347 static bool classof(const SDNode *N) {
1348 return N->getOpcode() == ISD::ConstantFP ||
1349 N->getOpcode() == ISD::TargetConstantFP;
1353 class GlobalAddressSDNode : public SDNode {
1354 const GlobalValue *TheGlobal;
1356 unsigned char TargetFlags;
1357 friend class SelectionDAG;
1358 GlobalAddressSDNode(unsigned Opc, unsigned Order, DebugLoc DL,
1359 const GlobalValue *GA, EVT VT, int64_t o,
1360 unsigned char TargetFlags);
1363 const GlobalValue *getGlobal() const { return TheGlobal; }
1364 int64_t getOffset() const { return Offset; }
1365 unsigned char getTargetFlags() const { return TargetFlags; }
1366 // Return the address space this GlobalAddress belongs to.
1367 unsigned getAddressSpace() const;
1369 static bool classof(const SDNode *N) {
1370 return N->getOpcode() == ISD::GlobalAddress ||
1371 N->getOpcode() == ISD::TargetGlobalAddress ||
1372 N->getOpcode() == ISD::GlobalTLSAddress ||
1373 N->getOpcode() == ISD::TargetGlobalTLSAddress;
1377 class FrameIndexSDNode : public SDNode {
1379 friend class SelectionDAG;
1380 FrameIndexSDNode(int fi, EVT VT, bool isTarg)
1381 : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex,
1382 0, DebugLoc(), getSDVTList(VT)), FI(fi) {
1386 int getIndex() const { return FI; }
1388 static bool classof(const SDNode *N) {
1389 return N->getOpcode() == ISD::FrameIndex ||
1390 N->getOpcode() == ISD::TargetFrameIndex;
1394 class JumpTableSDNode : public SDNode {
1396 unsigned char TargetFlags;
1397 friend class SelectionDAG;
1398 JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned char TF)
1399 : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable,
1400 0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) {
1404 int getIndex() const { return JTI; }
1405 unsigned char getTargetFlags() const { return TargetFlags; }
1407 static bool classof(const SDNode *N) {
1408 return N->getOpcode() == ISD::JumpTable ||
1409 N->getOpcode() == ISD::TargetJumpTable;
1413 class ConstantPoolSDNode : public SDNode {
1415 const Constant *ConstVal;
1416 MachineConstantPoolValue *MachineCPVal;
1418 int Offset; // It's a MachineConstantPoolValue if top bit is set.
1419 unsigned Alignment; // Minimum alignment requirement of CP (not log2 value).
1420 unsigned char TargetFlags;
1421 friend class SelectionDAG;
1422 ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o,
1423 unsigned Align, unsigned char TF)
1424 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
1425 DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align),
1427 assert(Offset >= 0 && "Offset is too large");
1430 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1431 EVT VT, int o, unsigned Align, unsigned char TF)
1432 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
1433 DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align),
1435 assert(Offset >= 0 && "Offset is too large");
1436 Val.MachineCPVal = v;
1437 Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1);
1441 bool isMachineConstantPoolEntry() const {
1445 const Constant *getConstVal() const {
1446 assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1447 return Val.ConstVal;
1450 MachineConstantPoolValue *getMachineCPVal() const {
1451 assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1452 return Val.MachineCPVal;
1455 int getOffset() const {
1456 return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1));
1459 // Return the alignment of this constant pool object, which is either 0 (for
1460 // default alignment) or the desired value.
1461 unsigned getAlignment() const { return Alignment; }
1462 unsigned char getTargetFlags() const { return TargetFlags; }
1464 Type *getType() const;
1466 static bool classof(const SDNode *N) {
1467 return N->getOpcode() == ISD::ConstantPool ||
1468 N->getOpcode() == ISD::TargetConstantPool;
1472 /// Completely target-dependent object reference.
1473 class TargetIndexSDNode : public SDNode {
1474 unsigned char TargetFlags;
1477 friend class SelectionDAG;
1480 TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned char TF)
1481 : SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)),
1482 TargetFlags(TF), Index(Idx), Offset(Ofs) {}
1485 unsigned char getTargetFlags() const { return TargetFlags; }
1486 int getIndex() const { return Index; }
1487 int64_t getOffset() const { return Offset; }
1489 static bool classof(const SDNode *N) {
1490 return N->getOpcode() == ISD::TargetIndex;
1494 class BasicBlockSDNode : public SDNode {
1495 MachineBasicBlock *MBB;
1496 friend class SelectionDAG;
1497 /// Debug info is meaningful and potentially useful here, but we create
1498 /// blocks out of order when they're jumped to, which makes it a bit
1499 /// harder. Let's see if we need it first.
1500 explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1501 : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb)
1505 MachineBasicBlock *getBasicBlock() const { return MBB; }
1507 static bool classof(const SDNode *N) {
1508 return N->getOpcode() == ISD::BasicBlock;
1512 /// BuildVectorSDNode - A "pseudo-class" with methods for operating on
1514 class BuildVectorSDNode : public SDNode {
1515 // These are constructed as SDNodes and then cast to BuildVectorSDNodes.
1516 explicit BuildVectorSDNode() LLVM_DELETED_FUNCTION;
1518 /// isConstantSplat - Check if this is a constant splat, and if so, find the
1519 /// smallest element size that splats the vector. If MinSplatBits is
1520 /// nonzero, the element size must be at least that large. Note that the
1521 /// splat element may be the entire vector (i.e., a one element vector).
1522 /// Returns the splat element value in SplatValue. Any undefined bits in
1523 /// that value are zero, and the corresponding bits in the SplatUndef mask
1524 /// are set. The SplatBitSize value is set to the splat element size in
1525 /// bits. HasAnyUndefs is set to true if any bits in the vector are
1526 /// undefined. isBigEndian describes the endianness of the target.
1527 bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef,
1528 unsigned &SplatBitSize, bool &HasAnyUndefs,
1529 unsigned MinSplatBits = 0,
1530 bool isBigEndian = false) const;
1532 /// getConstantSplatValue - Check if this is a constant splat, and if so,
1533 /// return the splat value only if it is a ConstantSDNode. Otherwise
1534 /// return nullptr. This is a simpler form of isConstantSplat.
1535 /// Get the constant splat only if you care about the splat value.
1536 ConstantSDNode *getConstantSplatValue() const;
1538 bool isConstant() const;
1540 static inline bool classof(const SDNode *N) {
1541 return N->getOpcode() == ISD::BUILD_VECTOR;
1545 /// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
1546 /// used when the SelectionDAG needs to make a simple reference to something
1547 /// in the LLVM IR representation.
1549 class SrcValueSDNode : public SDNode {
1551 friend class SelectionDAG;
1552 /// Create a SrcValue for a general value.
1553 explicit SrcValueSDNode(const Value *v)
1554 : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {}
1557 /// getValue - return the contained Value.
1558 const Value *getValue() const { return V; }
1560 static bool classof(const SDNode *N) {
1561 return N->getOpcode() == ISD::SRCVALUE;
1565 class MDNodeSDNode : public SDNode {
1567 friend class SelectionDAG;
1568 explicit MDNodeSDNode(const MDNode *md)
1569 : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md)
1573 const MDNode *getMD() const { return MD; }
1575 static bool classof(const SDNode *N) {
1576 return N->getOpcode() == ISD::MDNODE_SDNODE;
1580 class RegisterSDNode : public SDNode {
1582 friend class SelectionDAG;
1583 RegisterSDNode(unsigned reg, EVT VT)
1584 : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {
1588 unsigned getReg() const { return Reg; }
1590 static bool classof(const SDNode *N) {
1591 return N->getOpcode() == ISD::Register;
1595 class RegisterMaskSDNode : public SDNode {
1596 // The memory for RegMask is not owned by the node.
1597 const uint32_t *RegMask;
1598 friend class SelectionDAG;
1599 RegisterMaskSDNode(const uint32_t *mask)
1600 : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)),
1604 const uint32_t *getRegMask() const { return RegMask; }
1606 static bool classof(const SDNode *N) {
1607 return N->getOpcode() == ISD::RegisterMask;
1611 class BlockAddressSDNode : public SDNode {
1612 const BlockAddress *BA;
1614 unsigned char TargetFlags;
1615 friend class SelectionDAG;
1616 BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba,
1617 int64_t o, unsigned char Flags)
1618 : SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)),
1619 BA(ba), Offset(o), TargetFlags(Flags) {
1622 const BlockAddress *getBlockAddress() const { return BA; }
1623 int64_t getOffset() const { return Offset; }
1624 unsigned char getTargetFlags() const { return TargetFlags; }
1626 static bool classof(const SDNode *N) {
1627 return N->getOpcode() == ISD::BlockAddress ||
1628 N->getOpcode() == ISD::TargetBlockAddress;
1632 class EHLabelSDNode : public SDNode {
1635 friend class SelectionDAG;
1636 EHLabelSDNode(unsigned Order, DebugLoc dl, SDValue ch, MCSymbol *L)
1637 : SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {
1638 InitOperands(&Chain, ch);
1641 MCSymbol *getLabel() const { return Label; }
1643 static bool classof(const SDNode *N) {
1644 return N->getOpcode() == ISD::EH_LABEL;
1648 class ExternalSymbolSDNode : public SDNode {
1650 unsigned char TargetFlags;
1652 friend class SelectionDAG;
1653 ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT)
1654 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
1655 0, DebugLoc(), getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) {
1659 const char *getSymbol() const { return Symbol; }
1660 unsigned char getTargetFlags() const { return TargetFlags; }
1662 static bool classof(const SDNode *N) {
1663 return N->getOpcode() == ISD::ExternalSymbol ||
1664 N->getOpcode() == ISD::TargetExternalSymbol;
1668 class CondCodeSDNode : public SDNode {
1669 ISD::CondCode Condition;
1670 friend class SelectionDAG;
1671 explicit CondCodeSDNode(ISD::CondCode Cond)
1672 : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)),
1677 ISD::CondCode get() const { return Condition; }
1679 static bool classof(const SDNode *N) {
1680 return N->getOpcode() == ISD::CONDCODE;
1684 /// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the
1685 /// future and most targets don't support it.
1686 class CvtRndSatSDNode : public SDNode {
1687 ISD::CvtCode CvtCode;
1688 friend class SelectionDAG;
1689 explicit CvtRndSatSDNode(EVT VT, unsigned Order, DebugLoc dl,
1690 const SDValue *Ops, unsigned NumOps,
1692 : SDNode(ISD::CONVERT_RNDSAT, Order, dl, getSDVTList(VT), Ops, NumOps),
1694 assert(NumOps == 5 && "wrong number of operations");
1697 ISD::CvtCode getCvtCode() const { return CvtCode; }
1699 static bool classof(const SDNode *N) {
1700 return N->getOpcode() == ISD::CONVERT_RNDSAT;
1704 /// VTSDNode - This class is used to represent EVT's, which are used
1705 /// to parameterize some operations.
1706 class VTSDNode : public SDNode {
1708 friend class SelectionDAG;
1709 explicit VTSDNode(EVT VT)
1710 : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)),
1715 EVT getVT() const { return ValueType; }
1717 static bool classof(const SDNode *N) {
1718 return N->getOpcode() == ISD::VALUETYPE;
1722 /// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
1724 class LSBaseSDNode : public MemSDNode {
1725 //! Operand array for load and store
1727 \note Moving this array to the base class captures more
1728 common functionality shared between LoadSDNode and
1733 LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, DebugLoc dl,
1734 SDValue *Operands, unsigned numOperands,
1735 SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT,
1736 MachineMemOperand *MMO)
1737 : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
1738 SubclassData |= AM << 2;
1739 assert(getAddressingMode() == AM && "MemIndexedMode encoding error!");
1740 InitOperands(Ops, Operands, numOperands);
1741 assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
1742 "Only indexed loads and stores have a non-undef offset operand");
1745 const SDValue &getOffset() const {
1746 return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
1749 /// getAddressingMode - Return the addressing mode for this load or store:
1750 /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
1751 ISD::MemIndexedMode getAddressingMode() const {
1752 return ISD::MemIndexedMode((SubclassData >> 2) & 7);
1755 /// isIndexed - Return true if this is a pre/post inc/dec load/store.
1756 bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
1758 /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
1759 bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
1761 static bool classof(const SDNode *N) {
1762 return N->getOpcode() == ISD::LOAD ||
1763 N->getOpcode() == ISD::STORE;
1767 /// LoadSDNode - This class is used to represent ISD::LOAD nodes.
1769 class LoadSDNode : public LSBaseSDNode {
1770 friend class SelectionDAG;
1771 LoadSDNode(SDValue *ChainPtrOff, unsigned Order, DebugLoc dl, SDVTList VTs,
1772 ISD::MemIndexedMode AM, ISD::LoadExtType ETy, EVT MemVT,
1773 MachineMemOperand *MMO)
1774 : LSBaseSDNode(ISD::LOAD, Order, dl, ChainPtrOff, 3, VTs, AM, MemVT, MMO) {
1775 SubclassData |= (unsigned short)ETy;
1776 assert(getExtensionType() == ETy && "LoadExtType encoding error!");
1777 assert(readMem() && "Load MachineMemOperand is not a load!");
1778 assert(!writeMem() && "Load MachineMemOperand is a store!");
1782 /// getExtensionType - Return whether this is a plain node,
1783 /// or one of the varieties of value-extending loads.
1784 ISD::LoadExtType getExtensionType() const {
1785 return ISD::LoadExtType(SubclassData & 3);
1788 const SDValue &getBasePtr() const { return getOperand(1); }
1789 const SDValue &getOffset() const { return getOperand(2); }
1791 static bool classof(const SDNode *N) {
1792 return N->getOpcode() == ISD::LOAD;
1796 /// StoreSDNode - This class is used to represent ISD::STORE nodes.
1798 class StoreSDNode : public LSBaseSDNode {
1799 friend class SelectionDAG;
1800 StoreSDNode(SDValue *ChainValuePtrOff, unsigned Order, DebugLoc dl,
1801 SDVTList VTs, ISD::MemIndexedMode AM, bool isTrunc, EVT MemVT,
1802 MachineMemOperand *MMO)
1803 : LSBaseSDNode(ISD::STORE, Order, dl, ChainValuePtrOff, 4,
1804 VTs, AM, MemVT, MMO) {
1805 SubclassData |= (unsigned short)isTrunc;
1806 assert(isTruncatingStore() == isTrunc && "isTrunc encoding error!");
1807 assert(!readMem() && "Store MachineMemOperand is a load!");
1808 assert(writeMem() && "Store MachineMemOperand is not a store!");
1812 /// isTruncatingStore - Return true if the op does a truncation before store.
1813 /// For integers this is the same as doing a TRUNCATE and storing the result.
1814 /// For floats, it is the same as doing an FP_ROUND and storing the result.
1815 bool isTruncatingStore() const { return SubclassData & 1; }
1817 const SDValue &getValue() const { return getOperand(1); }
1818 const SDValue &getBasePtr() const { return getOperand(2); }
1819 const SDValue &getOffset() const { return getOperand(3); }
1821 static bool classof(const SDNode *N) {
1822 return N->getOpcode() == ISD::STORE;
1826 /// MachineSDNode - An SDNode that represents everything that will be needed
1827 /// to construct a MachineInstr. These nodes are created during the
1828 /// instruction selection proper phase.
1830 class MachineSDNode : public SDNode {
1832 typedef MachineMemOperand **mmo_iterator;
1835 friend class SelectionDAG;
1836 MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc DL, SDVTList VTs)
1837 : SDNode(Opc, Order, DL, VTs), MemRefs(0), MemRefsEnd(0) {}
1839 /// LocalOperands - Operands for this instruction, if they fit here. If
1840 /// they don't, this field is unused.
1841 SDUse LocalOperands[4];
1843 /// MemRefs - Memory reference descriptions for this instruction.
1844 mmo_iterator MemRefs;
1845 mmo_iterator MemRefsEnd;
1848 mmo_iterator memoperands_begin() const { return MemRefs; }
1849 mmo_iterator memoperands_end() const { return MemRefsEnd; }
1850 bool memoperands_empty() const { return MemRefsEnd == MemRefs; }
1852 /// setMemRefs - Assign this MachineSDNodes's memory reference descriptor
1853 /// list. This does not transfer ownership.
1854 void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd) {
1855 for (mmo_iterator MMI = NewMemRefs, MME = NewMemRefsEnd; MMI != MME; ++MMI)
1856 assert(*MMI && "Null mem ref detected!");
1857 MemRefs = NewMemRefs;
1858 MemRefsEnd = NewMemRefsEnd;
1861 static bool classof(const SDNode *N) {
1862 return N->isMachineOpcode();
1866 class SDNodeIterator : public std::iterator<std::forward_iterator_tag,
1867 SDNode, ptrdiff_t> {
1871 SDNodeIterator(const SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
1873 bool operator==(const SDNodeIterator& x) const {
1874 return Operand == x.Operand;
1876 bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
1878 const SDNodeIterator &operator=(const SDNodeIterator &I) {
1879 assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
1880 Operand = I.Operand;
1884 pointer operator*() const {
1885 return Node->getOperand(Operand).getNode();
1887 pointer operator->() const { return operator*(); }
1889 SDNodeIterator& operator++() { // Preincrement
1893 SDNodeIterator operator++(int) { // Postincrement
1894 SDNodeIterator tmp = *this; ++*this; return tmp;
1896 size_t operator-(SDNodeIterator Other) const {
1897 assert(Node == Other.Node &&
1898 "Cannot compare iterators of two different nodes!");
1899 return Operand - Other.Operand;
1902 static SDNodeIterator begin(const SDNode *N) { return SDNodeIterator(N, 0); }
1903 static SDNodeIterator end (const SDNode *N) {
1904 return SDNodeIterator(N, N->getNumOperands());
1907 unsigned getOperand() const { return Operand; }
1908 const SDNode *getNode() const { return Node; }
1911 template <> struct GraphTraits<SDNode*> {
1912 typedef SDNode NodeType;
1913 typedef SDNodeIterator ChildIteratorType;
1914 static inline NodeType *getEntryNode(SDNode *N) { return N; }
1915 static inline ChildIteratorType child_begin(NodeType *N) {
1916 return SDNodeIterator::begin(N);
1918 static inline ChildIteratorType child_end(NodeType *N) {
1919 return SDNodeIterator::end(N);
1923 /// LargestSDNode - The largest SDNode class.
1925 typedef AtomicSDNode LargestSDNode;
1927 /// MostAlignedSDNode - The SDNode class with the greatest alignment
1930 typedef GlobalAddressSDNode MostAlignedSDNode;
1933 /// isNormalLoad - Returns true if the specified node is a non-extending
1934 /// and unindexed load.
1935 inline bool isNormalLoad(const SDNode *N) {
1936 const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
1937 return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
1938 Ld->getAddressingMode() == ISD::UNINDEXED;
1941 /// isNON_EXTLoad - Returns true if the specified node is a non-extending
1943 inline bool isNON_EXTLoad(const SDNode *N) {
1944 return isa<LoadSDNode>(N) &&
1945 cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
1948 /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
1950 inline bool isEXTLoad(const SDNode *N) {
1951 return isa<LoadSDNode>(N) &&
1952 cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
1955 /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
1957 inline bool isSEXTLoad(const SDNode *N) {
1958 return isa<LoadSDNode>(N) &&
1959 cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
1962 /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
1964 inline bool isZEXTLoad(const SDNode *N) {
1965 return isa<LoadSDNode>(N) &&
1966 cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
1969 /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
1971 inline bool isUNINDEXEDLoad(const SDNode *N) {
1972 return isa<LoadSDNode>(N) &&
1973 cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
1976 /// isNormalStore - Returns true if the specified node is a non-truncating
1977 /// and unindexed store.
1978 inline bool isNormalStore(const SDNode *N) {
1979 const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
1980 return St && !St->isTruncatingStore() &&
1981 St->getAddressingMode() == ISD::UNINDEXED;
1984 /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
1986 inline bool isNON_TRUNCStore(const SDNode *N) {
1987 return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
1990 /// isTRUNCStore - Returns true if the specified node is a truncating
1992 inline bool isTRUNCStore(const SDNode *N) {
1993 return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
1996 /// isUNINDEXEDStore - Returns true if the specified node is an
1997 /// unindexed store.
1998 inline bool isUNINDEXEDStore(const SDNode *N) {
1999 return isa<StoreSDNode>(N) &&
2000 cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
2004 } // end llvm namespace