blob: 18afa69917ea31949bf6a5d1a9915e1770187336 [file] [log] [blame]
Chris Lattner63b570d2005-01-07 07:45:27 +00001//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
Misha Brukmanea61c352005-04-21 20:39:54 +00002//
Chris Lattner63b570d2005-01-07 07:45:27 +00003// 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 Brukmanea61c352005-04-21 20:39:54 +00007//
Chris Lattner63b570d2005-01-07 07:45:27 +00008//===----------------------------------------------------------------------===//
Misha Brukmanea61c352005-04-21 20:39:54 +00009//
Chris Lattner63b570d2005-01-07 07:45:27 +000010// 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
Andrew Lenharth2d86ea22005-04-27 20:10:01 +000022#include "llvm/Value.h"
Chris Lattner1080b9e2005-01-10 23:05:53 +000023#include "llvm/ADT/GraphTraits.h"
Chris Lattner1080b9e2005-01-10 23:05:53 +000024#include "llvm/ADT/iterator"
Chris Lattner5892d472006-08-16 21:01:10 +000025#include "llvm/ADT/SmallVector.h"
Evan Chengd6594ae2006-09-12 21:00:35 +000026#include "llvm/CodeGen/ValueTypes.h"
Jeff Cohen39931a32005-01-07 19:21:49 +000027#include "llvm/Support/DataTypes.h"
Chris Lattner63b570d2005-01-07 07:45:27 +000028#include <cassert>
Chris Lattner63b570d2005-01-07 07:45:27 +000029
30namespace llvm {
31
32class SelectionDAG;
33class GlobalValue;
34class MachineBasicBlock;
Evan Chengd6594ae2006-09-12 21:00:35 +000035class MachineConstantPoolValue;
Chris Lattner63b570d2005-01-07 07:45:27 +000036class SDNode;
37template <typename T> struct simplify_type;
Chris Lattnerb80e2be2005-11-09 23:46:43 +000038template <typename T> struct ilist_traits;
39template<typename NodeTy, typename Traits> class iplist;
40template<typename NodeTy> class ilist_iterator;
Chris Lattner63b570d2005-01-07 07:45:27 +000041
Chris Lattner0b3e5252006-08-15 19:11:05 +000042/// SDVTList - This represents a list of ValueType's that has been intern'd by
43/// a SelectionDAG. Instances of this simple value class are returned by
44/// SelectionDAG::getVTList(...).
45///
46struct SDVTList {
47 const MVT::ValueType *VTs;
48 unsigned short NumVTs;
49};
50
51
Chris Lattner63b570d2005-01-07 07:45:27 +000052/// ISD namespace - This namespace contains an enum which represents all of the
53/// SelectionDAG node types and value types.
54///
55namespace ISD {
56 //===--------------------------------------------------------------------===//
57 /// ISD::NodeType enum - This enum defines all of the operators valid in a
58 /// SelectionDAG.
59 ///
60 enum NodeType {
Chris Lattner3258ed62006-05-27 00:40:15 +000061 // DELETED_NODE - This is an illegal flag value that is used to catch
62 // errors. This opcode is not a legal opcode for any node.
63 DELETED_NODE,
64
Chris Lattner8a496fc2005-01-13 17:58:35 +000065 // EntryToken - This is the marker used to indicate the start of the region.
66 EntryToken,
67
Reid Spencer8c4bde32005-08-27 19:06:05 +000068 // Token factor - This node takes multiple tokens as input and produces a
Chris Lattner8a496fc2005-01-13 17:58:35 +000069 // single token result. This is used to represent the fact that the operand
70 // operators are independent of each other.
71 TokenFactor,
Nate Begemanf7f3d322005-08-30 02:39:32 +000072
73 // AssertSext, AssertZext - These nodes record if a register contains a
74 // value that has already been zero or sign extended from a narrower type.
75 // These nodes take two operands. The first is the node that has already
76 // been extended, and the second is a value type node indicating the width
77 // of the extension
78 AssertSext, AssertZext,
Misha Brukmanea61c352005-04-21 20:39:54 +000079
Chris Lattner8a496fc2005-01-13 17:58:35 +000080 // Various leaf nodes.
Evan Cheng1ab7d852006-03-01 00:51:13 +000081 STRING, BasicBlock, VALUETYPE, CONDCODE, Register,
82 Constant, ConstantFP,
Nate Begeman37efe672006-04-22 18:53:45 +000083 GlobalAddress, FrameIndex, JumpTable, ConstantPool, ExternalSymbol,
Evan Cheng1ab7d852006-03-01 00:51:13 +000084
Andrew Lenharth82c3d8f2006-10-11 04:29:42 +000085 // The address of the GOT
86 GLOBAL_OFFSET_TABLE,
Andrew Lenharthbeec30e2006-09-24 19:45:58 +000087
Chris Lattnerac0d7232006-01-29 06:24:40 +000088 // TargetConstant* - Like Constant*, but the DAG does not do any folding or
89 // simplification of the constant.
Chris Lattner056f9f62005-08-17 00:33:30 +000090 TargetConstant,
Chris Lattnerac0d7232006-01-29 06:24:40 +000091 TargetConstantFP,
Chris Lattnerf6b18492005-08-19 22:31:34 +000092
93 // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
94 // anything else with this node, and this is valid in the target-specific
95 // dag, turning into a GlobalAddress operand.
96 TargetGlobalAddress,
Chris Lattnerafb2dd42005-08-25 00:43:01 +000097 TargetFrameIndex,
Nate Begeman37efe672006-04-22 18:53:45 +000098 TargetJumpTable,
Chris Lattneraaaaf792005-08-25 05:02:41 +000099 TargetConstantPool,
Andrew Lenharth2a2de662005-10-23 03:40:17 +0000100 TargetExternalSymbol,
Chris Lattner72601ca2006-03-24 01:03:55 +0000101
Chris Lattneref8ef912006-03-28 00:39:06 +0000102 /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
103 /// This node represents a target intrinsic function with no side effects.
104 /// The first operand is the ID number of the intrinsic from the
105 /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The
106 /// node has returns the result of the intrinsic.
107 INTRINSIC_WO_CHAIN,
108
109 /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
110 /// This node represents a target intrinsic function with side effects that
111 /// returns a result. The first operand is a chain pointer. The second is
112 /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The
113 /// operands to the intrinsic follow. The node has two results, the result
114 /// of the intrinsic and an output chain.
115 INTRINSIC_W_CHAIN,
Chris Lattner63b570d2005-01-07 07:45:27 +0000116
Chris Lattneref8ef912006-03-28 00:39:06 +0000117 /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
118 /// This node represents a target intrinsic function with side effects that
119 /// does not return a result. The first operand is a chain pointer. The
120 /// second is the ID number of the intrinsic from the llvm::Intrinsic
121 /// namespace. The operands to the intrinsic follow.
122 INTRINSIC_VOID,
123
Chris Lattnerd5d0f9b2005-08-16 21:55:35 +0000124 // CopyToReg - This node has three operands: a chain, a register number to
125 // set to this value, and a value.
Chris Lattner63b570d2005-01-07 07:45:27 +0000126 CopyToReg,
127
128 // CopyFromReg - This node indicates that the input value is a virtual or
129 // physical register that is defined outside of the scope of this
Chris Lattner18c2f132005-01-13 20:50:02 +0000130 // SelectionDAG. The register is available from the RegSDNode object.
Chris Lattner63b570d2005-01-07 07:45:27 +0000131 CopyFromReg,
132
Nate Begemanfc1b1da2005-04-01 22:34:39 +0000133 // UNDEF - An undefined node
134 UNDEF,
Chris Lattner681ee1c2006-04-11 21:30:42 +0000135
Chris Lattnerc1a8ad72006-05-16 06:43:59 +0000136 /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG) - This node represents the formal
Chris Lattner681ee1c2006-04-11 21:30:42 +0000137 /// arguments for a function. CC# is a Constant value indicating the
138 /// calling convention of the function, and ISVARARG is a flag that
139 /// indicates whether the function is varargs or not. This node has one
Chris Lattnerc1a8ad72006-05-16 06:43:59 +0000140 /// result value for each incoming argument, plus one for the output chain.
141 /// It must be custom legalized.
142 ///
Chris Lattner681ee1c2006-04-11 21:30:42 +0000143 FORMAL_ARGUMENTS,
Chris Lattner6c0bfc72006-05-16 22:52:27 +0000144
145 /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE,
Evan Cheng9657eac2006-05-25 00:54:33 +0000146 /// ARG0, SIGN0, ARG1, SIGN1, ... ARGn, SIGNn)
Chris Lattner6c0bfc72006-05-16 22:52:27 +0000147 /// This node represents a fully general function call, before the legalizer
Evan Cheng9657eac2006-05-25 00:54:33 +0000148 /// runs. This has one result value for each argument / signness pair, plus
149 /// a chain result. It must be custom legalized.
Chris Lattner6c0bfc72006-05-16 22:52:27 +0000150 CALL,
Nate Begemanfc1b1da2005-04-01 22:34:39 +0000151
Chris Lattner63b570d2005-01-07 07:45:27 +0000152 // EXTRACT_ELEMENT - This is used to get the first or second (determined by
153 // a Constant, which is required to be operand #1), element of the aggregate
154 // value specified as operand #0. This is only for use before legalization,
155 // for values that will be broken into multiple registers.
156 EXTRACT_ELEMENT,
157
158 // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given
159 // two values of the same integer value type, this produces a value twice as
160 // big. Like EXTRACT_ELEMENT, this can only be used before legalization.
161 BUILD_PAIR,
Chris Lattner006e3e32005-11-20 22:55:57 +0000162
163 // MERGE_VALUES - This node takes multiple discrete operands and returns
164 // them all as its individual results. This nodes has exactly the same
165 // number of inputs and outputs, and is only valid before legalization.
166 // This node is useful for some pieces of the code generator that want to
167 // think about a single node with multiple results, not multiple nodes.
168 MERGE_VALUES,
Chris Lattner63b570d2005-01-07 07:45:27 +0000169
Chris Lattner615c2d02005-09-28 22:29:58 +0000170 // Simple integer binary arithmetic operators.
Chris Lattnerbede0b72005-04-06 04:21:29 +0000171 ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
Chris Lattner615c2d02005-09-28 22:29:58 +0000172
Nate Begeman551bf3f2006-02-17 05:43:56 +0000173 // Carry-setting nodes for multiple precision addition and subtraction.
174 // These nodes take two operands of the same value type, and produce two
175 // results. The first result is the normal add or sub result, the second
176 // result is the carry flag result.
177 ADDC, SUBC,
178
179 // Carry-using nodes for multiple precision addition and subtraction. These
180 // nodes take three operands: The first two are the normal lhs and rhs to
181 // the add or sub, and the third is the input carry flag. These nodes
182 // produce two results; the normal result of the add or sub, and the output
183 // carry flag. These nodes both read and write a carry flag to allow them
184 // to them to be chained together for add and sub of arbitrarily large
185 // values.
186 ADDE, SUBE,
187
Chris Lattner615c2d02005-09-28 22:29:58 +0000188 // Simple binary floating point operators.
189 FADD, FSUB, FMUL, FDIV, FREM,
Chris Lattner38bf3bf2006-03-05 05:06:40 +0000190
191 // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This
192 // DAG node does not require that X and Y have the same type, just that they
193 // are both floating point. X and the result must have the same type.
194 // FCOPYSIGN(f32, f64) is allowed.
195 FCOPYSIGN,
Chris Lattnerfa984b62006-03-17 19:53:41 +0000196
Chris Lattner22232f62006-03-19 00:52:25 +0000197 /// VBUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,..., COUNT,TYPE) - Return a vector
198 /// with the specified, possibly variable, elements. The number of elements
199 /// is required to be a power of two.
200 VBUILD_VECTOR,
Chris Lattnerbede0b72005-04-06 04:21:29 +0000201
Chris Lattner22232f62006-03-19 00:52:25 +0000202 /// BUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,...) - Return a vector
203 /// with the specified, possibly variable, elements. The number of elements
204 /// is required to be a power of two.
205 BUILD_VECTOR,
206
Chris Lattnerfa984b62006-03-17 19:53:41 +0000207 /// VINSERT_VECTOR_ELT(VECTOR, VAL, IDX, COUNT,TYPE) - Given a vector
208 /// VECTOR, an element ELEMENT, and a (potentially variable) index IDX,
209 /// return an vector with the specified element of VECTOR replaced with VAL.
210 /// COUNT and TYPE specify the type of vector, as is standard for V* nodes.
211 VINSERT_VECTOR_ELT,
212
Chris Lattner22232f62006-03-19 00:52:25 +0000213 /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR (a legal packed
214 /// type) with the element at IDX replaced with VAL.
215 INSERT_VECTOR_ELT,
Chris Lattner4b8db6c2006-03-21 20:43:08 +0000216
217 /// VEXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
218 /// (an MVT::Vector value) identified by the (potentially variable) element
219 /// number IDX.
220 VEXTRACT_VECTOR_ELT,
221
222 /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
223 /// (a legal packed type vector) identified by the (potentially variable)
224 /// element number IDX.
225 EXTRACT_VECTOR_ELT,
Chris Lattner22232f62006-03-19 00:52:25 +0000226
Chris Lattnereda6dfd2006-03-28 19:54:11 +0000227 /// VVECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC, COUNT,TYPE) - Returns a vector,
228 /// of the same type as VEC1/VEC2. SHUFFLEVEC is a VBUILD_VECTOR of
229 /// constant int values that indicate which value each result element will
230 /// get. The elements of VEC1/VEC2 are enumerated in order. This is quite
231 /// similar to the Altivec 'vperm' instruction, except that the indices must
232 /// be constants and are in terms of the element size of VEC1/VEC2, not in
233 /// terms of bytes.
234 VVECTOR_SHUFFLE,
235
Chris Lattner49c6d3e2006-03-19 23:42:51 +0000236 /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
237 /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values
238 /// (regardless of whether its datatype is legal or not) that indicate
239 /// which value each result element will get. The elements of VEC1/VEC2 are
240 /// enumerated in order. This is quite similar to the Altivec 'vperm'
241 /// instruction, except that the indices must be constants and are in terms
242 /// of the element size of VEC1/VEC2, not in terms of bytes.
243 VECTOR_SHUFFLE,
244
Chris Lattner762f2ae2006-03-22 19:56:46 +0000245 /// X = VBIT_CONVERT(Y) and X = VBIT_CONVERT(Y, COUNT,TYPE) - This node
246 /// represents a conversion from or to an ISD::Vector type.
247 ///
248 /// This is lowered to a BIT_CONVERT of the appropriate input/output types.
249 /// The input and output are required to have the same size and at least one
Chris Lattner313f13c2006-03-22 20:09:04 +0000250 /// is required to be a vector (if neither is a vector, just use
251 /// BIT_CONVERT).
Chris Lattner762f2ae2006-03-22 19:56:46 +0000252 ///
Chris Lattner313f13c2006-03-22 20:09:04 +0000253 /// If the result is a vector, this takes three operands (like any other
254 /// vector producer) which indicate the size and type of the vector result.
Chris Lattner762f2ae2006-03-22 19:56:46 +0000255 /// Otherwise it takes one input.
256 VBIT_CONVERT,
257
Chris Lattner22232f62006-03-19 00:52:25 +0000258 /// BINOP(LHS, RHS, COUNT,TYPE)
259 /// Simple abstract vector operators. Unlike the integer and floating point
260 /// binary operators, these nodes also take two additional operands:
261 /// a constant element count, and a value type node indicating the type of
262 /// the elements. The order is count, type, op0, op1. All vector opcodes,
263 /// including VLOAD and VConstant must currently have count and type as
264 /// their last two operands.
265 VADD, VSUB, VMUL, VSDIV, VUDIV,
266 VAND, VOR, VXOR,
Chris Lattner210721a2006-03-19 05:26:45 +0000267
Chris Lattner49027e62006-04-08 22:16:01 +0000268 /// VSELECT(COND,LHS,RHS, COUNT,TYPE) - Select for MVT::Vector values.
269 /// COND is a boolean value. This node return LHS if COND is true, RHS if
270 /// COND is false.
271 VSELECT,
272
Chris Lattner210721a2006-03-19 05:26:45 +0000273 /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
274 /// scalar value into the low element of the resultant vector type. The top
275 /// elements of the vector are undefined.
276 SCALAR_TO_VECTOR,
277
Chris Lattnerbede0b72005-04-06 04:21:29 +0000278 // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
279 // an unsigned/signed value of type i[2*n], then return the top part.
280 MULHU, MULHS,
Chris Lattner63b570d2005-01-07 07:45:27 +0000281
Nate Begeman35ef9132006-01-11 21:21:00 +0000282 // Bitwise operators - logical and, logical or, logical xor, shift left,
283 // shift right algebraic (shift in sign bits), shift right logical (shift in
284 // zeroes), rotate left, rotate right, and byteswap.
285 AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
Chris Lattner63b570d2005-01-07 07:45:27 +0000286
Andrew Lenharth691ef2b2005-05-03 17:19:30 +0000287 // Counting operators
288 CTTZ, CTLZ, CTPOP,
289
Chris Lattnerfa984b62006-03-17 19:53:41 +0000290 // Select(COND, TRUEVAL, FALSEVAL)
Nate Begeman9373a812005-08-10 20:51:12 +0000291 SELECT,
292
293 // Select with condition operator - This selects between a true value and
294 // a false value (ops #2 and #3) based on the boolean result of comparing
295 // the lhs and rhs (ops #0 and #1) of a conditional expression with the
296 // condition code in op #4, a CondCodeSDNode.
297 SELECT_CC,
Chris Lattner63b570d2005-01-07 07:45:27 +0000298
299 // SetCC operator - This evaluates to a boolean (i1) true value if the
Chris Lattner7cf7e3f2005-08-09 20:20:18 +0000300 // condition is true. The operands to this are the left and right operands
301 // to compare (ops #0, and #1) and the condition code to compare them with
302 // (op #2) as a CondCodeSDNode.
Chris Lattner63b570d2005-01-07 07:45:27 +0000303 SETCC,
304
Chris Lattner14c5b532005-04-02 03:30:33 +0000305 // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
306 // integer shift operations, just like ADD/SUB_PARTS. The operation
307 // ordering is:
Chris Lattner6b8f2d62005-04-02 03:59:45 +0000308 // [Lo,Hi] = op [LoLHS,HiLHS], Amt
Chris Lattner14c5b532005-04-02 03:30:33 +0000309 SHL_PARTS, SRA_PARTS, SRL_PARTS,
310
Chris Lattner63b570d2005-01-07 07:45:27 +0000311 // Conversion operators. These are all single input single output
312 // operations. For all of these, the result type must be strictly
313 // wider or narrower (depending on the operation) than the source
314 // type.
315
316 // SIGN_EXTEND - Used for integer types, replicating the sign bit
317 // into new bits.
318 SIGN_EXTEND,
319
320 // ZERO_EXTEND - Used for integer types, zeroing the new bits.
321 ZERO_EXTEND,
322
Chris Lattner7e122db2005-09-02 00:14:40 +0000323 // ANY_EXTEND - Used for integer types. The high bits are undefined.
324 ANY_EXTEND,
325
Chris Lattner63b570d2005-01-07 07:45:27 +0000326 // TRUNCATE - Completely drop the high bits.
327 TRUNCATE,
328
Chris Lattner1645ed02005-01-08 08:08:49 +0000329 // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
330 // depends on the first letter) to floating point.
331 SINT_TO_FP,
332 UINT_TO_FP,
333
Chris Lattnerea576102005-04-13 02:36:41 +0000334 // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
335 // sign extend a small value in a large integer register (e.g. sign
336 // extending the low 8 bits of a 32-bit register to fill the top 24 bits
Chris Lattner15e4b012005-07-10 00:07:11 +0000337 // with the 7th bit). The size of the smaller type is indicated by the 1th
338 // operand, a ValueType node.
Chris Lattner859157d2005-01-15 06:17:04 +0000339 SIGN_EXTEND_INREG,
Chris Lattner859157d2005-01-15 06:17:04 +0000340
Chris Lattner1645ed02005-01-08 08:08:49 +0000341 // FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
342 // integer.
343 FP_TO_SINT,
344 FP_TO_UINT,
345
Chris Lattner63b570d2005-01-07 07:45:27 +0000346 // FP_ROUND - Perform a rounding operation from the current
Chris Lattner859157d2005-01-15 06:17:04 +0000347 // precision down to the specified precision (currently always 64->32).
Chris Lattner63b570d2005-01-07 07:45:27 +0000348 FP_ROUND,
349
Chris Lattner859157d2005-01-15 06:17:04 +0000350 // FP_ROUND_INREG - This operator takes a floating point register, and
351 // rounds it to a floating point value. It then promotes it and returns it
352 // in a register of the same size. This operation effectively just discards
Chris Lattner15e4b012005-07-10 00:07:11 +0000353 // excess precision. The type to round down to is specified by the 1th
354 // operation, a VTSDNode (currently always 64->32->64).
Chris Lattner859157d2005-01-15 06:17:04 +0000355 FP_ROUND_INREG,
356
Chris Lattner63b570d2005-01-07 07:45:27 +0000357 // FP_EXTEND - Extend a smaller FP type into a larger FP type.
358 FP_EXTEND,
359
Chris Lattner1ac1c4b2005-12-23 00:15:59 +0000360 // BIT_CONVERT - Theis operator converts between integer and FP values, as
361 // if one was stored to memory as integer and the other was loaded from the
Chris Lattner80f55ab2005-12-23 00:46:10 +0000362 // same address (or equivalently for vector format conversions, etc). The
363 // source and result are required to have the same bit size (e.g.
364 // f32 <-> i32). This can also be used for int-to-int or fp-to-fp
365 // conversions, but that is a noop, deleted by getNode().
Chris Lattner1ac1c4b2005-12-23 00:15:59 +0000366 BIT_CONVERT,
367
Chris Lattnerdd2afb02006-09-09 05:55:44 +0000368 // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI - Perform unary floating point
369 // negation, absolute value, square root, sine and cosine, and powi
370 // operations.
371 FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI,
Chris Lattner38bf3bf2006-03-05 05:06:40 +0000372
Evan Cheng8862ef12006-10-26 21:52:24 +0000373 // LOAD and STORE have token chains as their first operand, then the same
374 // operands as an LLVM load/store instruction, then an offset node that
375 // is added / subtracted from the base pointer to form the address (for
376 // indexed memory ops).
Chris Lattner63b570d2005-01-07 07:45:27 +0000377 LOAD, STORE,
Nate Begeman5fbb5d22005-11-19 00:36:38 +0000378
Evan Cheng1ab7d852006-03-01 00:51:13 +0000379 // Abstract vector version of LOAD. VLOAD has a constant element count as
380 // the first operand, followed by a value type node indicating the type of
381 // the elements, a token chain, a pointer operand, and a SRCVALUE node.
Nate Begeman5fbb5d22005-11-19 00:36:38 +0000382 VLOAD,
Chris Lattner63b570d2005-01-07 07:45:27 +0000383
Chris Lattner1cff05c2005-01-14 22:07:46 +0000384 // TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a
385 // value and stores it to memory in one operation. This can be used for
Chris Lattnerf7db8c62005-07-10 00:28:25 +0000386 // either integer or floating point operands. The first four operands of
387 // this are the same as a standard store. The fifth is the ValueType to
388 // store it as (which will be smaller than the source value).
Chris Lattner1cff05c2005-01-14 22:07:46 +0000389 TRUNCSTORE,
390
Chris Lattner63b570d2005-01-07 07:45:27 +0000391 // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
392 // to a specified boundary. The first operand is the token chain, the
393 // second is the number of bytes to allocate, and the third is the alignment
Chris Lattner74fe0632005-08-29 22:48:32 +0000394 // boundary. The size is guaranteed to be a multiple of the stack
395 // alignment, and the alignment is guaranteed to be bigger than the stack
396 // alignment (if required) or 0 to get standard stack alignment.
Chris Lattner63b570d2005-01-07 07:45:27 +0000397 DYNAMIC_STACKALLOC,
398
399 // Control flow instructions. These all have token chains.
Misha Brukmanea61c352005-04-21 20:39:54 +0000400
Chris Lattner63b570d2005-01-07 07:45:27 +0000401 // BR - Unconditional branch. The first operand is the chain
402 // operand, the second is the MBB to branch to.
403 BR,
404
Nate Begeman37efe672006-04-22 18:53:45 +0000405 // BRIND - Indirect branch. The first operand is the chain, the second
406 // is the value to branch to, which must be of the same type as the target's
407 // pointer type.
408 BRIND,
409
Chris Lattner63b570d2005-01-07 07:45:27 +0000410 // BRCOND - Conditional branch. The first operand is the chain,
411 // the second is the condition, the third is the block to branch
412 // to if the condition is true.
413 BRCOND,
414
Nate Begeman7cbd5252005-08-16 19:49:35 +0000415 // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in
416 // that the condition is represented as condition code, and two nodes to
417 // compare, rather than as a combined SetCC node. The operands in order are
418 // chain, cc, lhs, rhs, block to branch to if condition is true.
419 BR_CC,
420
Chris Lattner63b570d2005-01-07 07:45:27 +0000421 // RET - Return from function. The first operand is the chain,
Evan Cheng8e7d0562006-05-26 23:09:09 +0000422 // and any subsequent operands are pairs of return value and return value
423 // signness for the function. This operation can have variable number of
424 // operands.
Chris Lattner63b570d2005-01-07 07:45:27 +0000425 RET,
426
Chris Lattner7572eb82006-01-26 22:23:45 +0000427 // INLINEASM - Represents an inline asm block. This node always has two
428 // return values: a chain and a flag result. The inputs are as follows:
429 // Operand #0 : Input chain.
430 // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string.
431 // Operand #2n+2: A RegisterNode.
432 // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
433 // Operand #last: Optional, an incoming flag.
434 INLINEASM,
Chris Lattneref36aa72005-01-11 05:56:17 +0000435
Chris Lattner5a67afc2006-01-13 02:39:42 +0000436 // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a
437 // value, the same type as the pointer type for the system, and an output
438 // chain.
439 STACKSAVE,
440
441 // STACKRESTORE has two operands, an input chain and a pointer to restore to
442 // it returns an output chain.
443 STACKRESTORE,
444
Chris Lattneref36aa72005-01-11 05:56:17 +0000445 // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain, and the rest
446 // correspond to the operands of the LLVM intrinsic functions. The only
447 // result is a token chain. The alignment argument is guaranteed to be a
448 // Constant node.
449 MEMSET,
450 MEMMOVE,
451 MEMCPY,
Misha Brukmanea61c352005-04-21 20:39:54 +0000452
Chris Lattner16cd04d2005-05-12 23:24:06 +0000453 // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
454 // a call sequence, and carry arbitrary information that target might want
455 // to know. The first operand is a chain, the rest are specified by the
456 // target and not touched by the DAG optimizers.
457 CALLSEQ_START, // Beginning of a call sequence
458 CALLSEQ_END, // End of a call sequence
Nate Begemanacc398c2006-01-25 18:21:52 +0000459
460 // VAARG - VAARG has three operands: an input chain, a pointer, and a
461 // SRCVALUE. It returns a pair of values: the vaarg value and a new chain.
462 VAARG,
463
464 // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
465 // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
466 // source.
467 VACOPY,
468
469 // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
470 // pointer, and a SRCVALUE.
471 VAEND, VASTART,
Chris Lattner63b570d2005-01-07 07:45:27 +0000472
Chris Lattner21074f42005-05-09 20:21:27 +0000473 // SRCVALUE - This corresponds to a Value*, and is used to associate memory
474 // locations with their value. This allows one use alias analysis
475 // information in the backend.
476 SRCVALUE,
477
Misha Brukmane3f570c2005-03-31 21:30:35 +0000478 // PCMARKER - This corresponds to the pcmarker intrinsic.
Andrew Lenharth95762122005-03-31 21:24:06 +0000479 PCMARKER,
Chris Lattner63b570d2005-01-07 07:45:27 +0000480
Andrew Lenharthaeef8fc2005-11-11 16:45:18 +0000481 // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
Andrew Lenharth8b91c772005-11-11 22:48:54 +0000482 // The only operand is a chain and a value and a chain are produced. The
483 // value is the contents of the architecture specific cycle counter like
484 // register (or other high accuracy low latency clock source)
Andrew Lenharthaeef8fc2005-11-11 16:45:18 +0000485 READCYCLECOUNTER,
486
Chris Lattnerd623e952005-10-05 06:34:34 +0000487 // HANDLENODE node - Used as a handle for various purposes.
488 HANDLENODE,
Andrew Lenharth2d86ea22005-04-27 20:10:01 +0000489
Chris Lattner47725d02005-11-29 06:15:39 +0000490 // LOCATION - This node is used to represent a source location for debug
491 // info. It takes token chain as input, then a line number, then a column
492 // number, then a filename, then a working dir. It produces a token chain
493 // as output.
494 LOCATION,
495
Jim Laskeyf5395ce2005-12-16 22:45:29 +0000496 // DEBUG_LOC - This node is used to represent source line information
Jim Laskeyabf6d172006-01-05 01:25:28 +0000497 // embedded in the code. It takes a token chain as input, then a line
498 // number, then a column then a file id (provided by MachineDebugInfo.) It
499 // produces a token chain as output.
Jim Laskeyf5395ce2005-12-16 22:45:29 +0000500 DEBUG_LOC,
501
Jim Laskeyabf6d172006-01-05 01:25:28 +0000502 // DEBUG_LABEL - This node is used to mark a location in the code where a
503 // label should be generated for use by the debug information. It takes a
Jim Laskeydf0f6592006-01-05 01:53:28 +0000504 // token chain as input and then a unique id (provided by MachineDebugInfo.)
505 // It produces a token chain as output.
Jim Laskeyabf6d172006-01-05 01:25:28 +0000506 DEBUG_LABEL,
507
Chris Lattner63b570d2005-01-07 07:45:27 +0000508 // BUILTIN_OP_END - This must be the last enum value in this list.
Chris Lattner410354f2006-02-22 16:23:43 +0000509 BUILTIN_OP_END
Chris Lattner63b570d2005-01-07 07:45:27 +0000510 };
511
Chris Lattner322dcd32006-03-25 22:56:35 +0000512 /// Node predicates
513
Evan Chenga8df1662006-03-27 06:58:47 +0000514 /// isBuildVectorAllOnes - Return true if the specified node is a
Chris Lattner322dcd32006-03-25 22:56:35 +0000515 /// BUILD_VECTOR where all of the elements are ~0 or undef.
Evan Chenga8df1662006-03-27 06:58:47 +0000516 bool isBuildVectorAllOnes(const SDNode *N);
Evan Cheng4a147842006-03-26 09:50:58 +0000517
518 /// isBuildVectorAllZeros - Return true if the specified node is a
519 /// BUILD_VECTOR where all of the elements are 0 or undef.
520 bool isBuildVectorAllZeros(const SDNode *N);
Chris Lattner322dcd32006-03-25 22:56:35 +0000521
Chris Lattner63b570d2005-01-07 07:45:27 +0000522 //===--------------------------------------------------------------------===//
Evan Cheng24446e22006-10-09 20:55:20 +0000523 /// MemOpAddrMode enum - This enum defines the three load / store addressing
524 /// modes.
525 ///
526 /// UNINDEXED "Normal" load / store. The effective address is already
527 /// computed and is available in the base pointer. The offset
Evan Cheng81c38452006-10-10 01:44:58 +0000528 /// operand is always undefined. In addition to producing a
529 /// chain, an unindexed load produces one value (result of the
530 /// load); an unindexed store does not produces a value.
Evan Cheng24446e22006-10-09 20:55:20 +0000531 ///
Evan Cheng35acd302006-10-17 21:12:56 +0000532 /// PRE_INC Similar to the unindexed mode where the effective address is
Evan Cheng8862ef12006-10-26 21:52:24 +0000533 /// PRE_DEC the value of the base pointer add / subtract the offset.
534 /// It considers the computation as being folded into the load /
Evan Cheng24446e22006-10-09 20:55:20 +0000535 /// store operation (i.e. the load / store does the address
536 /// computation as well as performing the memory transaction).
Evan Cheng81c38452006-10-10 01:44:58 +0000537 /// The base operand is always undefined. In addition to
538 /// producing a chain, pre-indexed load produces two values
539 /// (result of the load and the result of the address
540 /// computation); a pre-indexed store produces one value (result
541 /// of the address computation).
Evan Cheng24446e22006-10-09 20:55:20 +0000542 ///
Evan Cheng35acd302006-10-17 21:12:56 +0000543 /// POST_INC The effective address is the value of the base pointer. The
Evan Cheng8862ef12006-10-26 21:52:24 +0000544 /// POST_DEC value of the offset operand is then added to / subtracted
545 /// from the base after memory transaction. In addition to
546 /// producing a chain, post-indexed load produces two values
547 /// (the result of the load and the result of the base +/- offset
548 /// computation); a post-indexed store produces one value (the
549 /// the result of the base +/- offset computation).
Evan Cheng24446e22006-10-09 20:55:20 +0000550 ///
551 enum MemOpAddrMode {
552 UNINDEXED = 0,
Evan Cheng35acd302006-10-17 21:12:56 +0000553 PRE_INC,
554 PRE_DEC,
555 POST_INC,
556 POST_DEC
Evan Cheng24446e22006-10-09 20:55:20 +0000557 };
558
559 //===--------------------------------------------------------------------===//
Evan Chengc5484282006-10-04 00:56:09 +0000560 /// LoadExtType enum - This enum defines the three variants of LOADEXT
561 /// (load with extension).
562 ///
Evan Cheng24446e22006-10-09 20:55:20 +0000563 /// SEXTLOAD loads the integer operand and sign extends it to a larger
564 /// integer result type.
565 /// ZEXTLOAD loads the integer operand and zero extends it to a larger
566 /// integer result type.
567 /// EXTLOAD is used for three things: floating point extending loads,
568 /// integer extending loads [the top bits are undefined], and vector
569 /// extending loads [load into low elt].
570 ///
Evan Chengc5484282006-10-04 00:56:09 +0000571 enum LoadExtType {
Evan Cheng24446e22006-10-09 20:55:20 +0000572 NON_EXTLOAD = 0,
Evan Chengc5484282006-10-04 00:56:09 +0000573 EXTLOAD,
574 SEXTLOAD,
575 ZEXTLOAD,
576 LAST_LOADX_TYPE
577 };
578
579 //===--------------------------------------------------------------------===//
Chris Lattner63b570d2005-01-07 07:45:27 +0000580 /// ISD::CondCode enum - These are ordered carefully to make the bitfields
581 /// below work out, when considering SETFALSE (something that never exists
582 /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered
583 /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
584 /// to. If the "N" column is 1, the result of the comparison is undefined if
585 /// the input is a NAN.
586 ///
587 /// All of these (except for the 'always folded ops') should be handled for
588 /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
589 /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
590 ///
591 /// Note that these are laid out in a specific order to allow bit-twiddling
592 /// to transform conditions.
593 enum CondCode {
594 // Opcode N U L G E Intuitive operation
595 SETFALSE, // 0 0 0 0 Always false (always folded)
596 SETOEQ, // 0 0 0 1 True if ordered and equal
597 SETOGT, // 0 0 1 0 True if ordered and greater than
598 SETOGE, // 0 0 1 1 True if ordered and greater than or equal
599 SETOLT, // 0 1 0 0 True if ordered and less than
600 SETOLE, // 0 1 0 1 True if ordered and less than or equal
601 SETONE, // 0 1 1 0 True if ordered and operands are unequal
602 SETO, // 0 1 1 1 True if ordered (no nans)
603 SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y)
604 SETUEQ, // 1 0 0 1 True if unordered or equal
605 SETUGT, // 1 0 1 0 True if unordered or greater than
606 SETUGE, // 1 0 1 1 True if unordered, greater than, or equal
607 SETULT, // 1 1 0 0 True if unordered or less than
Misha Brukmanea61c352005-04-21 20:39:54 +0000608 SETULE, // 1 1 0 1 True if unordered, less than, or equal
Chris Lattner63b570d2005-01-07 07:45:27 +0000609 SETUNE, // 1 1 1 0 True if unordered or not equal
610 SETTRUE, // 1 1 1 1 Always true (always folded)
611 // Don't care operations: undefined if the input is a nan.
612 SETFALSE2, // 1 X 0 0 0 Always false (always folded)
613 SETEQ, // 1 X 0 0 1 True if equal
614 SETGT, // 1 X 0 1 0 True if greater than
615 SETGE, // 1 X 0 1 1 True if greater than or equal
616 SETLT, // 1 X 1 0 0 True if less than
Misha Brukmanea61c352005-04-21 20:39:54 +0000617 SETLE, // 1 X 1 0 1 True if less than or equal
Chris Lattner63b570d2005-01-07 07:45:27 +0000618 SETNE, // 1 X 1 1 0 True if not equal
619 SETTRUE2, // 1 X 1 1 1 Always true (always folded)
620
Chris Lattner410354f2006-02-22 16:23:43 +0000621 SETCC_INVALID // Marker value.
Chris Lattner63b570d2005-01-07 07:45:27 +0000622 };
623
624 /// isSignedIntSetCC - Return true if this is a setcc instruction that
625 /// performs a signed comparison when used with integer operands.
626 inline bool isSignedIntSetCC(CondCode Code) {
627 return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
628 }
629
630 /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
631 /// performs an unsigned comparison when used with integer operands.
632 inline bool isUnsignedIntSetCC(CondCode Code) {
633 return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
634 }
635
636 /// isTrueWhenEqual - Return true if the specified condition returns true if
637 /// the two operands to the condition are equal. Note that if one of the two
638 /// operands is a NaN, this value is meaningless.
639 inline bool isTrueWhenEqual(CondCode Cond) {
640 return ((int)Cond & 1) != 0;
641 }
642
643 /// getUnorderedFlavor - This function returns 0 if the condition is always
644 /// false if an operand is a NaN, 1 if the condition is always true if the
645 /// operand is a NaN, and 2 if the condition is undefined if the operand is a
646 /// NaN.
647 inline unsigned getUnorderedFlavor(CondCode Cond) {
648 return ((int)Cond >> 3) & 3;
649 }
650
651 /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
652 /// 'op' is a valid SetCC operation.
653 CondCode getSetCCInverse(CondCode Operation, bool isInteger);
654
655 /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
656 /// when given the operation for (X op Y).
657 CondCode getSetCCSwappedOperands(CondCode Operation);
658
659 /// getSetCCOrOperation - Return the result of a logical OR between different
660 /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This
661 /// function returns SETCC_INVALID if it is not possible to represent the
662 /// resultant comparison.
663 CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
664
665 /// getSetCCAndOperation - Return the result of a logical AND between
666 /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This
667 /// function returns SETCC_INVALID if it is not possible to represent the
668 /// resultant comparison.
669 CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
670} // end llvm::ISD namespace
671
672
673//===----------------------------------------------------------------------===//
674/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple
675/// values as the result of a computation. Many nodes return multiple values,
676/// from loads (which define a token and a return value) to ADDC (which returns
677/// a result and a carry value), to calls (which may return an arbitrary number
678/// of values).
679///
680/// As such, each use of a SelectionDAG computation must indicate the node that
681/// computes it as well as which return value to use from that node. This pair
682/// of information is represented with the SDOperand value type.
683///
Chris Lattnerf26bc8e2005-01-08 19:52:31 +0000684class SDOperand {
685public:
Chris Lattner63b570d2005-01-07 07:45:27 +0000686 SDNode *Val; // The node defining the value we are using.
687 unsigned ResNo; // Which return value of the node we are using.
688
Reid Spencerace44db2006-04-12 16:44:15 +0000689 SDOperand() : Val(0), ResNo(0) {}
Chris Lattner63b570d2005-01-07 07:45:27 +0000690 SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {}
691
692 bool operator==(const SDOperand &O) const {
693 return Val == O.Val && ResNo == O.ResNo;
694 }
695 bool operator!=(const SDOperand &O) const {
696 return !operator==(O);
697 }
698 bool operator<(const SDOperand &O) const {
699 return Val < O.Val || (Val == O.Val && ResNo < O.ResNo);
700 }
701
702 SDOperand getValue(unsigned R) const {
703 return SDOperand(Val, R);
704 }
705
Evan Chengbfa284f2006-03-03 06:42:32 +0000706 // isOperand - Return true if this node is an operand of N.
707 bool isOperand(SDNode *N) const;
708
Chris Lattner63b570d2005-01-07 07:45:27 +0000709 /// getValueType - Return the ValueType of the referenced return value.
710 ///
711 inline MVT::ValueType getValueType() const;
Misha Brukmanea61c352005-04-21 20:39:54 +0000712
Chris Lattner63b570d2005-01-07 07:45:27 +0000713 // Forwarding methods - These forward to the corresponding methods in SDNode.
714 inline unsigned getOpcode() const;
715 inline unsigned getNumOperands() const;
716 inline const SDOperand &getOperand(unsigned i) const;
Evan Chengc5484282006-10-04 00:56:09 +0000717 inline uint64_t getConstantOperandVal(unsigned i) const;
Nate Begeman0f66a912005-08-17 23:44:54 +0000718 inline bool isTargetOpcode() const;
719 inline unsigned getTargetOpcode() const;
Chris Lattnera44f4ae2005-01-13 22:58:50 +0000720
721 /// hasOneUse - Return true if there is exactly one operation using this
722 /// result value of the defining operator.
723 inline bool hasOneUse() const;
Chris Lattner63b570d2005-01-07 07:45:27 +0000724};
725
726
727/// simplify_type specializations - Allow casting operators to work directly on
728/// SDOperands as if they were SDNode*'s.
729template<> struct simplify_type<SDOperand> {
730 typedef SDNode* SimpleType;
731 static SimpleType getSimplifiedValue(const SDOperand &Val) {
732 return static_cast<SimpleType>(Val.Val);
733 }
734};
735template<> struct simplify_type<const SDOperand> {
736 typedef SDNode* SimpleType;
737 static SimpleType getSimplifiedValue(const SDOperand &Val) {
738 return static_cast<SimpleType>(Val.Val);
739 }
740};
741
742
743/// SDNode - Represents one node in the SelectionDAG.
744///
745class SDNode {
Chris Lattner0442fbf2005-01-21 21:39:38 +0000746 /// NodeType - The operation that this node performs.
747 ///
748 unsigned short NodeType;
749
Evan Chengb9ee9e62006-07-27 06:38:21 +0000750 /// NodeId - Unique id per SDNode in the DAG.
751 int NodeId;
Chris Lattner0442fbf2005-01-21 21:39:38 +0000752
Chris Lattnerf71e8432005-11-08 22:06:23 +0000753 /// OperandList - The values that are used by this operation.
Chris Lattner0442fbf2005-01-21 21:39:38 +0000754 ///
Chris Lattnerf71e8432005-11-08 22:06:23 +0000755 SDOperand *OperandList;
756
757 /// ValueList - The types of the values this node defines. SDNode's may
758 /// define multiple values simultaneously.
Chris Lattner2fa6d3b2006-08-14 23:31:51 +0000759 const MVT::ValueType *ValueList;
Chris Lattner63b570d2005-01-07 07:45:27 +0000760
Chris Lattnerf71e8432005-11-08 22:06:23 +0000761 /// NumOperands/NumValues - The number of entries in the Operand/Value list.
762 unsigned short NumOperands, NumValues;
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000763
764 /// Prev/Next pointers - These pointers form the linked list of of the
765 /// AllNodes list in the current DAG.
766 SDNode *Prev, *Next;
767 friend struct ilist_traits<SDNode>;
Chris Lattner63b570d2005-01-07 07:45:27 +0000768
Chris Lattnera5682852006-08-07 23:03:03 +0000769 /// NextInBucket - This is used by the SelectionDAGCSEMap.
770 void *NextInBucket;
771
Chris Lattner63b570d2005-01-07 07:45:27 +0000772 /// Uses - These are all of the SDNode's that use a value produced by this
773 /// node.
Chris Lattner5892d472006-08-16 21:01:10 +0000774 SmallVector<SDNode*,3> Uses;
Chris Lattner917d2c92006-07-19 00:00:37 +0000775
776 // Out-of-line virtual method to give class a home.
777 virtual void ANCHOR();
Chris Lattner63b570d2005-01-07 07:45:27 +0000778public:
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000779 virtual ~SDNode() {
780 assert(NumOperands == 0 && "Operand list not cleared before deletion");
Chris Lattner213a16c2006-08-14 22:19:25 +0000781 assert(NextInBucket == 0 && "Still in CSEMap?");
Chris Lattner3258ed62006-05-27 00:40:15 +0000782 NodeType = ISD::DELETED_NODE;
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000783 }
784
Chris Lattner63b570d2005-01-07 07:45:27 +0000785 //===--------------------------------------------------------------------===//
786 // Accessors
787 //
788 unsigned getOpcode() const { return NodeType; }
Nate Begeman0f66a912005-08-17 23:44:54 +0000789 bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
790 unsigned getTargetOpcode() const {
791 assert(isTargetOpcode() && "Not a target opcode!");
792 return NodeType - ISD::BUILTIN_OP_END;
793 }
Chris Lattner63b570d2005-01-07 07:45:27 +0000794
795 size_t use_size() const { return Uses.size(); }
796 bool use_empty() const { return Uses.empty(); }
797 bool hasOneUse() const { return Uses.size() == 1; }
798
Evan Chengb9ee9e62006-07-27 06:38:21 +0000799 /// getNodeId - Return the unique node id.
800 ///
801 int getNodeId() const { return NodeId; }
Chris Lattner0442fbf2005-01-21 21:39:38 +0000802
Chris Lattner5892d472006-08-16 21:01:10 +0000803 typedef SmallVector<SDNode*,3>::const_iterator use_iterator;
Chris Lattner7ece3802005-01-17 02:24:59 +0000804 use_iterator use_begin() const { return Uses.begin(); }
805 use_iterator use_end() const { return Uses.end(); }
806
Chris Lattnerb18a2f82005-01-12 18:37:33 +0000807 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
808 /// indicated value. This method ignores uses of other values defined by this
809 /// operation.
Evan Cheng4ee62112006-02-05 06:29:23 +0000810 bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
811
812 // isOnlyUse - Return true if this node is the only use of N.
813 bool isOnlyUse(SDNode *N) const;
Chris Lattnerb18a2f82005-01-12 18:37:33 +0000814
Evan Cheng80d8eaa2006-03-03 06:24:54 +0000815 // isOperand - Return true if this node is an operand of N.
816 bool isOperand(SDNode *N) const;
817
Chris Lattner63b570d2005-01-07 07:45:27 +0000818 /// getNumOperands - Return the number of values used by this operation.
819 ///
Chris Lattnerf71e8432005-11-08 22:06:23 +0000820 unsigned getNumOperands() const { return NumOperands; }
Chris Lattner63b570d2005-01-07 07:45:27 +0000821
Evan Chengc5484282006-10-04 00:56:09 +0000822 /// getConstantOperandVal - Helper method returns the integer value of a
823 /// ConstantSDNode operand.
824 uint64_t getConstantOperandVal(unsigned Num) const;
825
Chris Lattner63b570d2005-01-07 07:45:27 +0000826 const SDOperand &getOperand(unsigned Num) const {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000827 assert(Num < NumOperands && "Invalid child # of SDNode!");
828 return OperandList[Num];
Chris Lattner63b570d2005-01-07 07:45:27 +0000829 }
Evan Chengc5484282006-10-04 00:56:09 +0000830
Chris Lattnerf71e8432005-11-08 22:06:23 +0000831 typedef const SDOperand* op_iterator;
832 op_iterator op_begin() const { return OperandList; }
833 op_iterator op_end() const { return OperandList+NumOperands; }
Chris Lattner50f5a512005-05-14 06:19:11 +0000834
Chris Lattner63b570d2005-01-07 07:45:27 +0000835
Chris Lattner0b3e5252006-08-15 19:11:05 +0000836 SDVTList getVTList() const {
837 SDVTList X = { ValueList, NumValues };
838 return X;
839 };
840
Chris Lattner63b570d2005-01-07 07:45:27 +0000841 /// getNumValues - Return the number of values defined/returned by this
842 /// operator.
843 ///
Chris Lattnerf71e8432005-11-08 22:06:23 +0000844 unsigned getNumValues() const { return NumValues; }
Chris Lattner63b570d2005-01-07 07:45:27 +0000845
846 /// getValueType - Return the type of a specified result.
847 ///
848 MVT::ValueType getValueType(unsigned ResNo) const {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000849 assert(ResNo < NumValues && "Illegal result number!");
850 return ValueList[ResNo];
Chris Lattner63b570d2005-01-07 07:45:27 +0000851 }
Jeff Cohen9eb59ec2005-07-27 05:53:44 +0000852
Chris Lattnerf71e8432005-11-08 22:06:23 +0000853 typedef const MVT::ValueType* value_iterator;
854 value_iterator value_begin() const { return ValueList; }
855 value_iterator value_end() const { return ValueList+NumValues; }
Chris Lattner63b570d2005-01-07 07:45:27 +0000856
Chris Lattner6e6e3ce2005-01-10 23:25:04 +0000857 /// getOperationName - Return the opcode of this operation for printing.
858 ///
Chris Lattnerefe58692005-08-16 18:32:18 +0000859 const char* getOperationName(const SelectionDAG *G = 0) const;
Evan Cheng35acd302006-10-17 21:12:56 +0000860 static const char* getAddressingModeName(ISD::MemOpAddrMode AM);
Chris Lattner63b570d2005-01-07 07:45:27 +0000861 void dump() const;
Chris Lattnerefe58692005-08-16 18:32:18 +0000862 void dump(const SelectionDAG *G) const;
Chris Lattner63b570d2005-01-07 07:45:27 +0000863
864 static bool classof(const SDNode *) { return true; }
865
Chris Lattnera5682852006-08-07 23:03:03 +0000866
867 /// NextInBucket accessors, these are private to SelectionDAGCSEMap.
868 void *getNextInBucket() const { return NextInBucket; }
869 void SetNextInBucket(void *N) { NextInBucket = N; }
870
Chris Lattner63b570d2005-01-07 07:45:27 +0000871protected:
872 friend class SelectionDAG;
Chris Lattner109654f2005-11-08 23:30:11 +0000873
874 /// getValueTypeList - Return a pointer to the specified value type.
875 ///
876 static MVT::ValueType *getValueTypeList(MVT::ValueType VT);
Chris Lattner63b570d2005-01-07 07:45:27 +0000877
Evan Chengb9ee9e62006-07-27 06:38:21 +0000878 SDNode(unsigned NT, MVT::ValueType VT) : NodeType(NT), NodeId(-1) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000879 OperandList = 0; NumOperands = 0;
Chris Lattner109654f2005-11-08 23:30:11 +0000880 ValueList = getValueTypeList(VT);
Chris Lattnerf71e8432005-11-08 22:06:23 +0000881 NumValues = 1;
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000882 Prev = 0; Next = 0;
Chris Lattnera5682852006-08-07 23:03:03 +0000883 NextInBucket = 0;
Chris Lattner63b570d2005-01-07 07:45:27 +0000884 }
Chris Lattner63b570d2005-01-07 07:45:27 +0000885 SDNode(unsigned NT, SDOperand Op)
Evan Chengb9ee9e62006-07-27 06:38:21 +0000886 : NodeType(NT), NodeId(-1) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000887 OperandList = new SDOperand[1];
888 OperandList[0] = Op;
889 NumOperands = 1;
Chris Lattner63b570d2005-01-07 07:45:27 +0000890 Op.Val->Uses.push_back(this);
Chris Lattnerf71e8432005-11-08 22:06:23 +0000891 ValueList = 0;
892 NumValues = 0;
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000893 Prev = 0; Next = 0;
Chris Lattnera5682852006-08-07 23:03:03 +0000894 NextInBucket = 0;
Chris Lattner63b570d2005-01-07 07:45:27 +0000895 }
896 SDNode(unsigned NT, SDOperand N1, SDOperand N2)
Evan Chengb9ee9e62006-07-27 06:38:21 +0000897 : NodeType(NT), NodeId(-1) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000898 OperandList = new SDOperand[2];
899 OperandList[0] = N1;
900 OperandList[1] = N2;
901 NumOperands = 2;
Chris Lattner63b570d2005-01-07 07:45:27 +0000902 N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this);
Chris Lattnerf71e8432005-11-08 22:06:23 +0000903 ValueList = 0;
904 NumValues = 0;
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000905 Prev = 0; Next = 0;
Chris Lattnera5682852006-08-07 23:03:03 +0000906 NextInBucket = 0;
Chris Lattner63b570d2005-01-07 07:45:27 +0000907 }
908 SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3)
Evan Chengb9ee9e62006-07-27 06:38:21 +0000909 : NodeType(NT), NodeId(-1) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000910 OperandList = new SDOperand[3];
911 OperandList[0] = N1;
912 OperandList[1] = N2;
913 OperandList[2] = N3;
914 NumOperands = 3;
915
Chris Lattner63b570d2005-01-07 07:45:27 +0000916 N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this);
917 N3.Val->Uses.push_back(this);
Chris Lattnerf71e8432005-11-08 22:06:23 +0000918 ValueList = 0;
919 NumValues = 0;
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000920 Prev = 0; Next = 0;
Chris Lattnera5682852006-08-07 23:03:03 +0000921 NextInBucket = 0;
Chris Lattner63b570d2005-01-07 07:45:27 +0000922 }
Andrew Lenharth2d86ea22005-04-27 20:10:01 +0000923 SDNode(unsigned NT, SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4)
Evan Chengb9ee9e62006-07-27 06:38:21 +0000924 : NodeType(NT), NodeId(-1) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000925 OperandList = new SDOperand[4];
926 OperandList[0] = N1;
927 OperandList[1] = N2;
928 OperandList[2] = N3;
929 OperandList[3] = N4;
930 NumOperands = 4;
931
Andrew Lenharth2d86ea22005-04-27 20:10:01 +0000932 N1.Val->Uses.push_back(this); N2.Val->Uses.push_back(this);
933 N3.Val->Uses.push_back(this); N4.Val->Uses.push_back(this);
Chris Lattnerf71e8432005-11-08 22:06:23 +0000934 ValueList = 0;
935 NumValues = 0;
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000936 Prev = 0; Next = 0;
Chris Lattnera5682852006-08-07 23:03:03 +0000937 NextInBucket = 0;
Andrew Lenharth2d86ea22005-04-27 20:10:01 +0000938 }
Chris Lattnerf06f35e2006-08-08 01:09:31 +0000939 SDNode(unsigned Opc, const SDOperand *Ops, unsigned NumOps)
Evan Chengb9ee9e62006-07-27 06:38:21 +0000940 : NodeType(Opc), NodeId(-1) {
Chris Lattnerf06f35e2006-08-08 01:09:31 +0000941 NumOperands = NumOps;
Chris Lattnerf71e8432005-11-08 22:06:23 +0000942 OperandList = new SDOperand[NumOperands];
943
Chris Lattnerf06f35e2006-08-08 01:09:31 +0000944 for (unsigned i = 0, e = NumOps; i != e; ++i) {
945 OperandList[i] = Ops[i];
Chris Lattnerf71e8432005-11-08 22:06:23 +0000946 SDNode *N = OperandList[i].Val;
947 N->Uses.push_back(this);
Chris Lattner0442fbf2005-01-21 21:39:38 +0000948 }
Chris Lattnerf71e8432005-11-08 22:06:23 +0000949 ValueList = 0;
950 NumValues = 0;
Chris Lattnerb80e2be2005-11-09 23:46:43 +0000951 Prev = 0; Next = 0;
Chris Lattnera5682852006-08-07 23:03:03 +0000952 NextInBucket = 0;
Chris Lattnerf71e8432005-11-08 22:06:23 +0000953 }
Chris Lattner63b570d2005-01-07 07:45:27 +0000954
Chris Lattner1b950952005-08-16 18:16:24 +0000955 /// MorphNodeTo - This clears the return value and operands list, and sets the
956 /// opcode of the node to the specified value. This should only be used by
957 /// the SelectionDAG class.
958 void MorphNodeTo(unsigned Opc) {
959 NodeType = Opc;
Chris Lattnerf71e8432005-11-08 22:06:23 +0000960 ValueList = 0;
961 NumValues = 0;
Chris Lattnerb467f8a2005-08-17 01:54:00 +0000962
963 // Clear the operands list, updating used nodes to remove this from their
964 // use list.
Chris Lattnerf71e8432005-11-08 22:06:23 +0000965 for (op_iterator I = op_begin(), E = op_end(); I != E; ++I)
966 I->Val->removeUser(this);
967 delete [] OperandList;
968 OperandList = 0;
969 NumOperands = 0;
Chris Lattner1b950952005-08-16 18:16:24 +0000970 }
971
Chris Lattner0b3e5252006-08-15 19:11:05 +0000972 void setValueTypes(SDVTList L) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000973 assert(NumValues == 0 && "Should not have values yet!");
Chris Lattner0b3e5252006-08-15 19:11:05 +0000974 ValueList = L.VTs;
975 NumValues = L.NumVTs;
Chris Lattner63b570d2005-01-07 07:45:27 +0000976 }
Chris Lattner1b950952005-08-16 18:16:24 +0000977
978 void setOperands(SDOperand Op0) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000979 assert(NumOperands == 0 && "Should not have operands yet!");
980 OperandList = new SDOperand[1];
981 OperandList[0] = Op0;
982 NumOperands = 1;
Chris Lattner8c3484c2005-08-17 18:58:38 +0000983 Op0.Val->Uses.push_back(this);
Chris Lattner1b950952005-08-16 18:16:24 +0000984 }
985 void setOperands(SDOperand Op0, SDOperand Op1) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000986 assert(NumOperands == 0 && "Should not have operands yet!");
987 OperandList = new SDOperand[2];
988 OperandList[0] = Op0;
989 OperandList[1] = Op1;
990 NumOperands = 2;
Chris Lattner8c3484c2005-08-17 18:58:38 +0000991 Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
Chris Lattner1b950952005-08-16 18:16:24 +0000992 }
993 void setOperands(SDOperand Op0, SDOperand Op1, SDOperand Op2) {
Chris Lattnerf71e8432005-11-08 22:06:23 +0000994 assert(NumOperands == 0 && "Should not have operands yet!");
995 OperandList = new SDOperand[3];
996 OperandList[0] = Op0;
997 OperandList[1] = Op1;
998 OperandList[2] = Op2;
999 NumOperands = 3;
Chris Lattner8c3484c2005-08-17 18:58:38 +00001000 Op0.Val->Uses.push_back(this); Op1.Val->Uses.push_back(this);
1001 Op2.Val->Uses.push_back(this);
1002 }
Evan Cheng694481e2006-08-27 08:08:54 +00001003 void setOperands(const SDOperand *Ops, unsigned NumOps) {
Chris Lattnerf71e8432005-11-08 22:06:23 +00001004 assert(NumOperands == 0 && "Should not have operands yet!");
Evan Cheng694481e2006-08-27 08:08:54 +00001005 NumOperands = NumOps;
1006 OperandList = new SDOperand[NumOperands];
1007
1008 for (unsigned i = 0, e = NumOps; i != e; ++i) {
1009 OperandList[i] = Ops[i];
1010 SDNode *N = OperandList[i].Val;
1011 N->Uses.push_back(this);
1012 }
Andrew Lenharth7cf11b42006-01-23 21:51:14 +00001013 }
Andrew Lenharth8c6f1ee2006-01-23 20:59:12 +00001014
Chris Lattner8c3484c2005-08-17 18:58:38 +00001015 void addUser(SDNode *User) {
1016 Uses.push_back(User);
Chris Lattner1b950952005-08-16 18:16:24 +00001017 }
Chris Lattnerd1fc9642005-01-07 21:08:55 +00001018 void removeUser(SDNode *User) {
1019 // Remove this user from the operand's use list.
1020 for (unsigned i = Uses.size(); ; --i) {
1021 assert(i != 0 && "Didn't find user!");
1022 if (Uses[i-1] == User) {
Chris Lattner8c3484c2005-08-17 18:58:38 +00001023 Uses[i-1] = Uses.back();
1024 Uses.pop_back();
1025 return;
Chris Lattnerd1fc9642005-01-07 21:08:55 +00001026 }
1027 }
1028 }
Evan Chengb9ee9e62006-07-27 06:38:21 +00001029
1030 void setNodeId(int Id) {
1031 NodeId = Id;
1032 }
Chris Lattner63b570d2005-01-07 07:45:27 +00001033};
1034
1035
1036// Define inline functions from the SDOperand class.
1037
1038inline unsigned SDOperand::getOpcode() const {
1039 return Val->getOpcode();
1040}
1041inline MVT::ValueType SDOperand::getValueType() const {
1042 return Val->getValueType(ResNo);
1043}
1044inline unsigned SDOperand::getNumOperands() const {
1045 return Val->getNumOperands();
1046}
1047inline const SDOperand &SDOperand::getOperand(unsigned i) const {
1048 return Val->getOperand(i);
1049}
Evan Chengc5484282006-10-04 00:56:09 +00001050inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const {
1051 return Val->getConstantOperandVal(i);
1052}
Nate Begeman0f66a912005-08-17 23:44:54 +00001053inline bool SDOperand::isTargetOpcode() const {
1054 return Val->isTargetOpcode();
1055}
1056inline unsigned SDOperand::getTargetOpcode() const {
1057 return Val->getTargetOpcode();
1058}
Chris Lattnera44f4ae2005-01-13 22:58:50 +00001059inline bool SDOperand::hasOneUse() const {
1060 return Val->hasNUsesOfValue(1, ResNo);
1061}
Chris Lattner63b570d2005-01-07 07:45:27 +00001062
Chris Lattnerd623e952005-10-05 06:34:34 +00001063/// HandleSDNode - This class is used to form a handle around another node that
1064/// is persistant and is updated across invocations of replaceAllUsesWith on its
1065/// operand. This node should be directly created by end-users and not added to
1066/// the AllNodes list.
1067class HandleSDNode : public SDNode {
1068public:
1069 HandleSDNode(SDOperand X) : SDNode(ISD::HANDLENODE, X) {}
1070 ~HandleSDNode() {
1071 MorphNodeTo(ISD::HANDLENODE); // Drops operand uses.
1072 }
1073
1074 SDOperand getValue() const { return getOperand(0); }
1075};
1076
Chris Lattner47725d02005-11-29 06:15:39 +00001077class StringSDNode : public SDNode {
1078 std::string Value;
1079protected:
1080 friend class SelectionDAG;
1081 StringSDNode(const std::string &val)
1082 : SDNode(ISD::STRING, MVT::Other), Value(val) {
1083 }
1084public:
1085 const std::string &getValue() const { return Value; }
1086 static bool classof(const StringSDNode *) { return true; }
1087 static bool classof(const SDNode *N) {
1088 return N->getOpcode() == ISD::STRING;
1089 }
1090};
Chris Lattner63b570d2005-01-07 07:45:27 +00001091
1092class ConstantSDNode : public SDNode {
1093 uint64_t Value;
1094protected:
1095 friend class SelectionDAG;
Chris Lattner056f9f62005-08-17 00:33:30 +00001096 ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT)
1097 : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, VT), Value(val) {
Chris Lattner63b570d2005-01-07 07:45:27 +00001098 }
1099public:
1100
1101 uint64_t getValue() const { return Value; }
1102
1103 int64_t getSignExtended() const {
1104 unsigned Bits = MVT::getSizeInBits(getValueType(0));
Chris Lattnerf26bc8e2005-01-08 19:52:31 +00001105 return ((int64_t)Value << (64-Bits)) >> (64-Bits);
Chris Lattner63b570d2005-01-07 07:45:27 +00001106 }
1107
1108 bool isNullValue() const { return Value == 0; }
1109 bool isAllOnesValue() const {
Chris Lattner885a87e2006-04-02 02:28:52 +00001110 return Value == MVT::getIntVTBitMask(getValueType(0));
Chris Lattner63b570d2005-01-07 07:45:27 +00001111 }
1112
1113 static bool classof(const ConstantSDNode *) { return true; }
1114 static bool classof(const SDNode *N) {
Chris Lattner056f9f62005-08-17 00:33:30 +00001115 return N->getOpcode() == ISD::Constant ||
1116 N->getOpcode() == ISD::TargetConstant;
Chris Lattner63b570d2005-01-07 07:45:27 +00001117 }
1118};
1119
1120class ConstantFPSDNode : public SDNode {
1121 double Value;
1122protected:
1123 friend class SelectionDAG;
Chris Lattnerac0d7232006-01-29 06:24:40 +00001124 ConstantFPSDNode(bool isTarget, double val, MVT::ValueType VT)
1125 : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, VT),
1126 Value(val) {
Chris Lattner63b570d2005-01-07 07:45:27 +00001127 }
1128public:
1129
1130 double getValue() const { return Value; }
1131
1132 /// isExactlyValue - We don't rely on operator== working on double values, as
1133 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1134 /// As such, this method can be used to do an exact bit-for-bit comparison of
1135 /// two floating point values.
Jim Laskey58b968b2005-08-17 20:08:02 +00001136 bool isExactlyValue(double V) const;
Chris Lattner63b570d2005-01-07 07:45:27 +00001137
1138 static bool classof(const ConstantFPSDNode *) { return true; }
1139 static bool classof(const SDNode *N) {
Chris Lattnerac0d7232006-01-29 06:24:40 +00001140 return N->getOpcode() == ISD::ConstantFP ||
1141 N->getOpcode() == ISD::TargetConstantFP;
Chris Lattner63b570d2005-01-07 07:45:27 +00001142 }
1143};
1144
1145class GlobalAddressSDNode : public SDNode {
1146 GlobalValue *TheGlobal;
Evan Cheng404cb4f2006-02-25 09:54:52 +00001147 int Offset;
Chris Lattner63b570d2005-01-07 07:45:27 +00001148protected:
1149 friend class SelectionDAG;
Evan Cheng61ca74b2005-11-30 02:04:11 +00001150 GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
1151 int o=0)
Evan Cheng404cb4f2006-02-25 09:54:52 +00001152 : SDNode(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress, VT),
1153 Offset(o) {
Chris Lattner63b570d2005-01-07 07:45:27 +00001154 TheGlobal = const_cast<GlobalValue*>(GA);
Chris Lattner63b570d2005-01-07 07:45:27 +00001155 }
1156public:
1157
1158 GlobalValue *getGlobal() const { return TheGlobal; }
Evan Cheng404cb4f2006-02-25 09:54:52 +00001159 int getOffset() const { return Offset; }
Chris Lattner63b570d2005-01-07 07:45:27 +00001160
1161 static bool classof(const GlobalAddressSDNode *) { return true; }
1162 static bool classof(const SDNode *N) {
Chris Lattnerf6b18492005-08-19 22:31:34 +00001163 return N->getOpcode() == ISD::GlobalAddress ||
1164 N->getOpcode() == ISD::TargetGlobalAddress;
Chris Lattner63b570d2005-01-07 07:45:27 +00001165 }
1166};
1167
1168
1169class FrameIndexSDNode : public SDNode {
1170 int FI;
1171protected:
1172 friend class SelectionDAG;
Chris Lattnerafb2dd42005-08-25 00:43:01 +00001173 FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
1174 : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, VT), FI(fi) {}
Chris Lattner63b570d2005-01-07 07:45:27 +00001175public:
1176
1177 int getIndex() const { return FI; }
1178
1179 static bool classof(const FrameIndexSDNode *) { return true; }
1180 static bool classof(const SDNode *N) {
Chris Lattnerafb2dd42005-08-25 00:43:01 +00001181 return N->getOpcode() == ISD::FrameIndex ||
1182 N->getOpcode() == ISD::TargetFrameIndex;
Chris Lattner63b570d2005-01-07 07:45:27 +00001183 }
1184};
1185
Nate Begeman37efe672006-04-22 18:53:45 +00001186class JumpTableSDNode : public SDNode {
1187 int JTI;
1188protected:
1189 friend class SelectionDAG;
1190 JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg)
1191 : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, VT),
1192 JTI(jti) {}
1193public:
1194
1195 int getIndex() const { return JTI; }
1196
1197 static bool classof(const JumpTableSDNode *) { return true; }
1198 static bool classof(const SDNode *N) {
1199 return N->getOpcode() == ISD::JumpTable ||
1200 N->getOpcode() == ISD::TargetJumpTable;
1201 }
1202};
1203
Chris Lattner63b570d2005-01-07 07:45:27 +00001204class ConstantPoolSDNode : public SDNode {
Evan Chengd6594ae2006-09-12 21:00:35 +00001205 union {
1206 Constant *ConstVal;
1207 MachineConstantPoolValue *MachineCPVal;
1208 } Val;
Evan Chengbaf45002006-09-14 07:30:48 +00001209 int Offset; // It's a MachineConstantPoolValue if top bit is set.
Evan Chengb8973bd2006-01-31 22:23:14 +00001210 unsigned Alignment;
Chris Lattner63b570d2005-01-07 07:45:27 +00001211protected:
1212 friend class SelectionDAG;
Evan Cheng404cb4f2006-02-25 09:54:52 +00001213 ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT,
1214 int o=0)
Chris Lattneraaaaf792005-08-25 05:02:41 +00001215 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
Evan Chengd6594ae2006-09-12 21:00:35 +00001216 Offset(o), Alignment(0) {
1217 assert((int)Offset >= 0 && "Offset is too large");
1218 Val.ConstVal = c;
1219 }
Evan Cheng404cb4f2006-02-25 09:54:52 +00001220 ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o,
1221 unsigned Align)
Evan Chengb8973bd2006-01-31 22:23:14 +00001222 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
Evan Chengd6594ae2006-09-12 21:00:35 +00001223 Offset(o), Alignment(Align) {
1224 assert((int)Offset >= 0 && "Offset is too large");
1225 Val.ConstVal = c;
1226 }
1227 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1228 MVT::ValueType VT, int o=0)
1229 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
1230 Offset(o), Alignment(0) {
1231 assert((int)Offset >= 0 && "Offset is too large");
1232 Val.MachineCPVal = v;
1233 Offset |= 1 << (sizeof(unsigned)*8-1);
1234 }
1235 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1236 MVT::ValueType VT, int o, unsigned Align)
1237 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, VT),
1238 Offset(o), Alignment(Align) {
1239 assert((int)Offset >= 0 && "Offset is too large");
1240 Val.MachineCPVal = v;
1241 Offset |= 1 << (sizeof(unsigned)*8-1);
1242 }
Chris Lattner63b570d2005-01-07 07:45:27 +00001243public:
1244
Evan Chengd6594ae2006-09-12 21:00:35 +00001245 bool isMachineConstantPoolEntry() const {
1246 return (int)Offset < 0;
1247 }
1248
1249 Constant *getConstVal() const {
1250 assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1251 return Val.ConstVal;
1252 }
1253
1254 MachineConstantPoolValue *getMachineCPVal() const {
1255 assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1256 return Val.MachineCPVal;
1257 }
1258
Evan Chengbaf45002006-09-14 07:30:48 +00001259 int getOffset() const {
1260 return Offset & ~(1 << (sizeof(unsigned)*8-1));
1261 }
Chris Lattneref3640a2006-02-09 02:10:15 +00001262
1263 // Return the alignment of this constant pool object, which is either 0 (for
1264 // default alignment) or log2 of the desired value.
Evan Chengb8973bd2006-01-31 22:23:14 +00001265 unsigned getAlignment() const { return Alignment; }
Chris Lattner63b570d2005-01-07 07:45:27 +00001266
Evan Chengd6594ae2006-09-12 21:00:35 +00001267 const Type *getType() const;
1268
Chris Lattner63b570d2005-01-07 07:45:27 +00001269 static bool classof(const ConstantPoolSDNode *) { return true; }
1270 static bool classof(const SDNode *N) {
Chris Lattneraaaaf792005-08-25 05:02:41 +00001271 return N->getOpcode() == ISD::ConstantPool ||
1272 N->getOpcode() == ISD::TargetConstantPool;
Chris Lattner63b570d2005-01-07 07:45:27 +00001273 }
1274};
1275
1276class BasicBlockSDNode : public SDNode {
1277 MachineBasicBlock *MBB;
1278protected:
1279 friend class SelectionDAG;
1280 BasicBlockSDNode(MachineBasicBlock *mbb)
1281 : SDNode(ISD::BasicBlock, MVT::Other), MBB(mbb) {}
1282public:
1283
1284 MachineBasicBlock *getBasicBlock() const { return MBB; }
1285
1286 static bool classof(const BasicBlockSDNode *) { return true; }
1287 static bool classof(const SDNode *N) {
1288 return N->getOpcode() == ISD::BasicBlock;
1289 }
1290};
1291
Andrew Lenharth2d86ea22005-04-27 20:10:01 +00001292class SrcValueSDNode : public SDNode {
1293 const Value *V;
Andrew Lenharth691ef2b2005-05-03 17:19:30 +00001294 int offset;
Andrew Lenharth2d86ea22005-04-27 20:10:01 +00001295protected:
1296 friend class SelectionDAG;
Andrew Lenharth691ef2b2005-05-03 17:19:30 +00001297 SrcValueSDNode(const Value* v, int o)
1298 : SDNode(ISD::SRCVALUE, MVT::Other), V(v), offset(o) {}
Andrew Lenharth2d86ea22005-04-27 20:10:01 +00001299
1300public:
1301 const Value *getValue() const { return V; }
Andrew Lenharth691ef2b2005-05-03 17:19:30 +00001302 int getOffset() const { return offset; }
Andrew Lenharth2d86ea22005-04-27 20:10:01 +00001303
1304 static bool classof(const SrcValueSDNode *) { return true; }
1305 static bool classof(const SDNode *N) {
1306 return N->getOpcode() == ISD::SRCVALUE;
1307 }
1308};
1309
Chris Lattner63b570d2005-01-07 07:45:27 +00001310
Chris Lattnerd5d0f9b2005-08-16 21:55:35 +00001311class RegisterSDNode : public SDNode {
Chris Lattner63b570d2005-01-07 07:45:27 +00001312 unsigned Reg;
1313protected:
1314 friend class SelectionDAG;
Chris Lattnerd5d0f9b2005-08-16 21:55:35 +00001315 RegisterSDNode(unsigned reg, MVT::ValueType VT)
1316 : SDNode(ISD::Register, VT), Reg(reg) {}
Chris Lattner63b570d2005-01-07 07:45:27 +00001317public:
1318
1319 unsigned getReg() const { return Reg; }
1320
Chris Lattnerd5d0f9b2005-08-16 21:55:35 +00001321 static bool classof(const RegisterSDNode *) { return true; }
Chris Lattner63b570d2005-01-07 07:45:27 +00001322 static bool classof(const SDNode *N) {
Chris Lattnerd5d0f9b2005-08-16 21:55:35 +00001323 return N->getOpcode() == ISD::Register;
Chris Lattner63b570d2005-01-07 07:45:27 +00001324 }
1325};
1326
1327class ExternalSymbolSDNode : public SDNode {
1328 const char *Symbol;
1329protected:
1330 friend class SelectionDAG;
Andrew Lenharth2a2de662005-10-23 03:40:17 +00001331 ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
1332 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, VT),
1333 Symbol(Sym) {
Chris Lattner63b570d2005-01-07 07:45:27 +00001334 }
1335public:
1336
1337 const char *getSymbol() const { return Symbol; }
1338
1339 static bool classof(const ExternalSymbolSDNode *) { return true; }
1340 static bool classof(const SDNode *N) {
Andrew Lenharth2a2de662005-10-23 03:40:17 +00001341 return N->getOpcode() == ISD::ExternalSymbol ||
1342 N->getOpcode() == ISD::TargetExternalSymbol;
Chris Lattner63b570d2005-01-07 07:45:27 +00001343 }
1344};
1345
Chris Lattner7cf7e3f2005-08-09 20:20:18 +00001346class CondCodeSDNode : public SDNode {
Chris Lattner63b570d2005-01-07 07:45:27 +00001347 ISD::CondCode Condition;
1348protected:
1349 friend class SelectionDAG;
Chris Lattner7cf7e3f2005-08-09 20:20:18 +00001350 CondCodeSDNode(ISD::CondCode Cond)
1351 : SDNode(ISD::CONDCODE, MVT::Other), Condition(Cond) {
Chris Lattner63b570d2005-01-07 07:45:27 +00001352 }
1353public:
1354
Chris Lattner7cf7e3f2005-08-09 20:20:18 +00001355 ISD::CondCode get() const { return Condition; }
Chris Lattner63b570d2005-01-07 07:45:27 +00001356
Chris Lattner7cf7e3f2005-08-09 20:20:18 +00001357 static bool classof(const CondCodeSDNode *) { return true; }
Chris Lattner63b570d2005-01-07 07:45:27 +00001358 static bool classof(const SDNode *N) {
Chris Lattner7cf7e3f2005-08-09 20:20:18 +00001359 return N->getOpcode() == ISD::CONDCODE;
Chris Lattner63b570d2005-01-07 07:45:27 +00001360 }
1361};
1362
Chris Lattner15e4b012005-07-10 00:07:11 +00001363/// VTSDNode - This class is used to represent MVT::ValueType's, which are used
1364/// to parameterize some operations.
1365class VTSDNode : public SDNode {
1366 MVT::ValueType ValueType;
1367protected:
1368 friend class SelectionDAG;
1369 VTSDNode(MVT::ValueType VT)
1370 : SDNode(ISD::VALUETYPE, MVT::Other), ValueType(VT) {}
1371public:
1372
1373 MVT::ValueType getVT() const { return ValueType; }
1374
1375 static bool classof(const VTSDNode *) { return true; }
1376 static bool classof(const SDNode *N) {
1377 return N->getOpcode() == ISD::VALUETYPE;
1378 }
1379};
1380
Evan Cheng24446e22006-10-09 20:55:20 +00001381/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
1382///
1383class LoadSDNode : public SDNode {
Evan Cheng81c38452006-10-10 01:44:58 +00001384 // AddrMode - unindexed, pre-indexed, post-indexed.
1385 ISD::MemOpAddrMode AddrMode;
1386
1387 // ExtType - non-ext, anyext, sext, zext.
1388 ISD::LoadExtType ExtType;
1389
Evan Cheng2e49f092006-10-11 07:10:22 +00001390 // LoadedVT - VT of loaded value before extension.
1391 MVT::ValueType LoadedVT;
Evan Cheng81c38452006-10-10 01:44:58 +00001392
1393 // SrcValue - Memory location for alias analysis.
Evan Cheng24446e22006-10-09 20:55:20 +00001394 const Value *SrcValue;
Evan Cheng81c38452006-10-10 01:44:58 +00001395
1396 // SVOffset - Memory location offset.
Evan Cheng24446e22006-10-09 20:55:20 +00001397 int SVOffset;
Evan Cheng81c38452006-10-10 01:44:58 +00001398
1399 // Alignment - Alignment of memory location in bytes.
Evan Cheng24446e22006-10-09 20:55:20 +00001400 unsigned Alignment;
Evan Cheng81c38452006-10-10 01:44:58 +00001401
1402 // IsVolatile - True if the load is volatile.
Evan Cheng24446e22006-10-09 20:55:20 +00001403 bool IsVolatile;
1404protected:
1405 friend class SelectionDAG;
1406 LoadSDNode(SDOperand Chain, SDOperand Ptr, SDOperand Off,
1407 ISD::MemOpAddrMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
1408 const Value *SV, int O=0, unsigned Align=1, bool Vol=false)
1409 : SDNode(ISD::LOAD, Chain, Ptr, Off),
Evan Cheng2e49f092006-10-11 07:10:22 +00001410 AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O),
Evan Cheng24446e22006-10-09 20:55:20 +00001411 Alignment(Align), IsVolatile(Vol) {
Evan Cheng8862ef12006-10-26 21:52:24 +00001412 assert((Off.getOpcode() == ISD::UNDEF || AddrMode != ISD::UNINDEXED) &&
1413 "Only indexed load has a non-undef offset operand");
Evan Cheng24446e22006-10-09 20:55:20 +00001414 }
Evan Cheng24446e22006-10-09 20:55:20 +00001415public:
1416
Evan Cheng81c38452006-10-10 01:44:58 +00001417 const SDOperand getChain() const { return getOperand(0); }
1418 const SDOperand getBasePtr() const { return getOperand(1); }
1419 const SDOperand getOffset() const { return getOperand(2); }
Evan Cheng24446e22006-10-09 20:55:20 +00001420 ISD::MemOpAddrMode getAddressingMode() const { return AddrMode; }
1421 ISD::LoadExtType getExtensionType() const { return ExtType; }
Evan Cheng2e49f092006-10-11 07:10:22 +00001422 MVT::ValueType getLoadedVT() const { return LoadedVT; }
Evan Cheng24446e22006-10-09 20:55:20 +00001423 const Value *getSrcValue() const { return SrcValue; }
1424 int getSrcValueOffset() const { return SVOffset; }
1425 unsigned getAlignment() const { return Alignment; }
1426 bool isVolatile() const { return IsVolatile; }
1427
1428 static bool classof(const LoadSDNode *) { return true; }
1429 static bool classof(const SDNode *N) {
1430 return N->getOpcode() == ISD::LOAD;
1431 }
1432};
1433
1434/// StoreSDNode - This class is used to represent ISD::STORE nodes.
1435///
1436class StoreSDNode : public SDNode {
Evan Cheng81c38452006-10-10 01:44:58 +00001437 // AddrMode - unindexed, pre-indexed, post-indexed.
1438 ISD::MemOpAddrMode AddrMode;
1439
1440 // IsTruncStore - True is the op does a truncation before store.
1441 bool IsTruncStore;
1442
Evan Cheng2e49f092006-10-11 07:10:22 +00001443 // StoredVT - VT of the value after truncation.
Evan Cheng81c38452006-10-10 01:44:58 +00001444 MVT::ValueType StoredVT;
1445
1446 // SrcValue - Memory location for alias analysis.
Evan Cheng24446e22006-10-09 20:55:20 +00001447 const Value *SrcValue;
Evan Cheng81c38452006-10-10 01:44:58 +00001448
1449 // SVOffset - Memory location offset.
Evan Cheng24446e22006-10-09 20:55:20 +00001450 int SVOffset;
Evan Cheng81c38452006-10-10 01:44:58 +00001451
1452 // Alignment - Alignment of memory location in bytes.
Evan Cheng24446e22006-10-09 20:55:20 +00001453 unsigned Alignment;
Evan Cheng81c38452006-10-10 01:44:58 +00001454
1455 // IsVolatile - True if the store is volatile.
Evan Cheng24446e22006-10-09 20:55:20 +00001456 bool IsVolatile;
1457protected:
1458 friend class SelectionDAG;
Evan Cheng8b2794a2006-10-13 21:14:26 +00001459 StoreSDNode(SDOperand Chain, SDOperand Value, SDOperand Ptr, SDOperand Off,
Evan Cheng24446e22006-10-09 20:55:20 +00001460 ISD::MemOpAddrMode AM, bool isTrunc, MVT::ValueType SVT,
1461 const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
Evan Cheng8b2794a2006-10-13 21:14:26 +00001462 : SDNode(ISD::STORE, Chain, Value, Ptr, Off),
Evan Cheng24446e22006-10-09 20:55:20 +00001463 AddrMode(AM), IsTruncStore(isTrunc), StoredVT(SVT), SrcValue(SV),
1464 SVOffset(O), Alignment(Align), IsVolatile(Vol) {
Evan Cheng8862ef12006-10-26 21:52:24 +00001465 assert((Off.getOpcode() == ISD::UNDEF || AddrMode != ISD::UNINDEXED) &&
1466 "Only indexed store has a non-undef offset operand");
Evan Cheng24446e22006-10-09 20:55:20 +00001467 }
1468public:
1469
Evan Cheng81c38452006-10-10 01:44:58 +00001470 const SDOperand getChain() const { return getOperand(0); }
Evan Cheng8b2794a2006-10-13 21:14:26 +00001471 const SDOperand getValue() const { return getOperand(1); }
1472 const SDOperand getBasePtr() const { return getOperand(2); }
1473 const SDOperand getOffset() const { return getOperand(3); }
Evan Cheng24446e22006-10-09 20:55:20 +00001474 ISD::MemOpAddrMode getAddressingMode() const { return AddrMode; }
1475 bool isTruncatingStore() const { return IsTruncStore; }
1476 MVT::ValueType getStoredVT() const { return StoredVT; }
1477 const Value *getSrcValue() const { return SrcValue; }
1478 int getSrcValueOffset() const { return SVOffset; }
1479 unsigned getAlignment() const { return Alignment; }
1480 bool isVolatile() const { return IsVolatile; }
1481
1482 static bool classof(const LoadSDNode *) { return true; }
1483 static bool classof(const SDNode *N) {
1484 return N->getOpcode() == ISD::STORE;
1485 }
1486};
1487
Chris Lattner15e4b012005-07-10 00:07:11 +00001488
Chris Lattner1080b9e2005-01-10 23:05:53 +00001489class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
1490 SDNode *Node;
1491 unsigned Operand;
Misha Brukmanea61c352005-04-21 20:39:54 +00001492
Chris Lattner1080b9e2005-01-10 23:05:53 +00001493 SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
1494public:
1495 bool operator==(const SDNodeIterator& x) const {
1496 return Operand == x.Operand;
1497 }
1498 bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
1499
1500 const SDNodeIterator &operator=(const SDNodeIterator &I) {
1501 assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
1502 Operand = I.Operand;
1503 return *this;
1504 }
Misha Brukmanea61c352005-04-21 20:39:54 +00001505
Chris Lattner1080b9e2005-01-10 23:05:53 +00001506 pointer operator*() const {
1507 return Node->getOperand(Operand).Val;
1508 }
1509 pointer operator->() const { return operator*(); }
Misha Brukmanea61c352005-04-21 20:39:54 +00001510
Chris Lattner1080b9e2005-01-10 23:05:53 +00001511 SDNodeIterator& operator++() { // Preincrement
1512 ++Operand;
1513 return *this;
1514 }
1515 SDNodeIterator operator++(int) { // Postincrement
Misha Brukmanea61c352005-04-21 20:39:54 +00001516 SDNodeIterator tmp = *this; ++*this; return tmp;
Chris Lattner1080b9e2005-01-10 23:05:53 +00001517 }
1518
1519 static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
1520 static SDNodeIterator end (SDNode *N) {
1521 return SDNodeIterator(N, N->getNumOperands());
1522 }
1523
1524 unsigned getOperand() const { return Operand; }
1525 const SDNode *getNode() const { return Node; }
1526};
1527
1528template <> struct GraphTraits<SDNode*> {
1529 typedef SDNode NodeType;
1530 typedef SDNodeIterator ChildIteratorType;
1531 static inline NodeType *getEntryNode(SDNode *N) { return N; }
Misha Brukmanea61c352005-04-21 20:39:54 +00001532 static inline ChildIteratorType child_begin(NodeType *N) {
Chris Lattner1080b9e2005-01-10 23:05:53 +00001533 return SDNodeIterator::begin(N);
1534 }
Misha Brukmanea61c352005-04-21 20:39:54 +00001535 static inline ChildIteratorType child_end(NodeType *N) {
Chris Lattner1080b9e2005-01-10 23:05:53 +00001536 return SDNodeIterator::end(N);
1537 }
1538};
1539
Chris Lattnerb80e2be2005-11-09 23:46:43 +00001540template<>
1541struct ilist_traits<SDNode> {
1542 static SDNode *getPrev(const SDNode *N) { return N->Prev; }
1543 static SDNode *getNext(const SDNode *N) { return N->Next; }
1544
1545 static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; }
1546 static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; }
1547
1548 static SDNode *createSentinel() {
1549 return new SDNode(ISD::EntryToken, MVT::Other);
1550 }
1551 static void destroySentinel(SDNode *N) { delete N; }
1552 //static SDNode *createNode(const SDNode &V) { return new SDNode(V); }
1553
1554
1555 void addNodeToList(SDNode *NTy) {}
1556 void removeNodeFromList(SDNode *NTy) {}
1557 void transferNodesFromList(iplist<SDNode, ilist_traits> &L2,
1558 const ilist_iterator<SDNode> &X,
1559 const ilist_iterator<SDNode> &Y) {}
1560};
1561
Evan Chengc5484282006-10-04 00:56:09 +00001562namespace ISD {
Evan Cheng24446e22006-10-09 20:55:20 +00001563 /// isNON_EXTLoad - Returns true if the specified node is a non-extending
1564 /// load.
1565 inline bool isNON_EXTLoad(const SDNode *N) {
1566 return N->getOpcode() == ISD::LOAD &&
1567 cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
1568 }
1569
Evan Chengc5484282006-10-04 00:56:09 +00001570 /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
1571 ///
1572 inline bool isEXTLoad(const SDNode *N) {
Evan Cheng24446e22006-10-09 20:55:20 +00001573 return N->getOpcode() == ISD::LOAD &&
1574 cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
Evan Chengc5484282006-10-04 00:56:09 +00001575 }
1576
1577 /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
1578 ///
1579 inline bool isSEXTLoad(const SDNode *N) {
Evan Cheng24446e22006-10-09 20:55:20 +00001580 return N->getOpcode() == ISD::LOAD &&
1581 cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
Evan Chengc5484282006-10-04 00:56:09 +00001582 }
1583
1584 /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
1585 ///
1586 inline bool isZEXTLoad(const SDNode *N) {
Evan Cheng24446e22006-10-09 20:55:20 +00001587 return N->getOpcode() == ISD::LOAD &&
1588 cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
Evan Chengc5484282006-10-04 00:56:09 +00001589 }
Evan Cheng8b2794a2006-10-13 21:14:26 +00001590
1591 /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
1592 /// store.
1593 inline bool isNON_TRUNCStore(const SDNode *N) {
1594 return N->getOpcode() == ISD::STORE &&
1595 !cast<StoreSDNode>(N)->isTruncatingStore();
1596 }
1597
1598 /// isTRUNCStore - Returns true if the specified node is a truncating
1599 /// store.
1600 inline bool isTRUNCStore(const SDNode *N) {
1601 return N->getOpcode() == ISD::STORE &&
1602 cast<StoreSDNode>(N)->isTruncatingStore();
1603 }
Evan Chengc5484282006-10-04 00:56:09 +00001604}
1605
1606
Chris Lattner63b570d2005-01-07 07:45:27 +00001607} // end llvm namespace
1608
1609#endif