Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 1 | //===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===// |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 2 | // |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 7 | // |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 9 | // |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 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/CodeGen/ValueTypes.h" |
Andrew Lenharth | 2d86ea2 | 2005-04-27 20:10:01 +0000 | [diff] [blame] | 23 | #include "llvm/Value.h" |
Chris Lattner | 1080b9e | 2005-01-10 23:05:53 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/GraphTraits.h" |
| 25 | #include "llvm/ADT/GraphTraits.h" |
| 26 | #include "llvm/ADT/iterator" |
Jeff Cohen | 39931a3 | 2005-01-07 19:21:49 +0000 | [diff] [blame] | 27 | #include "llvm/Support/DataTypes.h" |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 28 | #include <cassert> |
| 29 | #include <vector> |
| 30 | |
| 31 | namespace llvm { |
| 32 | |
| 33 | class SelectionDAG; |
| 34 | class GlobalValue; |
| 35 | class MachineBasicBlock; |
| 36 | class SDNode; |
| 37 | template <typename T> struct simplify_type; |
| 38 | |
| 39 | /// ISD namespace - This namespace contains an enum which represents all of the |
| 40 | /// SelectionDAG node types and value types. |
| 41 | /// |
| 42 | namespace ISD { |
| 43 | //===--------------------------------------------------------------------===// |
| 44 | /// ISD::NodeType enum - This enum defines all of the operators valid in a |
| 45 | /// SelectionDAG. |
| 46 | /// |
| 47 | enum NodeType { |
Chris Lattner | 8a496fc | 2005-01-13 17:58:35 +0000 | [diff] [blame] | 48 | // EntryToken - This is the marker used to indicate the start of the region. |
| 49 | EntryToken, |
| 50 | |
Reid Spencer | 8c4bde3 | 2005-08-27 19:06:05 +0000 | [diff] [blame] | 51 | // Token factor - This node takes multiple tokens as input and produces a |
Chris Lattner | 8a496fc | 2005-01-13 17:58:35 +0000 | [diff] [blame] | 52 | // single token result. This is used to represent the fact that the operand |
| 53 | // operators are independent of each other. |
| 54 | TokenFactor, |
Nate Begeman | f7f3d32 | 2005-08-30 02:39:32 +0000 | [diff] [blame^] | 55 | |
| 56 | // AssertSext, AssertZext - These nodes record if a register contains a |
| 57 | // value that has already been zero or sign extended from a narrower type. |
| 58 | // These nodes take two operands. The first is the node that has already |
| 59 | // been extended, and the second is a value type node indicating the width |
| 60 | // of the extension |
| 61 | AssertSext, AssertZext, |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 62 | |
Chris Lattner | 8a496fc | 2005-01-13 17:58:35 +0000 | [diff] [blame] | 63 | // Various leaf nodes. |
| 64 | Constant, ConstantFP, GlobalAddress, FrameIndex, ConstantPool, |
Chris Lattner | d5d0f9b | 2005-08-16 21:55:35 +0000 | [diff] [blame] | 65 | BasicBlock, ExternalSymbol, VALUETYPE, CONDCODE, Register, |
Chris Lattner | 056f9f6 | 2005-08-17 00:33:30 +0000 | [diff] [blame] | 66 | |
| 67 | // TargetConstant - Like Constant, but the DAG does not do any folding or |
| 68 | // simplification of the constant. This is used by the DAG->DAG selector. |
| 69 | TargetConstant, |
Chris Lattner | f6b1849 | 2005-08-19 22:31:34 +0000 | [diff] [blame] | 70 | |
| 71 | // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or |
| 72 | // anything else with this node, and this is valid in the target-specific |
| 73 | // dag, turning into a GlobalAddress operand. |
| 74 | TargetGlobalAddress, |
Chris Lattner | afb2dd4 | 2005-08-25 00:43:01 +0000 | [diff] [blame] | 75 | TargetFrameIndex, |
Chris Lattner | aaaaf79 | 2005-08-25 05:02:41 +0000 | [diff] [blame] | 76 | TargetConstantPool, |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 77 | |
Chris Lattner | d5d0f9b | 2005-08-16 21:55:35 +0000 | [diff] [blame] | 78 | // CopyToReg - This node has three operands: a chain, a register number to |
| 79 | // set to this value, and a value. |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 80 | CopyToReg, |
| 81 | |
| 82 | // CopyFromReg - This node indicates that the input value is a virtual or |
| 83 | // physical register that is defined outside of the scope of this |
Chris Lattner | 18c2f13 | 2005-01-13 20:50:02 +0000 | [diff] [blame] | 84 | // SelectionDAG. The register is available from the RegSDNode object. |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 85 | CopyFromReg, |
| 86 | |
Chris Lattner | 18c2f13 | 2005-01-13 20:50:02 +0000 | [diff] [blame] | 87 | // ImplicitDef - This node indicates that the specified register is |
Chris Lattner | d5d0f9b | 2005-08-16 21:55:35 +0000 | [diff] [blame] | 88 | // implicitly defined by some operation (e.g. its a live-in argument). The |
| 89 | // two operands to this are the token chain coming in and the register. |
| 90 | // The only result is the token chain going out. |
Chris Lattner | 18c2f13 | 2005-01-13 20:50:02 +0000 | [diff] [blame] | 91 | ImplicitDef, |
| 92 | |
Nate Begeman | fc1b1da | 2005-04-01 22:34:39 +0000 | [diff] [blame] | 93 | // UNDEF - An undefined node |
| 94 | UNDEF, |
| 95 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 96 | // EXTRACT_ELEMENT - This is used to get the first or second (determined by |
| 97 | // a Constant, which is required to be operand #1), element of the aggregate |
| 98 | // value specified as operand #0. This is only for use before legalization, |
| 99 | // for values that will be broken into multiple registers. |
| 100 | EXTRACT_ELEMENT, |
| 101 | |
| 102 | // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given |
| 103 | // two values of the same integer value type, this produces a value twice as |
| 104 | // big. Like EXTRACT_ELEMENT, this can only be used before legalization. |
| 105 | BUILD_PAIR, |
| 106 | |
| 107 | |
| 108 | // Simple binary arithmetic operators. |
Chris Lattner | bede0b7 | 2005-04-06 04:21:29 +0000 | [diff] [blame] | 109 | ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, |
| 110 | |
| 111 | // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing |
| 112 | // an unsigned/signed value of type i[2*n], then return the top part. |
| 113 | MULHU, MULHS, |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 114 | |
| 115 | // Bitwise operators. |
| 116 | AND, OR, XOR, SHL, SRA, SRL, |
| 117 | |
Andrew Lenharth | 691ef2b | 2005-05-03 17:19:30 +0000 | [diff] [blame] | 118 | // Counting operators |
| 119 | CTTZ, CTLZ, CTPOP, |
| 120 | |
Nate Begeman | 9373a81 | 2005-08-10 20:51:12 +0000 | [diff] [blame] | 121 | // Select |
| 122 | SELECT, |
| 123 | |
| 124 | // Select with condition operator - This selects between a true value and |
| 125 | // a false value (ops #2 and #3) based on the boolean result of comparing |
| 126 | // the lhs and rhs (ops #0 and #1) of a conditional expression with the |
| 127 | // condition code in op #4, a CondCodeSDNode. |
| 128 | SELECT_CC, |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 129 | |
| 130 | // SetCC operator - This evaluates to a boolean (i1) true value if the |
Chris Lattner | 7cf7e3f | 2005-08-09 20:20:18 +0000 | [diff] [blame] | 131 | // condition is true. The operands to this are the left and right operands |
| 132 | // to compare (ops #0, and #1) and the condition code to compare them with |
| 133 | // (op #2) as a CondCodeSDNode. |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 134 | SETCC, |
| 135 | |
Chris Lattner | 5880b9f | 2005-01-20 18:50:39 +0000 | [diff] [blame] | 136 | // ADD_PARTS/SUB_PARTS - These operators take two logical operands which are |
| 137 | // broken into a multiple pieces each, and return the resulting pieces of |
| 138 | // doing an atomic add/sub operation. This is used to handle add/sub of |
| 139 | // expanded types. The operation ordering is: |
| 140 | // [Lo,Hi] = op [LoLHS,HiLHS], [LoRHS,HiRHS] |
| 141 | ADD_PARTS, SUB_PARTS, |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 142 | |
Chris Lattner | 14c5b53 | 2005-04-02 03:30:33 +0000 | [diff] [blame] | 143 | // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded |
| 144 | // integer shift operations, just like ADD/SUB_PARTS. The operation |
| 145 | // ordering is: |
Chris Lattner | 6b8f2d6 | 2005-04-02 03:59:45 +0000 | [diff] [blame] | 146 | // [Lo,Hi] = op [LoLHS,HiLHS], Amt |
Chris Lattner | 14c5b53 | 2005-04-02 03:30:33 +0000 | [diff] [blame] | 147 | SHL_PARTS, SRA_PARTS, SRL_PARTS, |
| 148 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 149 | // Conversion operators. These are all single input single output |
| 150 | // operations. For all of these, the result type must be strictly |
| 151 | // wider or narrower (depending on the operation) than the source |
| 152 | // type. |
| 153 | |
| 154 | // SIGN_EXTEND - Used for integer types, replicating the sign bit |
| 155 | // into new bits. |
| 156 | SIGN_EXTEND, |
| 157 | |
| 158 | // ZERO_EXTEND - Used for integer types, zeroing the new bits. |
| 159 | ZERO_EXTEND, |
| 160 | |
| 161 | // TRUNCATE - Completely drop the high bits. |
| 162 | TRUNCATE, |
| 163 | |
Chris Lattner | 1645ed0 | 2005-01-08 08:08:49 +0000 | [diff] [blame] | 164 | // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign |
| 165 | // depends on the first letter) to floating point. |
| 166 | SINT_TO_FP, |
| 167 | UINT_TO_FP, |
| 168 | |
Chris Lattner | ea57610 | 2005-04-13 02:36:41 +0000 | [diff] [blame] | 169 | // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to |
| 170 | // sign extend a small value in a large integer register (e.g. sign |
| 171 | // extending the low 8 bits of a 32-bit register to fill the top 24 bits |
Chris Lattner | 15e4b01 | 2005-07-10 00:07:11 +0000 | [diff] [blame] | 172 | // with the 7th bit). The size of the smaller type is indicated by the 1th |
| 173 | // operand, a ValueType node. |
Chris Lattner | 859157d | 2005-01-15 06:17:04 +0000 | [diff] [blame] | 174 | SIGN_EXTEND_INREG, |
Chris Lattner | 859157d | 2005-01-15 06:17:04 +0000 | [diff] [blame] | 175 | |
Chris Lattner | 1645ed0 | 2005-01-08 08:08:49 +0000 | [diff] [blame] | 176 | // FP_TO_[US]INT - Convert a floating point value to a signed or unsigned |
| 177 | // integer. |
| 178 | FP_TO_SINT, |
| 179 | FP_TO_UINT, |
| 180 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 181 | // FP_ROUND - Perform a rounding operation from the current |
Chris Lattner | 859157d | 2005-01-15 06:17:04 +0000 | [diff] [blame] | 182 | // precision down to the specified precision (currently always 64->32). |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 183 | FP_ROUND, |
| 184 | |
Chris Lattner | 859157d | 2005-01-15 06:17:04 +0000 | [diff] [blame] | 185 | // FP_ROUND_INREG - This operator takes a floating point register, and |
| 186 | // rounds it to a floating point value. It then promotes it and returns it |
| 187 | // in a register of the same size. This operation effectively just discards |
Chris Lattner | 15e4b01 | 2005-07-10 00:07:11 +0000 | [diff] [blame] | 188 | // excess precision. The type to round down to is specified by the 1th |
| 189 | // operation, a VTSDNode (currently always 64->32->64). |
Chris Lattner | 859157d | 2005-01-15 06:17:04 +0000 | [diff] [blame] | 190 | FP_ROUND_INREG, |
| 191 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 192 | // FP_EXTEND - Extend a smaller FP type into a larger FP type. |
| 193 | FP_EXTEND, |
| 194 | |
Chris Lattner | 7f64464 | 2005-04-28 21:44:03 +0000 | [diff] [blame] | 195 | // FNEG, FABS, FSQRT, FSIN, FCOS - Perform unary floating point negation, |
| 196 | // absolute value, square root, sine and cosine operations. |
| 197 | FNEG, FABS, FSQRT, FSIN, FCOS, |
Chris Lattner | 7366fd3 | 2005-04-02 04:58:28 +0000 | [diff] [blame] | 198 | |
Chris Lattner | 1cff05c | 2005-01-14 22:07:46 +0000 | [diff] [blame] | 199 | // Other operators. LOAD and STORE have token chains as their first |
Chris Lattner | f7db8c6 | 2005-07-10 00:28:25 +0000 | [diff] [blame] | 200 | // operand, then the same operands as an LLVM load/store instruction, then a |
| 201 | // SRCVALUE node that provides alias analysis information. |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 202 | LOAD, STORE, |
| 203 | |
Chris Lattner | 5f056bf | 2005-07-10 01:55:33 +0000 | [diff] [blame] | 204 | // EXTLOAD, SEXTLOAD, ZEXTLOAD - These three operators all load a value from |
| 205 | // memory and extend them to a larger value (e.g. load a byte into a word |
| 206 | // register). All three of these have four operands, a token chain, a |
| 207 | // pointer to load from, a SRCVALUE for alias analysis, and a VALUETYPE node |
| 208 | // indicating the type to load. |
Chris Lattner | 1cff05c | 2005-01-14 22:07:46 +0000 | [diff] [blame] | 209 | // |
| 210 | // SEXTLOAD loads the integer operand and sign extends it to a larger |
| 211 | // integer result type. |
| 212 | // ZEXTLOAD loads the integer operand and zero extends it to a larger |
| 213 | // integer result type. |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 214 | // EXTLOAD is used for two things: floating point extending loads, and |
Chris Lattner | 1cff05c | 2005-01-14 22:07:46 +0000 | [diff] [blame] | 215 | // integer extending loads where it doesn't matter what the high |
| 216 | // bits are set to. The code generator is allowed to codegen this |
| 217 | // into whichever operation is more efficient. |
| 218 | EXTLOAD, SEXTLOAD, ZEXTLOAD, |
| 219 | |
| 220 | // TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a |
| 221 | // value and stores it to memory in one operation. This can be used for |
Chris Lattner | f7db8c6 | 2005-07-10 00:28:25 +0000 | [diff] [blame] | 222 | // either integer or floating point operands. The first four operands of |
| 223 | // this are the same as a standard store. The fifth is the ValueType to |
| 224 | // store it as (which will be smaller than the source value). |
Chris Lattner | 1cff05c | 2005-01-14 22:07:46 +0000 | [diff] [blame] | 225 | TRUNCSTORE, |
| 226 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 227 | // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned |
| 228 | // to a specified boundary. The first operand is the token chain, the |
| 229 | // second is the number of bytes to allocate, and the third is the alignment |
Chris Lattner | 74fe063 | 2005-08-29 22:48:32 +0000 | [diff] [blame] | 230 | // boundary. The size is guaranteed to be a multiple of the stack |
| 231 | // alignment, and the alignment is guaranteed to be bigger than the stack |
| 232 | // alignment (if required) or 0 to get standard stack alignment. |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 233 | DYNAMIC_STACKALLOC, |
| 234 | |
| 235 | // Control flow instructions. These all have token chains. |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 236 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 237 | // BR - Unconditional branch. The first operand is the chain |
| 238 | // operand, the second is the MBB to branch to. |
| 239 | BR, |
| 240 | |
| 241 | // BRCOND - Conditional branch. The first operand is the chain, |
| 242 | // the second is the condition, the third is the block to branch |
| 243 | // to if the condition is true. |
| 244 | BRCOND, |
| 245 | |
Chris Lattner | 1df6338 | 2005-04-09 03:21:50 +0000 | [diff] [blame] | 246 | // BRCONDTWOWAY - Two-way conditional branch. The first operand is the |
| 247 | // chain, the second is the condition, the third is the block to branch to |
| 248 | // if true, and the forth is the block to branch to if false. Targets |
| 249 | // usually do not implement this, preferring to have legalize demote the |
| 250 | // operation to BRCOND/BR pairs when necessary. |
| 251 | BRCONDTWOWAY, |
| 252 | |
Nate Begeman | 7cbd525 | 2005-08-16 19:49:35 +0000 | [diff] [blame] | 253 | // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in |
| 254 | // that the condition is represented as condition code, and two nodes to |
| 255 | // compare, rather than as a combined SetCC node. The operands in order are |
| 256 | // chain, cc, lhs, rhs, block to branch to if condition is true. |
| 257 | BR_CC, |
| 258 | |
| 259 | // BRTWOWAY_CC - Two-way conditional branch. The operands in order are |
| 260 | // chain, cc, lhs, rhs, block to branch to if condition is true, block to |
| 261 | // branch to if condition is false. Targets usually do not implement this, |
| 262 | // preferring to have legalize demote the operation to BRCOND/BR pairs. |
| 263 | BRTWOWAY_CC, |
| 264 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 265 | // RET - Return from function. The first operand is the chain, |
| 266 | // and any subsequent operands are the return values for the |
| 267 | // function. This operation can have variable number of operands. |
| 268 | RET, |
| 269 | |
| 270 | // CALL - Call to a function pointer. The first operand is the chain, the |
| 271 | // second is the destination function pointer (a GlobalAddress for a direct |
| 272 | // call). Arguments have already been lowered to explicit DAGs according to |
Chris Lattner | 4c1eae9 | 2005-05-13 18:40:17 +0000 | [diff] [blame] | 273 | // the calling convention in effect here. TAILCALL is the same as CALL, but |
| 274 | // the callee is known not to access the stack of the caller. |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 275 | CALL, |
Chris Lattner | 4c1eae9 | 2005-05-13 18:40:17 +0000 | [diff] [blame] | 276 | TAILCALL, |
Chris Lattner | ef36aa7 | 2005-01-11 05:56:17 +0000 | [diff] [blame] | 277 | |
| 278 | // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain, and the rest |
| 279 | // correspond to the operands of the LLVM intrinsic functions. The only |
| 280 | // result is a token chain. The alignment argument is guaranteed to be a |
| 281 | // Constant node. |
| 282 | MEMSET, |
| 283 | MEMMOVE, |
| 284 | MEMCPY, |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 285 | |
Chris Lattner | 16cd04d | 2005-05-12 23:24:06 +0000 | [diff] [blame] | 286 | // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of |
| 287 | // a call sequence, and carry arbitrary information that target might want |
| 288 | // to know. The first operand is a chain, the rest are specified by the |
| 289 | // target and not touched by the DAG optimizers. |
| 290 | CALLSEQ_START, // Beginning of a call sequence |
| 291 | CALLSEQ_END, // End of a call sequence |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 292 | |
Chris Lattner | 21074f4 | 2005-05-09 20:21:27 +0000 | [diff] [blame] | 293 | // SRCVALUE - This corresponds to a Value*, and is used to associate memory |
| 294 | // locations with their value. This allows one use alias analysis |
| 295 | // information in the backend. |
| 296 | SRCVALUE, |
| 297 | |
Misha Brukman | e3f570c | 2005-03-31 21:30:35 +0000 | [diff] [blame] | 298 | // PCMARKER - This corresponds to the pcmarker intrinsic. |
Andrew Lenharth | 9576212 | 2005-03-31 21:24:06 +0000 | [diff] [blame] | 299 | PCMARKER, |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 300 | |
Chris Lattner | 21074f4 | 2005-05-09 20:21:27 +0000 | [diff] [blame] | 301 | // READPORT, WRITEPORT, READIO, WRITEIO - These correspond to the LLVM |
| 302 | // intrinsics of the same name. The first operand is a token chain, the |
| 303 | // other operands match the intrinsic. These produce a token chain in |
| 304 | // addition to a value (if any). |
| 305 | READPORT, WRITEPORT, READIO, WRITEIO, |
Andrew Lenharth | 2d86ea2 | 2005-04-27 20:10:01 +0000 | [diff] [blame] | 306 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 307 | // BUILTIN_OP_END - This must be the last enum value in this list. |
| 308 | BUILTIN_OP_END, |
| 309 | }; |
| 310 | |
| 311 | //===--------------------------------------------------------------------===// |
| 312 | /// ISD::CondCode enum - These are ordered carefully to make the bitfields |
| 313 | /// below work out, when considering SETFALSE (something that never exists |
| 314 | /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered |
| 315 | /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal |
| 316 | /// to. If the "N" column is 1, the result of the comparison is undefined if |
| 317 | /// the input is a NAN. |
| 318 | /// |
| 319 | /// All of these (except for the 'always folded ops') should be handled for |
| 320 | /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT, |
| 321 | /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used. |
| 322 | /// |
| 323 | /// Note that these are laid out in a specific order to allow bit-twiddling |
| 324 | /// to transform conditions. |
| 325 | enum CondCode { |
| 326 | // Opcode N U L G E Intuitive operation |
| 327 | SETFALSE, // 0 0 0 0 Always false (always folded) |
| 328 | SETOEQ, // 0 0 0 1 True if ordered and equal |
| 329 | SETOGT, // 0 0 1 0 True if ordered and greater than |
| 330 | SETOGE, // 0 0 1 1 True if ordered and greater than or equal |
| 331 | SETOLT, // 0 1 0 0 True if ordered and less than |
| 332 | SETOLE, // 0 1 0 1 True if ordered and less than or equal |
| 333 | SETONE, // 0 1 1 0 True if ordered and operands are unequal |
| 334 | SETO, // 0 1 1 1 True if ordered (no nans) |
| 335 | SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y) |
| 336 | SETUEQ, // 1 0 0 1 True if unordered or equal |
| 337 | SETUGT, // 1 0 1 0 True if unordered or greater than |
| 338 | SETUGE, // 1 0 1 1 True if unordered, greater than, or equal |
| 339 | SETULT, // 1 1 0 0 True if unordered or less than |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 340 | SETULE, // 1 1 0 1 True if unordered, less than, or equal |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 341 | SETUNE, // 1 1 1 0 True if unordered or not equal |
| 342 | SETTRUE, // 1 1 1 1 Always true (always folded) |
| 343 | // Don't care operations: undefined if the input is a nan. |
| 344 | SETFALSE2, // 1 X 0 0 0 Always false (always folded) |
| 345 | SETEQ, // 1 X 0 0 1 True if equal |
| 346 | SETGT, // 1 X 0 1 0 True if greater than |
| 347 | SETGE, // 1 X 0 1 1 True if greater than or equal |
| 348 | SETLT, // 1 X 1 0 0 True if less than |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 349 | SETLE, // 1 X 1 0 1 True if less than or equal |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 350 | SETNE, // 1 X 1 1 0 True if not equal |
| 351 | SETTRUE2, // 1 X 1 1 1 Always true (always folded) |
| 352 | |
| 353 | SETCC_INVALID, // Marker value. |
| 354 | }; |
| 355 | |
| 356 | /// isSignedIntSetCC - Return true if this is a setcc instruction that |
| 357 | /// performs a signed comparison when used with integer operands. |
| 358 | inline bool isSignedIntSetCC(CondCode Code) { |
| 359 | return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE; |
| 360 | } |
| 361 | |
| 362 | /// isUnsignedIntSetCC - Return true if this is a setcc instruction that |
| 363 | /// performs an unsigned comparison when used with integer operands. |
| 364 | inline bool isUnsignedIntSetCC(CondCode Code) { |
| 365 | return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE; |
| 366 | } |
| 367 | |
| 368 | /// isTrueWhenEqual - Return true if the specified condition returns true if |
| 369 | /// the two operands to the condition are equal. Note that if one of the two |
| 370 | /// operands is a NaN, this value is meaningless. |
| 371 | inline bool isTrueWhenEqual(CondCode Cond) { |
| 372 | return ((int)Cond & 1) != 0; |
| 373 | } |
| 374 | |
| 375 | /// getUnorderedFlavor - This function returns 0 if the condition is always |
| 376 | /// false if an operand is a NaN, 1 if the condition is always true if the |
| 377 | /// operand is a NaN, and 2 if the condition is undefined if the operand is a |
| 378 | /// NaN. |
| 379 | inline unsigned getUnorderedFlavor(CondCode Cond) { |
| 380 | return ((int)Cond >> 3) & 3; |
| 381 | } |
| 382 | |
| 383 | /// getSetCCInverse - Return the operation corresponding to !(X op Y), where |
| 384 | /// 'op' is a valid SetCC operation. |
| 385 | CondCode getSetCCInverse(CondCode Operation, bool isInteger); |
| 386 | |
| 387 | /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) |
| 388 | /// when given the operation for (X op Y). |
| 389 | CondCode getSetCCSwappedOperands(CondCode Operation); |
| 390 | |
| 391 | /// getSetCCOrOperation - Return the result of a logical OR between different |
| 392 | /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This |
| 393 | /// function returns SETCC_INVALID if it is not possible to represent the |
| 394 | /// resultant comparison. |
| 395 | CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger); |
| 396 | |
| 397 | /// getSetCCAndOperation - Return the result of a logical AND between |
| 398 | /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This |
| 399 | /// function returns SETCC_INVALID if it is not possible to represent the |
| 400 | /// resultant comparison. |
| 401 | CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger); |
| 402 | } // end llvm::ISD namespace |
| 403 | |
| 404 | |
| 405 | //===----------------------------------------------------------------------===// |
| 406 | /// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple |
| 407 | /// values as the result of a computation. Many nodes return multiple values, |
| 408 | /// from loads (which define a token and a return value) to ADDC (which returns |
| 409 | /// a result and a carry value), to calls (which may return an arbitrary number |
| 410 | /// of values). |
| 411 | /// |
| 412 | /// As such, each use of a SelectionDAG computation must indicate the node that |
| 413 | /// computes it as well as which return value to use from that node. This pair |
| 414 | /// of information is represented with the SDOperand value type. |
| 415 | /// |
Chris Lattner | f26bc8e | 2005-01-08 19:52:31 +0000 | [diff] [blame] | 416 | class SDOperand { |
| 417 | public: |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 418 | SDNode *Val; // The node defining the value we are using. |
| 419 | unsigned ResNo; // Which return value of the node we are using. |
| 420 | |
| 421 | SDOperand() : Val(0) {} |
| 422 | SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} |
| 423 | |
| 424 | bool operator==(const SDOperand &O) const { |
| 425 | return Val == O.Val && ResNo == O.ResNo; |
| 426 | } |
| 427 | bool operator!=(const SDOperand &O) const { |
| 428 | return !operator==(O); |
| 429 | } |
| 430 | bool operator<(const SDOperand &O) const { |
| 431 | return Val < O.Val || (Val == O.Val && ResNo < O.ResNo); |
| 432 | } |
| 433 | |
| 434 | SDOperand getValue(unsigned R) const { |
| 435 | return SDOperand(Val, R); |
| 436 | } |
| 437 | |
| 438 | /// getValueType - Return the ValueType of the referenced return value. |
| 439 | /// |
| 440 | inline MVT::ValueType getValueType() const; |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 441 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 442 | // Forwarding methods - These forward to the corresponding methods in SDNode. |
| 443 | inline unsigned getOpcode() const; |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 444 | inline unsigned getNodeDepth() const; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 445 | inline unsigned getNumOperands() const; |
| 446 | inline const SDOperand &getOperand(unsigned i) const; |
Nate Begeman | 0f66a91 | 2005-08-17 23:44:54 +0000 | [diff] [blame] | 447 | inline bool isTargetOpcode() const; |
| 448 | inline unsigned getTargetOpcode() const; |
Chris Lattner | a44f4ae | 2005-01-13 22:58:50 +0000 | [diff] [blame] | 449 | |
| 450 | /// hasOneUse - Return true if there is exactly one operation using this |
| 451 | /// result value of the defining operator. |
| 452 | inline bool hasOneUse() const; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 453 | }; |
| 454 | |
| 455 | |
| 456 | /// simplify_type specializations - Allow casting operators to work directly on |
| 457 | /// SDOperands as if they were SDNode*'s. |
| 458 | template<> struct simplify_type<SDOperand> { |
| 459 | typedef SDNode* SimpleType; |
| 460 | static SimpleType getSimplifiedValue(const SDOperand &Val) { |
| 461 | return static_cast<SimpleType>(Val.Val); |
| 462 | } |
| 463 | }; |
| 464 | template<> struct simplify_type<const SDOperand> { |
| 465 | typedef SDNode* SimpleType; |
| 466 | static SimpleType getSimplifiedValue(const SDOperand &Val) { |
| 467 | return static_cast<SimpleType>(Val.Val); |
| 468 | } |
| 469 | }; |
| 470 | |
| 471 | |
| 472 | /// SDNode - Represents one node in the SelectionDAG. |
| 473 | /// |
| 474 | class SDNode { |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 475 | /// NodeType - The operation that this node performs. |
| 476 | /// |
| 477 | unsigned short NodeType; |
| 478 | |
| 479 | /// NodeDepth - Node depth is defined as MAX(Node depth of children)+1. This |
| 480 | /// means that leaves have a depth of 1, things that use only leaves have a |
| 481 | /// depth of 2, etc. |
| 482 | unsigned short NodeDepth; |
| 483 | |
| 484 | /// Operands - The values that are used by this operation. |
| 485 | /// |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 486 | std::vector<SDOperand> Operands; |
| 487 | |
| 488 | /// Values - The types of the values this node defines. SDNode's may define |
| 489 | /// multiple values simultaneously. |
| 490 | std::vector<MVT::ValueType> Values; |
| 491 | |
| 492 | /// Uses - These are all of the SDNode's that use a value produced by this |
| 493 | /// node. |
| 494 | std::vector<SDNode*> Uses; |
| 495 | public: |
| 496 | |
| 497 | //===--------------------------------------------------------------------===// |
| 498 | // Accessors |
| 499 | // |
| 500 | unsigned getOpcode() const { return NodeType; } |
Nate Begeman | 0f66a91 | 2005-08-17 23:44:54 +0000 | [diff] [blame] | 501 | bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } |
| 502 | unsigned getTargetOpcode() const { |
| 503 | assert(isTargetOpcode() && "Not a target opcode!"); |
| 504 | return NodeType - ISD::BUILTIN_OP_END; |
| 505 | } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 506 | |
| 507 | size_t use_size() const { return Uses.size(); } |
| 508 | bool use_empty() const { return Uses.empty(); } |
| 509 | bool hasOneUse() const { return Uses.size() == 1; } |
| 510 | |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 511 | /// getNodeDepth - Return the distance from this node to the leaves in the |
| 512 | /// graph. The leaves have a depth of 1. |
| 513 | unsigned getNodeDepth() const { return NodeDepth; } |
| 514 | |
Chris Lattner | 7ece380 | 2005-01-17 02:24:59 +0000 | [diff] [blame] | 515 | typedef std::vector<SDNode*>::const_iterator use_iterator; |
| 516 | use_iterator use_begin() const { return Uses.begin(); } |
| 517 | use_iterator use_end() const { return Uses.end(); } |
| 518 | |
Chris Lattner | b18a2f8 | 2005-01-12 18:37:33 +0000 | [diff] [blame] | 519 | /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the |
| 520 | /// indicated value. This method ignores uses of other values defined by this |
| 521 | /// operation. |
| 522 | bool hasNUsesOfValue(unsigned NUses, unsigned Value); |
| 523 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 524 | /// getNumOperands - Return the number of values used by this operation. |
| 525 | /// |
| 526 | unsigned getNumOperands() const { return Operands.size(); } |
| 527 | |
| 528 | const SDOperand &getOperand(unsigned Num) { |
| 529 | assert(Num < Operands.size() && "Invalid child # of SDNode!"); |
| 530 | return Operands[Num]; |
| 531 | } |
| 532 | |
| 533 | const SDOperand &getOperand(unsigned Num) const { |
| 534 | assert(Num < Operands.size() && "Invalid child # of SDNode!"); |
| 535 | return Operands[Num]; |
| 536 | } |
Chris Lattner | 50f5a51 | 2005-05-14 06:19:11 +0000 | [diff] [blame] | 537 | typedef std::vector<SDOperand>::const_iterator op_iterator; |
| 538 | op_iterator op_begin() const { return Operands.begin(); } |
| 539 | op_iterator op_end() const { return Operands.end(); } |
| 540 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 541 | |
| 542 | /// getNumValues - Return the number of values defined/returned by this |
| 543 | /// operator. |
| 544 | /// |
| 545 | unsigned getNumValues() const { return Values.size(); } |
| 546 | |
| 547 | /// getValueType - Return the type of a specified result. |
| 548 | /// |
| 549 | MVT::ValueType getValueType(unsigned ResNo) const { |
| 550 | assert(ResNo < Values.size() && "Illegal result number!"); |
| 551 | return Values[ResNo]; |
| 552 | } |
Jeff Cohen | 9eb59ec | 2005-07-27 05:53:44 +0000 | [diff] [blame] | 553 | |
Chris Lattner | 50f5a51 | 2005-05-14 06:19:11 +0000 | [diff] [blame] | 554 | typedef std::vector<MVT::ValueType>::const_iterator value_iterator; |
| 555 | value_iterator value_begin() const { return Values.begin(); } |
| 556 | value_iterator value_end() const { return Values.end(); } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 557 | |
Chris Lattner | 6e6e3ce | 2005-01-10 23:25:04 +0000 | [diff] [blame] | 558 | /// getOperationName - Return the opcode of this operation for printing. |
| 559 | /// |
Chris Lattner | efe5869 | 2005-08-16 18:32:18 +0000 | [diff] [blame] | 560 | const char* getOperationName(const SelectionDAG *G = 0) const; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 561 | void dump() const; |
Chris Lattner | efe5869 | 2005-08-16 18:32:18 +0000 | [diff] [blame] | 562 | void dump(const SelectionDAG *G) const; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 563 | |
| 564 | static bool classof(const SDNode *) { return true; } |
| 565 | |
Chris Lattner | 73b3537 | 2005-05-11 18:56:45 +0000 | [diff] [blame] | 566 | |
| 567 | /// setAdjCallChain - This method should only be used by the legalizer. |
| 568 | void setAdjCallChain(SDOperand N); |
Jeff Cohen | 9eb59ec | 2005-07-27 05:53:44 +0000 | [diff] [blame] | 569 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 570 | protected: |
| 571 | friend class SelectionDAG; |
| 572 | |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 573 | SDNode(unsigned NT, MVT::ValueType VT) : NodeType(NT), NodeDepth(1) { |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 574 | Values.reserve(1); |
| 575 | Values.push_back(VT); |
| 576 | } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 577 | SDNode(unsigned NT, SDOperand Op) |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 578 | : NodeType(NT), NodeDepth(Op.Val->getNodeDepth()+1) { |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 579 | Operands.reserve(1); Operands.push_back(Op); |
| 580 | Op.Val->Uses.push_back(this); |
| 581 | } |
| 582 | SDNode(unsigned NT, SDOperand N1, SDOperand N2) |
| 583 | : NodeType(NT) { |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 584 | if (N1.Val->getNodeDepth() > N2.Val->getNodeDepth()) |
| 585 | NodeDepth = N1.Val->getNodeDepth()+1; |
| 586 | else |
| 587 | NodeDepth = N2.Val->getNodeDepth()+1; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 588 | Operands.reserve(2); Operands.push_back(N1); Operands.push_back(N2); |
| 589 | N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this); |
| 590 | } |
| 591 | SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3) |
| 592 | : NodeType(NT) { |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 593 | unsigned ND = N1.Val->getNodeDepth(); |
| 594 | if (ND < N2.Val->getNodeDepth()) |
| 595 | ND = N2.Val->getNodeDepth(); |
| 596 | if (ND < N3.Val->getNodeDepth()) |
| 597 | ND = N3.Val->getNodeDepth(); |
| 598 | NodeDepth = ND+1; |
| 599 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 600 | Operands.reserve(3); Operands.push_back(N1); Operands.push_back(N2); |
| 601 | Operands.push_back(N3); |
| 602 | N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this); |
| 603 | N3.Val->Uses.push_back(this); |
| 604 | } |
Andrew Lenharth | 2d86ea2 | 2005-04-27 20:10:01 +0000 | [diff] [blame] | 605 | SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4) |
| 606 | : NodeType(NT) { |
| 607 | unsigned ND = N1.Val->getNodeDepth(); |
| 608 | if (ND < N2.Val->getNodeDepth()) |
| 609 | ND = N2.Val->getNodeDepth(); |
| 610 | if (ND < N3.Val->getNodeDepth()) |
| 611 | ND = N3.Val->getNodeDepth(); |
| 612 | if (ND < N4.Val->getNodeDepth()) |
| 613 | ND = N4.Val->getNodeDepth(); |
| 614 | NodeDepth = ND+1; |
| 615 | |
Andrew Lenharth | 691ef2b | 2005-05-03 17:19:30 +0000 | [diff] [blame] | 616 | Operands.reserve(4); Operands.push_back(N1); Operands.push_back(N2); |
Andrew Lenharth | 2d86ea2 | 2005-04-27 20:10:01 +0000 | [diff] [blame] | 617 | Operands.push_back(N3); Operands.push_back(N4); |
| 618 | N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this); |
| 619 | N3.Val->Uses.push_back(this); N4.Val->Uses.push_back(this); |
| 620 | } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 621 | SDNode(unsigned NT, std::vector<SDOperand> &Nodes) : NodeType(NT) { |
| 622 | Operands.swap(Nodes); |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 623 | unsigned ND = 0; |
| 624 | for (unsigned i = 0, e = Operands.size(); i != e; ++i) { |
Chris Lattner | ef36aa7 | 2005-01-11 05:56:17 +0000 | [diff] [blame] | 625 | Operands[i].Val->Uses.push_back(this); |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 626 | if (ND < Operands[i].Val->getNodeDepth()) |
| 627 | ND = Operands[i].Val->getNodeDepth(); |
| 628 | } |
| 629 | NodeDepth = ND+1; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 630 | } |
| 631 | |
Chris Lattner | 1b95095 | 2005-08-16 18:16:24 +0000 | [diff] [blame] | 632 | virtual ~SDNode() {} |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 633 | |
Chris Lattner | 1b95095 | 2005-08-16 18:16:24 +0000 | [diff] [blame] | 634 | /// MorphNodeTo - This clears the return value and operands list, and sets the |
| 635 | /// opcode of the node to the specified value. This should only be used by |
| 636 | /// the SelectionDAG class. |
| 637 | void MorphNodeTo(unsigned Opc) { |
| 638 | NodeType = Opc; |
| 639 | Values.clear(); |
Chris Lattner | b467f8a | 2005-08-17 01:54:00 +0000 | [diff] [blame] | 640 | |
| 641 | // Clear the operands list, updating used nodes to remove this from their |
| 642 | // use list. |
| 643 | while (!Operands.empty()) { |
| 644 | SDNode *O = Operands.back().Val; |
| 645 | Operands.pop_back(); |
| 646 | O->removeUser(this); |
| 647 | } |
Chris Lattner | 1b95095 | 2005-08-16 18:16:24 +0000 | [diff] [blame] | 648 | } |
| 649 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 650 | void setValueTypes(MVT::ValueType VT) { |
| 651 | Values.reserve(1); |
| 652 | Values.push_back(VT); |
| 653 | } |
| 654 | void setValueTypes(MVT::ValueType VT1, MVT::ValueType VT2) { |
| 655 | Values.reserve(2); |
| 656 | Values.push_back(VT1); |
| 657 | Values.push_back(VT2); |
| 658 | } |
| 659 | /// Note: this method destroys the vector passed in. |
| 660 | void setValueTypes(std::vector<MVT::ValueType> &VTs) { |
| 661 | std::swap(Values, VTs); |
| 662 | } |
Chris Lattner | 1b95095 | 2005-08-16 18:16:24 +0000 | [diff] [blame] | 663 | |
| 664 | void setOperands(SDOperand Op0) { |
| 665 | Operands.reserve(1); |
| 666 | Operands.push_back(Op0); |
Chris Lattner | 8c3484c | 2005-08-17 18:58:38 +0000 | [diff] [blame] | 667 | Op0.Val->Uses.push_back(this); |
Chris Lattner | 1b95095 | 2005-08-16 18:16:24 +0000 | [diff] [blame] | 668 | } |
| 669 | void setOperands(SDOperand Op0, SDOperand Op1) { |
| 670 | Operands.reserve(2); |
| 671 | Operands.push_back(Op0); |
| 672 | Operands.push_back(Op1); |
Chris Lattner | 8c3484c | 2005-08-17 18:58:38 +0000 | [diff] [blame] | 673 | Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this); |
Chris Lattner | 1b95095 | 2005-08-16 18:16:24 +0000 | [diff] [blame] | 674 | } |
| 675 | void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2) { |
| 676 | Operands.reserve(3); |
| 677 | Operands.push_back(Op0); |
| 678 | Operands.push_back(Op1); |
| 679 | Operands.push_back(Op2); |
Chris Lattner | 8c3484c | 2005-08-17 18:58:38 +0000 | [diff] [blame] | 680 | Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this); |
| 681 | Op2.Val->Uses.push_back(this); |
| 682 | } |
Nate Begeman | 294a0a1 | 2005-08-18 07:30:15 +0000 | [diff] [blame] | 683 | void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3) { |
| 684 | Operands.reserve(4); |
| 685 | Operands.push_back(Op0); |
| 686 | Operands.push_back(Op1); |
| 687 | Operands.push_back(Op2); |
| 688 | Operands.push_back(Op3); |
| 689 | Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this); |
| 690 | Op2.Val->Uses.push_back(this); Op3.Val->Uses.push_back(this); |
| 691 | } |
Chris Lattner | d54209f | 2005-08-21 18:49:58 +0000 | [diff] [blame] | 692 | void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2, SDOperand Op3, |
| 693 | SDOperand Op4) { |
| 694 | Operands.reserve(5); |
| 695 | Operands.push_back(Op0); |
| 696 | Operands.push_back(Op1); |
| 697 | Operands.push_back(Op2); |
| 698 | Operands.push_back(Op3); |
| 699 | Operands.push_back(Op4); |
| 700 | Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this); |
| 701 | Op2.Val->Uses.push_back(this); Op3.Val->Uses.push_back(this); |
| 702 | Op4.Val->Uses.push_back(this); |
| 703 | } |
Chris Lattner | 8c3484c | 2005-08-17 18:58:38 +0000 | [diff] [blame] | 704 | void addUser(SDNode *User) { |
| 705 | Uses.push_back(User); |
Chris Lattner | 1b95095 | 2005-08-16 18:16:24 +0000 | [diff] [blame] | 706 | } |
Chris Lattner | d1fc964 | 2005-01-07 21:08:55 +0000 | [diff] [blame] | 707 | void removeUser(SDNode *User) { |
| 708 | // Remove this user from the operand's use list. |
| 709 | for (unsigned i = Uses.size(); ; --i) { |
| 710 | assert(i != 0 && "Didn't find user!"); |
| 711 | if (Uses[i-1] == User) { |
Chris Lattner | 8c3484c | 2005-08-17 18:58:38 +0000 | [diff] [blame] | 712 | Uses[i-1] = Uses.back(); |
| 713 | Uses.pop_back(); |
| 714 | return; |
Chris Lattner | d1fc964 | 2005-01-07 21:08:55 +0000 | [diff] [blame] | 715 | } |
| 716 | } |
| 717 | } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 718 | }; |
| 719 | |
| 720 | |
| 721 | // Define inline functions from the SDOperand class. |
| 722 | |
| 723 | inline unsigned SDOperand::getOpcode() const { |
| 724 | return Val->getOpcode(); |
| 725 | } |
Chris Lattner | 0442fbf | 2005-01-21 21:39:38 +0000 | [diff] [blame] | 726 | inline unsigned SDOperand::getNodeDepth() const { |
| 727 | return Val->getNodeDepth(); |
| 728 | } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 729 | inline MVT::ValueType SDOperand::getValueType() const { |
| 730 | return Val->getValueType(ResNo); |
| 731 | } |
| 732 | inline unsigned SDOperand::getNumOperands() const { |
| 733 | return Val->getNumOperands(); |
| 734 | } |
| 735 | inline const SDOperand &SDOperand::getOperand(unsigned i) const { |
| 736 | return Val->getOperand(i); |
| 737 | } |
Nate Begeman | 0f66a91 | 2005-08-17 23:44:54 +0000 | [diff] [blame] | 738 | inline bool SDOperand::isTargetOpcode() const { |
| 739 | return Val->isTargetOpcode(); |
| 740 | } |
| 741 | inline unsigned SDOperand::getTargetOpcode() const { |
| 742 | return Val->getTargetOpcode(); |
| 743 | } |
Chris Lattner | a44f4ae | 2005-01-13 22:58:50 +0000 | [diff] [blame] | 744 | inline bool SDOperand::hasOneUse() const { |
| 745 | return Val->hasNUsesOfValue(1, ResNo); |
| 746 | } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 747 | |
| 748 | |
| 749 | class ConstantSDNode : public SDNode { |
| 750 | uint64_t Value; |
| 751 | protected: |
| 752 | friend class SelectionDAG; |
Chris Lattner | 056f9f6 | 2005-08-17 00:33:30 +0000 | [diff] [blame] | 753 | ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT) |
| 754 | : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, VT), Value(val) { |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 755 | } |
| 756 | public: |
| 757 | |
| 758 | uint64_t getValue() const { return Value; } |
| 759 | |
| 760 | int64_t getSignExtended() const { |
| 761 | unsigned Bits = MVT::getSizeInBits(getValueType(0)); |
Chris Lattner | f26bc8e | 2005-01-08 19:52:31 +0000 | [diff] [blame] | 762 | return ((int64_t)Value << (64-Bits)) >> (64-Bits); |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 763 | } |
| 764 | |
| 765 | bool isNullValue() const { return Value == 0; } |
| 766 | bool isAllOnesValue() const { |
Chris Lattner | 2bffad3 | 2005-04-08 21:31:29 +0000 | [diff] [blame] | 767 | int NumBits = MVT::getSizeInBits(getValueType(0)); |
| 768 | if (NumBits == 64) return Value+1 == 0; |
| 769 | return Value == (1ULL << NumBits)-1; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 770 | } |
| 771 | |
| 772 | static bool classof(const ConstantSDNode *) { return true; } |
| 773 | static bool classof(const SDNode *N) { |
Chris Lattner | 056f9f6 | 2005-08-17 00:33:30 +0000 | [diff] [blame] | 774 | return N->getOpcode() == ISD::Constant || |
| 775 | N->getOpcode() == ISD::TargetConstant; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 776 | } |
| 777 | }; |
| 778 | |
| 779 | class ConstantFPSDNode : public SDNode { |
| 780 | double Value; |
| 781 | protected: |
| 782 | friend class SelectionDAG; |
| 783 | ConstantFPSDNode(double val, MVT::ValueType VT) |
| 784 | : SDNode(ISD::ConstantFP, VT), Value(val) { |
| 785 | } |
| 786 | public: |
| 787 | |
| 788 | double getValue() const { return Value; } |
| 789 | |
| 790 | /// isExactlyValue - We don't rely on operator== working on double values, as |
| 791 | /// it returns true for things that are clearly not equal, like -0.0 and 0.0. |
| 792 | /// As such, this method can be used to do an exact bit-for-bit comparison of |
| 793 | /// two floating point values. |
Jim Laskey | 58b968b | 2005-08-17 20:08:02 +0000 | [diff] [blame] | 794 | bool isExactlyValue(double V) const; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 795 | |
| 796 | static bool classof(const ConstantFPSDNode *) { return true; } |
| 797 | static bool classof(const SDNode *N) { |
| 798 | return N->getOpcode() == ISD::ConstantFP; |
| 799 | } |
| 800 | }; |
| 801 | |
| 802 | class GlobalAddressSDNode : public SDNode { |
| 803 | GlobalValue *TheGlobal; |
| 804 | protected: |
| 805 | friend class SelectionDAG; |
Chris Lattner | f6b1849 | 2005-08-19 22:31:34 +0000 | [diff] [blame] | 806 | GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT) |
| 807 | : SDNode(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress, VT) { |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 808 | TheGlobal = const_cast<GlobalValue*>(GA); |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 809 | } |
| 810 | public: |
| 811 | |
| 812 | GlobalValue *getGlobal() const { return TheGlobal; } |
| 813 | |
| 814 | static bool classof(const GlobalAddressSDNode *) { return true; } |
| 815 | static bool classof(const SDNode *N) { |
Chris Lattner | f6b1849 | 2005-08-19 22:31:34 +0000 | [diff] [blame] | 816 | return N->getOpcode() == ISD::GlobalAddress || |
| 817 | N->getOpcode() == ISD::TargetGlobalAddress; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 818 | } |
| 819 | }; |
| 820 | |
| 821 | |
| 822 | class FrameIndexSDNode : public SDNode { |
| 823 | int FI; |
| 824 | protected: |
| 825 | friend class SelectionDAG; |
Chris Lattner | afb2dd4 | 2005-08-25 00:43:01 +0000 | [diff] [blame] | 826 | FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg) |
| 827 | : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, VT), FI(fi) {} |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 828 | public: |
| 829 | |
| 830 | int getIndex() const { return FI; } |
| 831 | |
| 832 | static bool classof(const FrameIndexSDNode *) { return true; } |
| 833 | static bool classof(const SDNode *N) { |
Chris Lattner | afb2dd4 | 2005-08-25 00:43:01 +0000 | [diff] [blame] | 834 | return N->getOpcode() == ISD::FrameIndex || |
| 835 | N->getOpcode() == ISD::TargetFrameIndex; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 836 | } |
| 837 | }; |
| 838 | |
| 839 | class ConstantPoolSDNode : public SDNode { |
Chris Lattner | 5839bf2 | 2005-08-26 17:15:30 +0000 | [diff] [blame] | 840 | Constant *C; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 841 | protected: |
| 842 | friend class SelectionDAG; |
Chris Lattner | 5839bf2 | 2005-08-26 17:15:30 +0000 | [diff] [blame] | 843 | ConstantPoolSDNode(Constant *c, MVT::ValueType VT, bool isTarget) |
Chris Lattner | aaaaf79 | 2005-08-25 05:02:41 +0000 | [diff] [blame] | 844 | : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT), |
Chris Lattner | 5839bf2 | 2005-08-26 17:15:30 +0000 | [diff] [blame] | 845 | C(c) {} |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 846 | public: |
| 847 | |
Chris Lattner | 5839bf2 | 2005-08-26 17:15:30 +0000 | [diff] [blame] | 848 | Constant *get() const { return C; } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 849 | |
| 850 | static bool classof(const ConstantPoolSDNode *) { return true; } |
| 851 | static bool classof(const SDNode *N) { |
Chris Lattner | aaaaf79 | 2005-08-25 05:02:41 +0000 | [diff] [blame] | 852 | return N->getOpcode() == ISD::ConstantPool || |
| 853 | N->getOpcode() == ISD::TargetConstantPool; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 854 | } |
| 855 | }; |
| 856 | |
| 857 | class BasicBlockSDNode : public SDNode { |
| 858 | MachineBasicBlock *MBB; |
| 859 | protected: |
| 860 | friend class SelectionDAG; |
| 861 | BasicBlockSDNode(MachineBasicBlock *mbb) |
| 862 | : SDNode(ISD::BasicBlock, MVT::Other), MBB(mbb) {} |
| 863 | public: |
| 864 | |
| 865 | MachineBasicBlock *getBasicBlock() const { return MBB; } |
| 866 | |
| 867 | static bool classof(const BasicBlockSDNode *) { return true; } |
| 868 | static bool classof(const SDNode *N) { |
| 869 | return N->getOpcode() == ISD::BasicBlock; |
| 870 | } |
| 871 | }; |
| 872 | |
Andrew Lenharth | 2d86ea2 | 2005-04-27 20:10:01 +0000 | [diff] [blame] | 873 | class SrcValueSDNode : public SDNode { |
| 874 | const Value *V; |
Andrew Lenharth | 691ef2b | 2005-05-03 17:19:30 +0000 | [diff] [blame] | 875 | int offset; |
Andrew Lenharth | 2d86ea2 | 2005-04-27 20:10:01 +0000 | [diff] [blame] | 876 | protected: |
| 877 | friend class SelectionDAG; |
Andrew Lenharth | 691ef2b | 2005-05-03 17:19:30 +0000 | [diff] [blame] | 878 | SrcValueSDNode(const Value* v, int o) |
| 879 | : SDNode(ISD::SRCVALUE, MVT::Other), V(v), offset(o) {} |
Andrew Lenharth | 2d86ea2 | 2005-04-27 20:10:01 +0000 | [diff] [blame] | 880 | |
| 881 | public: |
| 882 | const Value *getValue() const { return V; } |
Andrew Lenharth | 691ef2b | 2005-05-03 17:19:30 +0000 | [diff] [blame] | 883 | int getOffset() const { return offset; } |
Andrew Lenharth | 2d86ea2 | 2005-04-27 20:10:01 +0000 | [diff] [blame] | 884 | |
| 885 | static bool classof(const SrcValueSDNode *) { return true; } |
| 886 | static bool classof(const SDNode *N) { |
| 887 | return N->getOpcode() == ISD::SRCVALUE; |
| 888 | } |
| 889 | }; |
| 890 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 891 | |
Chris Lattner | d5d0f9b | 2005-08-16 21:55:35 +0000 | [diff] [blame] | 892 | class RegisterSDNode : public SDNode { |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 893 | unsigned Reg; |
| 894 | protected: |
| 895 | friend class SelectionDAG; |
Chris Lattner | d5d0f9b | 2005-08-16 21:55:35 +0000 | [diff] [blame] | 896 | RegisterSDNode(unsigned reg, MVT::ValueType VT) |
| 897 | : SDNode(ISD::Register, VT), Reg(reg) {} |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 898 | public: |
| 899 | |
| 900 | unsigned getReg() const { return Reg; } |
| 901 | |
Chris Lattner | d5d0f9b | 2005-08-16 21:55:35 +0000 | [diff] [blame] | 902 | static bool classof(const RegisterSDNode *) { return true; } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 903 | static bool classof(const SDNode *N) { |
Chris Lattner | d5d0f9b | 2005-08-16 21:55:35 +0000 | [diff] [blame] | 904 | return N->getOpcode() == ISD::Register; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 905 | } |
| 906 | }; |
| 907 | |
| 908 | class ExternalSymbolSDNode : public SDNode { |
| 909 | const char *Symbol; |
| 910 | protected: |
| 911 | friend class SelectionDAG; |
| 912 | ExternalSymbolSDNode(const char *Sym, MVT::ValueType VT) |
| 913 | : SDNode(ISD::ExternalSymbol, VT), Symbol(Sym) { |
| 914 | } |
| 915 | public: |
| 916 | |
| 917 | const char *getSymbol() const { return Symbol; } |
| 918 | |
| 919 | static bool classof(const ExternalSymbolSDNode *) { return true; } |
| 920 | static bool classof(const SDNode *N) { |
| 921 | return N->getOpcode() == ISD::ExternalSymbol; |
| 922 | } |
| 923 | }; |
| 924 | |
Chris Lattner | 7cf7e3f | 2005-08-09 20:20:18 +0000 | [diff] [blame] | 925 | class CondCodeSDNode : public SDNode { |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 926 | ISD::CondCode Condition; |
| 927 | protected: |
| 928 | friend class SelectionDAG; |
Chris Lattner | 7cf7e3f | 2005-08-09 20:20:18 +0000 | [diff] [blame] | 929 | CondCodeSDNode(ISD::CondCode Cond) |
| 930 | : SDNode(ISD::CONDCODE, MVT::Other), Condition(Cond) { |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 931 | } |
| 932 | public: |
| 933 | |
Chris Lattner | 7cf7e3f | 2005-08-09 20:20:18 +0000 | [diff] [blame] | 934 | ISD::CondCode get() const { return Condition; } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 935 | |
Chris Lattner | 7cf7e3f | 2005-08-09 20:20:18 +0000 | [diff] [blame] | 936 | static bool classof(const CondCodeSDNode *) { return true; } |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 937 | static bool classof(const SDNode *N) { |
Chris Lattner | 7cf7e3f | 2005-08-09 20:20:18 +0000 | [diff] [blame] | 938 | return N->getOpcode() == ISD::CONDCODE; |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 939 | } |
| 940 | }; |
| 941 | |
Chris Lattner | 15e4b01 | 2005-07-10 00:07:11 +0000 | [diff] [blame] | 942 | /// VTSDNode - This class is used to represent MVT::ValueType's, which are used |
| 943 | /// to parameterize some operations. |
| 944 | class VTSDNode : public SDNode { |
| 945 | MVT::ValueType ValueType; |
| 946 | protected: |
| 947 | friend class SelectionDAG; |
| 948 | VTSDNode(MVT::ValueType VT) |
| 949 | : SDNode(ISD::VALUETYPE, MVT::Other), ValueType(VT) {} |
| 950 | public: |
| 951 | |
| 952 | MVT::ValueType getVT() const { return ValueType; } |
| 953 | |
| 954 | static bool classof(const VTSDNode *) { return true; } |
| 955 | static bool classof(const SDNode *N) { |
| 956 | return N->getOpcode() == ISD::VALUETYPE; |
| 957 | } |
| 958 | }; |
| 959 | |
| 960 | |
Chris Lattner | 1080b9e | 2005-01-10 23:05:53 +0000 | [diff] [blame] | 961 | class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { |
| 962 | SDNode *Node; |
| 963 | unsigned Operand; |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 964 | |
Chris Lattner | 1080b9e | 2005-01-10 23:05:53 +0000 | [diff] [blame] | 965 | SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} |
| 966 | public: |
| 967 | bool operator==(const SDNodeIterator& x) const { |
| 968 | return Operand == x.Operand; |
| 969 | } |
| 970 | bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } |
| 971 | |
| 972 | const SDNodeIterator &operator=(const SDNodeIterator &I) { |
| 973 | assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); |
| 974 | Operand = I.Operand; |
| 975 | return *this; |
| 976 | } |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 977 | |
Chris Lattner | 1080b9e | 2005-01-10 23:05:53 +0000 | [diff] [blame] | 978 | pointer operator*() const { |
| 979 | return Node->getOperand(Operand).Val; |
| 980 | } |
| 981 | pointer operator->() const { return operator*(); } |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 982 | |
Chris Lattner | 1080b9e | 2005-01-10 23:05:53 +0000 | [diff] [blame] | 983 | SDNodeIterator& operator++() { // Preincrement |
| 984 | ++Operand; |
| 985 | return *this; |
| 986 | } |
| 987 | SDNodeIterator operator++(int) { // Postincrement |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 988 | SDNodeIterator tmp = *this; ++*this; return tmp; |
Chris Lattner | 1080b9e | 2005-01-10 23:05:53 +0000 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } |
| 992 | static SDNodeIterator end (SDNode *N) { |
| 993 | return SDNodeIterator(N, N->getNumOperands()); |
| 994 | } |
| 995 | |
| 996 | unsigned getOperand() const { return Operand; } |
| 997 | const SDNode *getNode() const { return Node; } |
| 998 | }; |
| 999 | |
| 1000 | template <> struct GraphTraits<SDNode*> { |
| 1001 | typedef SDNode NodeType; |
| 1002 | typedef SDNodeIterator ChildIteratorType; |
| 1003 | static inline NodeType *getEntryNode(SDNode *N) { return N; } |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 1004 | static inline ChildIteratorType child_begin(NodeType *N) { |
Chris Lattner | 1080b9e | 2005-01-10 23:05:53 +0000 | [diff] [blame] | 1005 | return SDNodeIterator::begin(N); |
| 1006 | } |
Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 1007 | static inline ChildIteratorType child_end(NodeType *N) { |
Chris Lattner | 1080b9e | 2005-01-10 23:05:53 +0000 | [diff] [blame] | 1008 | return SDNodeIterator::end(N); |
| 1009 | } |
| 1010 | }; |
| 1011 | |
Chris Lattner | 63b570d | 2005-01-07 07:45:27 +0000 | [diff] [blame] | 1012 | } // end llvm namespace |
| 1013 | |
| 1014 | #endif |