SelectionDAGNodes.h revision 0fe9c6e7babb3c0731d9cb864ec498ec4184760f
1//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file declares the SDNode class and derived classes, which are used to 11// represent the nodes and operations present in a SelectionDAG. These nodes 12// and operations are machine code level operations, with some similarities to 13// the GCC RTL representation. 14// 15// Clients should include the SelectionDAG.h file instead of this file directly. 16// 17//===----------------------------------------------------------------------===// 18 19#ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H 20#define LLVM_CODEGEN_SELECTIONDAGNODES_H 21 22#include "llvm/Value.h" 23#include "llvm/ADT/FoldingSet.h" 24#include "llvm/ADT/GraphTraits.h" 25#include "llvm/ADT/iterator.h" 26#include "llvm/ADT/APFloat.h" 27#include "llvm/ADT/APInt.h" 28#include "llvm/CodeGen/ValueTypes.h" 29#include "llvm/CodeGen/MachineMemOperand.h" 30#include "llvm/Support/DataTypes.h" 31#include <cassert> 32 33namespace llvm { 34 35class SelectionDAG; 36class GlobalValue; 37class MachineBasicBlock; 38class MachineConstantPoolValue; 39class SDNode; 40class CompileUnitDesc; 41template <typename T> struct DenseMapInfo; 42template <typename T> struct simplify_type; 43template <typename T> struct ilist_traits; 44template<typename NodeTy, typename Traits> class iplist; 45template<typename NodeTy> class ilist_iterator; 46 47/// SDVTList - This represents a list of ValueType's that has been intern'd by 48/// a SelectionDAG. Instances of this simple value class are returned by 49/// SelectionDAG::getVTList(...). 50/// 51struct SDVTList { 52 const MVT *VTs; 53 unsigned short NumVTs; 54}; 55 56/// ISD namespace - This namespace contains an enum which represents all of the 57/// SelectionDAG node types and value types. 58/// 59namespace ISD { 60 61 //===--------------------------------------------------------------------===// 62 /// ISD::NodeType enum - This enum defines all of the operators valid in a 63 /// SelectionDAG. 64 /// 65 enum NodeType { 66 // DELETED_NODE - This is an illegal flag value that is used to catch 67 // errors. This opcode is not a legal opcode for any node. 68 DELETED_NODE, 69 70 // EntryToken - This is the marker used to indicate the start of the region. 71 EntryToken, 72 73 // Token factor - This node takes multiple tokens as input and produces a 74 // single token result. This is used to represent the fact that the operand 75 // operators are independent of each other. 76 TokenFactor, 77 78 // AssertSext, AssertZext - These nodes record if a register contains a 79 // value that has already been zero or sign extended from a narrower type. 80 // These nodes take two operands. The first is the node that has already 81 // been extended, and the second is a value type node indicating the width 82 // of the extension 83 AssertSext, AssertZext, 84 85 // Various leaf nodes. 86 BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register, 87 Constant, ConstantFP, 88 GlobalAddress, GlobalTLSAddress, FrameIndex, 89 JumpTable, ConstantPool, ExternalSymbol, 90 91 // The address of the GOT 92 GLOBAL_OFFSET_TABLE, 93 94 // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and 95 // llvm.returnaddress on the DAG. These nodes take one operand, the index 96 // of the frame or return address to return. An index of zero corresponds 97 // to the current function's frame or return address, an index of one to the 98 // parent's frame or return address, and so on. 99 FRAMEADDR, RETURNADDR, 100 101 // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to 102 // first (possible) on-stack argument. This is needed for correct stack 103 // adjustment during unwind. 104 FRAME_TO_ARGS_OFFSET, 105 106 // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the 107 // address of the exception block on entry to an landing pad block. 108 EXCEPTIONADDR, 109 110 // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents 111 // the selection index of the exception thrown. 112 EHSELECTION, 113 114 // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 115 // 'eh_return' gcc dwarf builtin, which is used to return from 116 // exception. The general meaning is: adjust stack by OFFSET and pass 117 // execution to HANDLER. Many platform-related details also :) 118 EH_RETURN, 119 120 // TargetConstant* - Like Constant*, but the DAG does not do any folding or 121 // simplification of the constant. 122 TargetConstant, 123 TargetConstantFP, 124 125 // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or 126 // anything else with this node, and this is valid in the target-specific 127 // dag, turning into a GlobalAddress operand. 128 TargetGlobalAddress, 129 TargetGlobalTLSAddress, 130 TargetFrameIndex, 131 TargetJumpTable, 132 TargetConstantPool, 133 TargetExternalSymbol, 134 135 /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) 136 /// This node represents a target intrinsic function with no side effects. 137 /// The first operand is the ID number of the intrinsic from the 138 /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The 139 /// node has returns the result of the intrinsic. 140 INTRINSIC_WO_CHAIN, 141 142 /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) 143 /// This node represents a target intrinsic function with side effects that 144 /// returns a result. The first operand is a chain pointer. The second is 145 /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The 146 /// operands to the intrinsic follow. The node has two results, the result 147 /// of the intrinsic and an output chain. 148 INTRINSIC_W_CHAIN, 149 150 /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) 151 /// This node represents a target intrinsic function with side effects that 152 /// does not return a result. The first operand is a chain pointer. The 153 /// second is the ID number of the intrinsic from the llvm::Intrinsic 154 /// namespace. The operands to the intrinsic follow. 155 INTRINSIC_VOID, 156 157 // CopyToReg - This node has three operands: a chain, a register number to 158 // set to this value, and a value. 159 CopyToReg, 160 161 // CopyFromReg - This node indicates that the input value is a virtual or 162 // physical register that is defined outside of the scope of this 163 // SelectionDAG. The register is available from the RegisterSDNode object. 164 CopyFromReg, 165 166 // UNDEF - An undefined node 167 UNDEF, 168 169 /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node 170 /// represents the formal arguments for a function. CC# is a Constant value 171 /// indicating the calling convention of the function, and ISVARARG is a 172 /// flag that indicates whether the function is varargs or not. This node 173 /// has one result value for each incoming argument, plus one for the output 174 /// chain. It must be custom legalized. See description of CALL node for 175 /// FLAG argument contents explanation. 176 /// 177 FORMAL_ARGUMENTS, 178 179 /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE, 180 /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn) 181 /// This node represents a fully general function call, before the legalizer 182 /// runs. This has one result value for each argument / flag pair, plus 183 /// a chain result. It must be custom legalized. Flag argument indicates 184 /// misc. argument attributes. Currently: 185 /// Bit 0 - signness 186 /// Bit 1 - 'inreg' attribute 187 /// Bit 2 - 'sret' attribute 188 /// Bit 4 - 'byval' attribute 189 /// Bit 5 - 'nest' attribute 190 /// Bit 6-9 - alignment of byval structures 191 /// Bit 10-26 - size of byval structures 192 /// Bits 31:27 - argument ABI alignment in the first argument piece and 193 /// alignment '1' in other argument pieces. 194 CALL, 195 196 // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by 197 // a Constant, which is required to be operand #1) half of the integer or 198 // float value specified as operand #0. This is only for use before 199 // legalization, for values that will be broken into multiple registers. 200 EXTRACT_ELEMENT, 201 202 // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given 203 // two values of the same integer value type, this produces a value twice as 204 // big. Like EXTRACT_ELEMENT, this can only be used before legalization. 205 BUILD_PAIR, 206 207 // MERGE_VALUES - This node takes multiple discrete operands and returns 208 // them all as its individual results. This nodes has exactly the same 209 // number of inputs and outputs, and is only valid before legalization. 210 // This node is useful for some pieces of the code generator that want to 211 // think about a single node with multiple results, not multiple nodes. 212 MERGE_VALUES, 213 214 // Simple integer binary arithmetic operators. 215 ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, 216 217 // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing 218 // a signed/unsigned value of type i[2*N], and return the full value as 219 // two results, each of type iN. 220 SMUL_LOHI, UMUL_LOHI, 221 222 // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and 223 // remainder result. 224 SDIVREM, UDIVREM, 225 226 // CARRY_FALSE - This node is used when folding other nodes, 227 // like ADDC/SUBC, which indicate the carry result is always false. 228 CARRY_FALSE, 229 230 // Carry-setting nodes for multiple precision addition and subtraction. 231 // These nodes take two operands of the same value type, and produce two 232 // results. The first result is the normal add or sub result, the second 233 // result is the carry flag result. 234 ADDC, SUBC, 235 236 // Carry-using nodes for multiple precision addition and subtraction. These 237 // nodes take three operands: The first two are the normal lhs and rhs to 238 // the add or sub, and the third is the input carry flag. These nodes 239 // produce two results; the normal result of the add or sub, and the output 240 // carry flag. These nodes both read and write a carry flag to allow them 241 // to them to be chained together for add and sub of arbitrarily large 242 // values. 243 ADDE, SUBE, 244 245 // Simple binary floating point operators. 246 FADD, FSUB, FMUL, FDIV, FREM, 247 248 // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This 249 // DAG node does not require that X and Y have the same type, just that they 250 // are both floating point. X and the result must have the same type. 251 // FCOPYSIGN(f32, f64) is allowed. 252 FCOPYSIGN, 253 254 // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point 255 // value as an integer 0/1 value. 256 FGETSIGN, 257 258 /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector 259 /// with the specified, possibly variable, elements. The number of elements 260 /// is required to be a power of two. 261 BUILD_VECTOR, 262 263 /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element 264 /// at IDX replaced with VAL. If the type of VAL is larger than the vector 265 /// element type then VAL is truncated before replacement. 266 INSERT_VECTOR_ELT, 267 268 /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR 269 /// identified by the (potentially variable) element number IDX. 270 EXTRACT_VECTOR_ELT, 271 272 /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of 273 /// vector type with the same length and element type, this produces a 274 /// concatenated vector result value, with length equal to the sum of the 275 /// lengths of the input vectors. 276 CONCAT_VECTORS, 277 278 /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an 279 /// vector value) starting with the (potentially variable) element number 280 /// IDX, which must be a multiple of the result vector length. 281 EXTRACT_SUBVECTOR, 282 283 /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same 284 /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values 285 /// (maybe of an illegal datatype) or undef that indicate which value each 286 /// result element will get. The elements of VEC1/VEC2 are enumerated in 287 /// order. This is quite similar to the Altivec 'vperm' instruction, except 288 /// that the indices must be constants and are in terms of the element size 289 /// of VEC1/VEC2, not in terms of bytes. 290 VECTOR_SHUFFLE, 291 292 /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a 293 /// scalar value into element 0 of the resultant vector type. The top 294 /// elements 1 to N-1 of the N-element vector are undefined. 295 SCALAR_TO_VECTOR, 296 297 // EXTRACT_SUBREG - This node is used to extract a sub-register value. 298 // This node takes a superreg and a constant sub-register index as operands. 299 // Note sub-register indices must be increasing. That is, if the 300 // sub-register index of a 8-bit sub-register is N, then the index for a 301 // 16-bit sub-register must be at least N+1. 302 EXTRACT_SUBREG, 303 304 // INSERT_SUBREG - This node is used to insert a sub-register value. 305 // This node takes a superreg, a subreg value, and a constant sub-register 306 // index as operands. 307 INSERT_SUBREG, 308 309 // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing 310 // an unsigned/signed value of type i[2*N], then return the top part. 311 MULHU, MULHS, 312 313 // Bitwise operators - logical and, logical or, logical xor, shift left, 314 // shift right algebraic (shift in sign bits), shift right logical (shift in 315 // zeroes), rotate left, rotate right, and byteswap. 316 AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP, 317 318 // Counting operators 319 CTTZ, CTLZ, CTPOP, 320 321 // Select(COND, TRUEVAL, FALSEVAL) 322 SELECT, 323 324 // Select with condition operator - This selects between a true value and 325 // a false value (ops #2 and #3) based on the boolean result of comparing 326 // the lhs and rhs (ops #0 and #1) of a conditional expression with the 327 // condition code in op #4, a CondCodeSDNode. 328 SELECT_CC, 329 330 // SetCC operator - This evaluates to a boolean (i1) true value if the 331 // condition is true. The operands to this are the left and right operands 332 // to compare (ops #0, and #1) and the condition code to compare them with 333 // (op #2) as a CondCodeSDNode. 334 SETCC, 335 336 // Vector SetCC operator - This evaluates to a vector of integer elements 337 // with the high bit in each element set to true if the comparison is true 338 // and false if the comparison is false. All other bits in each element 339 // are undefined. The operands to this are the left and right operands 340 // to compare (ops #0, and #1) and the condition code to compare them with 341 // (op #2) as a CondCodeSDNode. 342 VSETCC, 343 344 // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded 345 // integer shift operations, just like ADD/SUB_PARTS. The operation 346 // ordering is: 347 // [Lo,Hi] = op [LoLHS,HiLHS], Amt 348 SHL_PARTS, SRA_PARTS, SRL_PARTS, 349 350 // Conversion operators. These are all single input single output 351 // operations. For all of these, the result type must be strictly 352 // wider or narrower (depending on the operation) than the source 353 // type. 354 355 // SIGN_EXTEND - Used for integer types, replicating the sign bit 356 // into new bits. 357 SIGN_EXTEND, 358 359 // ZERO_EXTEND - Used for integer types, zeroing the new bits. 360 ZERO_EXTEND, 361 362 // ANY_EXTEND - Used for integer types. The high bits are undefined. 363 ANY_EXTEND, 364 365 // TRUNCATE - Completely drop the high bits. 366 TRUNCATE, 367 368 // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign 369 // depends on the first letter) to floating point. 370 SINT_TO_FP, 371 UINT_TO_FP, 372 373 // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to 374 // sign extend a small value in a large integer register (e.g. sign 375 // extending the low 8 bits of a 32-bit register to fill the top 24 bits 376 // with the 7th bit). The size of the smaller type is indicated by the 1th 377 // operand, a ValueType node. 378 SIGN_EXTEND_INREG, 379 380 /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned 381 /// integer. 382 FP_TO_SINT, 383 FP_TO_UINT, 384 385 /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type 386 /// down to the precision of the destination VT. TRUNC is a flag, which is 387 /// always an integer that is zero or one. If TRUNC is 0, this is a 388 /// normal rounding, if it is 1, this FP_ROUND is known to not change the 389 /// value of Y. 390 /// 391 /// The TRUNC = 1 case is used in cases where we know that the value will 392 /// not be modified by the node, because Y is not using any of the extra 393 /// precision of source type. This allows certain transformations like 394 /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for 395 /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed. 396 FP_ROUND, 397 398 // FLT_ROUNDS_ - Returns current rounding mode: 399 // -1 Undefined 400 // 0 Round to 0 401 // 1 Round to nearest 402 // 2 Round to +inf 403 // 3 Round to -inf 404 FLT_ROUNDS_, 405 406 /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and 407 /// rounds it to a floating point value. It then promotes it and returns it 408 /// in a register of the same size. This operation effectively just 409 /// discards excess precision. The type to round down to is specified by 410 /// the VT operand, a VTSDNode. 411 FP_ROUND_INREG, 412 413 /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type. 414 FP_EXTEND, 415 416 // BIT_CONVERT - Theis operator converts between integer and FP values, as 417 // if one was stored to memory as integer and the other was loaded from the 418 // same address (or equivalently for vector format conversions, etc). The 419 // source and result are required to have the same bit size (e.g. 420 // f32 <-> i32). This can also be used for int-to-int or fp-to-fp 421 // conversions, but that is a noop, deleted by getNode(). 422 BIT_CONVERT, 423 424 // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW - Perform unary floating point 425 // negation, absolute value, square root, sine and cosine, powi, and pow 426 // operations. 427 FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, 428 429 // LOAD and STORE have token chains as their first operand, then the same 430 // operands as an LLVM load/store instruction, then an offset node that 431 // is added / subtracted from the base pointer to form the address (for 432 // indexed memory ops). 433 LOAD, STORE, 434 435 // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned 436 // to a specified boundary. This node always has two return values: a new 437 // stack pointer value and a chain. The first operand is the token chain, 438 // the second is the number of bytes to allocate, and the third is the 439 // alignment boundary. The size is guaranteed to be a multiple of the stack 440 // alignment, and the alignment is guaranteed to be bigger than the stack 441 // alignment (if required) or 0 to get standard stack alignment. 442 DYNAMIC_STACKALLOC, 443 444 // Control flow instructions. These all have token chains. 445 446 // BR - Unconditional branch. The first operand is the chain 447 // operand, the second is the MBB to branch to. 448 BR, 449 450 // BRIND - Indirect branch. The first operand is the chain, the second 451 // is the value to branch to, which must be of the same type as the target's 452 // pointer type. 453 BRIND, 454 455 // BR_JT - Jumptable branch. The first operand is the chain, the second 456 // is the jumptable index, the last one is the jumptable entry index. 457 BR_JT, 458 459 // BRCOND - Conditional branch. The first operand is the chain, 460 // the second is the condition, the third is the block to branch 461 // to if the condition is true. 462 BRCOND, 463 464 // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in 465 // that the condition is represented as condition code, and two nodes to 466 // compare, rather than as a combined SetCC node. The operands in order are 467 // chain, cc, lhs, rhs, block to branch to if condition is true. 468 BR_CC, 469 470 // RET - Return from function. The first operand is the chain, 471 // and any subsequent operands are pairs of return value and return value 472 // signness for the function. This operation can have variable number of 473 // operands. 474 RET, 475 476 // INLINEASM - Represents an inline asm block. This node always has two 477 // return values: a chain and a flag result. The inputs are as follows: 478 // Operand #0 : Input chain. 479 // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string. 480 // Operand #2n+2: A RegisterNode. 481 // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def 482 // Operand #last: Optional, an incoming flag. 483 INLINEASM, 484 485 // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track 486 // locations needed for debug and exception handling tables. These nodes 487 // take a chain as input and return a chain. 488 DBG_LABEL, 489 EH_LABEL, 490 491 // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track 492 // local variable declarations for debugging information. First operand is 493 // a chain, while the next two operands are first two arguments (address 494 // and variable) of a llvm.dbg.declare instruction. 495 DECLARE, 496 497 // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a 498 // value, the same type as the pointer type for the system, and an output 499 // chain. 500 STACKSAVE, 501 502 // STACKRESTORE has two operands, an input chain and a pointer to restore to 503 // it returns an output chain. 504 STACKRESTORE, 505 506 // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of 507 // a call sequence, and carry arbitrary information that target might want 508 // to know. The first operand is a chain, the rest are specified by the 509 // target and not touched by the DAG optimizers. 510 // CALLSEQ_START..CALLSEQ_END pairs may not be nested. 511 CALLSEQ_START, // Beginning of a call sequence 512 CALLSEQ_END, // End of a call sequence 513 514 // VAARG - VAARG has three operands: an input chain, a pointer, and a 515 // SRCVALUE. It returns a pair of values: the vaarg value and a new chain. 516 VAARG, 517 518 // VACOPY - VACOPY has five operands: an input chain, a destination pointer, 519 // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the 520 // source. 521 VACOPY, 522 523 // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a 524 // pointer, and a SRCVALUE. 525 VAEND, VASTART, 526 527 // SRCVALUE - This is a node type that holds a Value* that is used to 528 // make reference to a value in the LLVM IR. 529 SRCVALUE, 530 531 // MEMOPERAND - This is a node that contains a MachineMemOperand which 532 // records information about a memory reference. This is used to make 533 // AliasAnalysis queries from the backend. 534 MEMOPERAND, 535 536 // PCMARKER - This corresponds to the pcmarker intrinsic. 537 PCMARKER, 538 539 // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic. 540 // The only operand is a chain and a value and a chain are produced. The 541 // value is the contents of the architecture specific cycle counter like 542 // register (or other high accuracy low latency clock source) 543 READCYCLECOUNTER, 544 545 // HANDLENODE node - Used as a handle for various purposes. 546 HANDLENODE, 547 548 // DBG_STOPPOINT - This node is used to represent a source location for 549 // debug info. It takes token chain as input, and carries a line number, 550 // column number, and a pointer to a CompileUnitDesc object identifying 551 // the containing compilation unit. It produces a token chain as output. 552 DBG_STOPPOINT, 553 554 // DEBUG_LOC - This node is used to represent source line information 555 // embedded in the code. It takes a token chain as input, then a line 556 // number, then a column then a file id (provided by MachineModuleInfo.) It 557 // produces a token chain as output. 558 DEBUG_LOC, 559 560 // TRAMPOLINE - This corresponds to the init_trampoline intrinsic. 561 // It takes as input a token chain, the pointer to the trampoline, 562 // the pointer to the nested function, the pointer to pass for the 563 // 'nest' parameter, a SRCVALUE for the trampoline and another for 564 // the nested function (allowing targets to access the original 565 // Function*). It produces the result of the intrinsic and a token 566 // chain as output. 567 TRAMPOLINE, 568 569 // TRAP - Trapping instruction 570 TRAP, 571 572 // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are 573 // their first operand. The other operands are the address to prefetch, 574 // read / write specifier, and locality specifier. 575 PREFETCH, 576 577 // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load, 578 // store-store, device) 579 // This corresponds to the memory.barrier intrinsic. 580 // it takes an input chain, 4 operands to specify the type of barrier, an 581 // operand specifying if the barrier applies to device and uncached memory 582 // and produces an output chain. 583 MEMBARRIER, 584 585 // Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) 586 // this corresponds to the atomic.lcs intrinsic. 587 // cmp is compared to *ptr, and if equal, swap is stored in *ptr. 588 // the return is always the original value in *ptr 589 ATOMIC_CMP_SWAP, 590 591 // Val, OUTCHAIN = ATOMIC_LOAD_ADD(INCHAIN, ptr, amt) 592 // this corresponds to the atomic.las intrinsic. 593 // *ptr + amt is stored to *ptr atomically. 594 // the return is always the original value in *ptr 595 ATOMIC_LOAD_ADD, 596 597 // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) 598 // this corresponds to the atomic.swap intrinsic. 599 // amt is stored to *ptr atomically. 600 // the return is always the original value in *ptr 601 ATOMIC_SWAP, 602 603 // Val, OUTCHAIN = ATOMIC_LOAD_SUB(INCHAIN, ptr, amt) 604 // this corresponds to the atomic.lss intrinsic. 605 // *ptr - amt is stored to *ptr atomically. 606 // the return is always the original value in *ptr 607 ATOMIC_LOAD_SUB, 608 609 // Val, OUTCHAIN = ATOMIC_L[OpName]S(INCHAIN, ptr, amt) 610 // this corresponds to the atomic.[OpName] intrinsic. 611 // op(*ptr, amt) is stored to *ptr atomically. 612 // the return is always the original value in *ptr 613 ATOMIC_LOAD_AND, 614 ATOMIC_LOAD_OR, 615 ATOMIC_LOAD_XOR, 616 ATOMIC_LOAD_NAND, 617 ATOMIC_LOAD_MIN, 618 ATOMIC_LOAD_MAX, 619 ATOMIC_LOAD_UMIN, 620 ATOMIC_LOAD_UMAX, 621 622 // BUILTIN_OP_END - This must be the last enum value in this list. 623 BUILTIN_OP_END 624 }; 625 626 /// Node predicates 627 628 /// isBuildVectorAllOnes - Return true if the specified node is a 629 /// BUILD_VECTOR where all of the elements are ~0 or undef. 630 bool isBuildVectorAllOnes(const SDNode *N); 631 632 /// isBuildVectorAllZeros - Return true if the specified node is a 633 /// BUILD_VECTOR where all of the elements are 0 or undef. 634 bool isBuildVectorAllZeros(const SDNode *N); 635 636 /// isScalarToVector - Return true if the specified node is a 637 /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low 638 /// element is not an undef. 639 bool isScalarToVector(const SDNode *N); 640 641 /// isDebugLabel - Return true if the specified node represents a debug 642 /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node). 643 bool isDebugLabel(const SDNode *N); 644 645 //===--------------------------------------------------------------------===// 646 /// MemIndexedMode enum - This enum defines the load / store indexed 647 /// addressing modes. 648 /// 649 /// UNINDEXED "Normal" load / store. The effective address is already 650 /// computed and is available in the base pointer. The offset 651 /// operand is always undefined. In addition to producing a 652 /// chain, an unindexed load produces one value (result of the 653 /// load); an unindexed store does not produce a value. 654 /// 655 /// PRE_INC Similar to the unindexed mode where the effective address is 656 /// PRE_DEC the value of the base pointer add / subtract the offset. 657 /// It considers the computation as being folded into the load / 658 /// store operation (i.e. the load / store does the address 659 /// computation as well as performing the memory transaction). 660 /// The base operand is always undefined. In addition to 661 /// producing a chain, pre-indexed load produces two values 662 /// (result of the load and the result of the address 663 /// computation); a pre-indexed store produces one value (result 664 /// of the address computation). 665 /// 666 /// POST_INC The effective address is the value of the base pointer. The 667 /// POST_DEC value of the offset operand is then added to / subtracted 668 /// from the base after memory transaction. In addition to 669 /// producing a chain, post-indexed load produces two values 670 /// (the result of the load and the result of the base +/- offset 671 /// computation); a post-indexed store produces one value (the 672 /// the result of the base +/- offset computation). 673 /// 674 enum MemIndexedMode { 675 UNINDEXED = 0, 676 PRE_INC, 677 PRE_DEC, 678 POST_INC, 679 POST_DEC, 680 LAST_INDEXED_MODE 681 }; 682 683 //===--------------------------------------------------------------------===// 684 /// LoadExtType enum - This enum defines the three variants of LOADEXT 685 /// (load with extension). 686 /// 687 /// SEXTLOAD loads the integer operand and sign extends it to a larger 688 /// integer result type. 689 /// ZEXTLOAD loads the integer operand and zero extends it to a larger 690 /// integer result type. 691 /// EXTLOAD is used for three things: floating point extending loads, 692 /// integer extending loads [the top bits are undefined], and vector 693 /// extending loads [load into low elt]. 694 /// 695 enum LoadExtType { 696 NON_EXTLOAD = 0, 697 EXTLOAD, 698 SEXTLOAD, 699 ZEXTLOAD, 700 LAST_LOADX_TYPE 701 }; 702 703 //===--------------------------------------------------------------------===// 704 /// ISD::CondCode enum - These are ordered carefully to make the bitfields 705 /// below work out, when considering SETFALSE (something that never exists 706 /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered 707 /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal 708 /// to. If the "N" column is 1, the result of the comparison is undefined if 709 /// the input is a NAN. 710 /// 711 /// All of these (except for the 'always folded ops') should be handled for 712 /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT, 713 /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used. 714 /// 715 /// Note that these are laid out in a specific order to allow bit-twiddling 716 /// to transform conditions. 717 enum CondCode { 718 // Opcode N U L G E Intuitive operation 719 SETFALSE, // 0 0 0 0 Always false (always folded) 720 SETOEQ, // 0 0 0 1 True if ordered and equal 721 SETOGT, // 0 0 1 0 True if ordered and greater than 722 SETOGE, // 0 0 1 1 True if ordered and greater than or equal 723 SETOLT, // 0 1 0 0 True if ordered and less than 724 SETOLE, // 0 1 0 1 True if ordered and less than or equal 725 SETONE, // 0 1 1 0 True if ordered and operands are unequal 726 SETO, // 0 1 1 1 True if ordered (no nans) 727 SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 728 SETUEQ, // 1 0 0 1 True if unordered or equal 729 SETUGT, // 1 0 1 0 True if unordered or greater than 730 SETUGE, // 1 0 1 1 True if unordered, greater than, or equal 731 SETULT, // 1 1 0 0 True if unordered or less than 732 SETULE, // 1 1 0 1 True if unordered, less than, or equal 733 SETUNE, // 1 1 1 0 True if unordered or not equal 734 SETTRUE, // 1 1 1 1 Always true (always folded) 735 // Don't care operations: undefined if the input is a nan. 736 SETFALSE2, // 1 X 0 0 0 Always false (always folded) 737 SETEQ, // 1 X 0 0 1 True if equal 738 SETGT, // 1 X 0 1 0 True if greater than 739 SETGE, // 1 X 0 1 1 True if greater than or equal 740 SETLT, // 1 X 1 0 0 True if less than 741 SETLE, // 1 X 1 0 1 True if less than or equal 742 SETNE, // 1 X 1 1 0 True if not equal 743 SETTRUE2, // 1 X 1 1 1 Always true (always folded) 744 745 SETCC_INVALID // Marker value. 746 }; 747 748 /// isSignedIntSetCC - Return true if this is a setcc instruction that 749 /// performs a signed comparison when used with integer operands. 750 inline bool isSignedIntSetCC(CondCode Code) { 751 return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE; 752 } 753 754 /// isUnsignedIntSetCC - Return true if this is a setcc instruction that 755 /// performs an unsigned comparison when used with integer operands. 756 inline bool isUnsignedIntSetCC(CondCode Code) { 757 return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE; 758 } 759 760 /// isTrueWhenEqual - Return true if the specified condition returns true if 761 /// the two operands to the condition are equal. Note that if one of the two 762 /// operands is a NaN, this value is meaningless. 763 inline bool isTrueWhenEqual(CondCode Cond) { 764 return ((int)Cond & 1) != 0; 765 } 766 767 /// getUnorderedFlavor - This function returns 0 if the condition is always 768 /// false if an operand is a NaN, 1 if the condition is always true if the 769 /// operand is a NaN, and 2 if the condition is undefined if the operand is a 770 /// NaN. 771 inline unsigned getUnorderedFlavor(CondCode Cond) { 772 return ((int)Cond >> 3) & 3; 773 } 774 775 /// getSetCCInverse - Return the operation corresponding to !(X op Y), where 776 /// 'op' is a valid SetCC operation. 777 CondCode getSetCCInverse(CondCode Operation, bool isInteger); 778 779 /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) 780 /// when given the operation for (X op Y). 781 CondCode getSetCCSwappedOperands(CondCode Operation); 782 783 /// getSetCCOrOperation - Return the result of a logical OR between different 784 /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This 785 /// function returns SETCC_INVALID if it is not possible to represent the 786 /// resultant comparison. 787 CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger); 788 789 /// getSetCCAndOperation - Return the result of a logical AND between 790 /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This 791 /// function returns SETCC_INVALID if it is not possible to represent the 792 /// resultant comparison. 793 CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger); 794} // end llvm::ISD namespace 795 796 797//===----------------------------------------------------------------------===// 798/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple 799/// values as the result of a computation. Many nodes return multiple values, 800/// from loads (which define a token and a return value) to ADDC (which returns 801/// a result and a carry value), to calls (which may return an arbitrary number 802/// of values). 803/// 804/// As such, each use of a SelectionDAG computation must indicate the node that 805/// computes it as well as which return value to use from that node. This pair 806/// of information is represented with the SDOperand value type. 807/// 808class SDOperand { 809public: 810 SDNode *Val; // The node defining the value we are using. 811 unsigned ResNo; // Which return value of the node we are using. 812 813 SDOperand() : Val(0), ResNo(0) {} 814 SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} 815 816 bool operator==(const SDOperand &O) const { 817 return Val == O.Val && ResNo == O.ResNo; 818 } 819 bool operator!=(const SDOperand &O) const { 820 return !operator==(O); 821 } 822 bool operator<(const SDOperand &O) const { 823 return Val < O.Val || (Val == O.Val && ResNo < O.ResNo); 824 } 825 826 SDOperand getValue(unsigned R) const { 827 return SDOperand(Val, R); 828 } 829 830 // isOperandOf - Return true if this node is an operand of N. 831 bool isOperandOf(SDNode *N) const; 832 833 /// getValueType - Return the ValueType of the referenced return value. 834 /// 835 inline MVT getValueType() const; 836 837 /// getValueSizeInBits - Returns the size of the value in bits. 838 /// 839 unsigned getValueSizeInBits() const { 840 return getValueType().getSizeInBits(); 841 } 842 843 // Forwarding methods - These forward to the corresponding methods in SDNode. 844 inline unsigned getOpcode() const; 845 inline unsigned getNumOperands() const; 846 inline const SDOperand &getOperand(unsigned i) const; 847 inline uint64_t getConstantOperandVal(unsigned i) const; 848 inline bool isTargetOpcode() const; 849 inline unsigned getTargetOpcode() const; 850 851 852 /// reachesChainWithoutSideEffects - Return true if this operand (which must 853 /// be a chain) reaches the specified operand without crossing any 854 /// side-effecting instructions. In practice, this looks through token 855 /// factors and non-volatile loads. In order to remain efficient, this only 856 /// looks a couple of nodes in, it does not do an exhaustive search. 857 bool reachesChainWithoutSideEffects(SDOperand Dest, 858 unsigned Depth = 2) const; 859 860 /// hasOneUse - Return true if there is exactly one operation using this 861 /// result value of the defining operator. 862 inline bool hasOneUse() const; 863 864 /// use_empty - Return true if there are no operations using this 865 /// result value of the defining operator. 866 inline bool use_empty() const; 867}; 868 869 870template<> struct DenseMapInfo<SDOperand> { 871 static inline SDOperand getEmptyKey() { 872 return SDOperand((SDNode*)-1, -1U); 873 } 874 static inline SDOperand getTombstoneKey() { 875 return SDOperand((SDNode*)-1, 0); 876 } 877 static unsigned getHashValue(const SDOperand &Val) { 878 return ((unsigned)((uintptr_t)Val.Val >> 4) ^ 879 (unsigned)((uintptr_t)Val.Val >> 9)) + Val.ResNo; 880 } 881 static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) { 882 return LHS == RHS; 883 } 884 static bool isPod() { return true; } 885}; 886 887/// simplify_type specializations - Allow casting operators to work directly on 888/// SDOperands as if they were SDNode*'s. 889template<> struct simplify_type<SDOperand> { 890 typedef SDNode* SimpleType; 891 static SimpleType getSimplifiedValue(const SDOperand &Val) { 892 return static_cast<SimpleType>(Val.Val); 893 } 894}; 895template<> struct simplify_type<const SDOperand> { 896 typedef SDNode* SimpleType; 897 static SimpleType getSimplifiedValue(const SDOperand &Val) { 898 return static_cast<SimpleType>(Val.Val); 899 } 900}; 901 902/// SDUse - Represents a use of the SDNode referred by 903/// the SDOperand. 904class SDUse { 905 SDOperand Operand; 906 /// User - Parent node of this operand. 907 SDNode *User; 908 /// Prev, next - Pointers to the uses list of the SDNode referred by 909 /// this operand. 910 SDUse **Prev, *Next; 911public: 912 friend class SDNode; 913 SDUse(): Operand(), User(NULL), Prev(NULL), Next(NULL) {} 914 915 SDUse(SDNode *val, unsigned resno) : 916 Operand(val,resno), User(NULL), Prev(NULL), Next(NULL) {} 917 918 SDUse& operator= (const SDOperand& Op) { 919 Operand = Op; 920 Next = NULL; 921 Prev = NULL; 922 return *this; 923 } 924 925 SDUse& operator= (const SDUse& Op) { 926 Operand = Op; 927 Next = NULL; 928 Prev = NULL; 929 return *this; 930 } 931 932 SDUse * getNext() { return Next; } 933 934 SDNode *getUser() { return User; } 935 936 void setUser(SDNode *p) { User = p; } 937 938 operator SDOperand() const { return Operand; } 939 940 const SDOperand& getSDOperand() const { return Operand; } 941 942 SDNode* &getVal () { return Operand.Val; } 943 944 bool operator==(const SDOperand &O) const { 945 return Operand == O; 946 } 947 948 bool operator!=(const SDOperand &O) const { 949 return !(Operand == O); 950 } 951 952 bool operator<(const SDOperand &O) const { 953 return Operand < O; 954 } 955 956protected: 957 void addToList(SDUse **List) { 958 Next = *List; 959 if (Next) Next->Prev = &Next; 960 Prev = List; 961 *List = this; 962 } 963 964 void removeFromList() { 965 *Prev = Next; 966 if (Next) Next->Prev = Prev; 967 } 968}; 969 970 971/// simplify_type specializations - Allow casting operators to work directly on 972/// SDOperands as if they were SDNode*'s. 973template<> struct simplify_type<SDUse> { 974 typedef SDNode* SimpleType; 975 static SimpleType getSimplifiedValue(const SDUse &Val) { 976 return static_cast<SimpleType>(Val.getSDOperand().Val); 977 } 978}; 979template<> struct simplify_type<const SDUse> { 980 typedef SDNode* SimpleType; 981 static SimpleType getSimplifiedValue(const SDUse &Val) { 982 return static_cast<SimpleType>(Val.getSDOperand().Val); 983 } 984}; 985 986 987/// SDOperandPtr - A helper SDOperand pointer class, that can handle 988/// arrays of SDUse and arrays of SDOperand objects. This is required 989/// in many places inside the SelectionDAG. 990/// 991class SDOperandPtr { 992 const SDOperand *ptr; // The pointer to the SDOperand object 993 int object_size; // The size of the object containg the SDOperand 994public: 995 SDOperandPtr() : ptr(0), object_size(0) {} 996 997 SDOperandPtr(SDUse * use_ptr) { 998 ptr = &use_ptr->getSDOperand(); 999 object_size = (int)sizeof(SDUse); 1000 } 1001 1002 SDOperandPtr(const SDOperand * op_ptr) { 1003 ptr = op_ptr; 1004 object_size = (int)sizeof(SDOperand); 1005 } 1006 1007 const SDOperand operator *() { return *ptr; } 1008 const SDOperand *operator ->() { return ptr; } 1009 SDOperandPtr operator ++ () { 1010 ptr = (SDOperand*)((char *)ptr + object_size); 1011 return *this; 1012 } 1013 1014 SDOperandPtr operator ++ (int) { 1015 SDOperandPtr tmp = *this; 1016 ptr = (SDOperand*)((char *)ptr + object_size); 1017 return tmp; 1018 } 1019 1020 SDOperand operator[] (int idx) const { 1021 return *(SDOperand*)((char*) ptr + object_size * idx); 1022 } 1023}; 1024 1025/// SDNode - Represents one node in the SelectionDAG. 1026/// 1027class SDNode : public FoldingSetNode { 1028private: 1029 /// NodeType - The operation that this node performs. 1030 /// 1031 unsigned short NodeType; 1032 1033 /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true, 1034 /// then they will be delete[]'d when the node is destroyed. 1035 bool OperandsNeedDelete : 1; 1036 1037 /// NodeId - Unique id per SDNode in the DAG. 1038 int NodeId; 1039 1040 /// OperandList - The values that are used by this operation. 1041 /// 1042 SDUse *OperandList; 1043 1044 /// ValueList - The types of the values this node defines. SDNode's may 1045 /// define multiple values simultaneously. 1046 const MVT *ValueList; 1047 1048 /// NumOperands/NumValues - The number of entries in the Operand/Value list. 1049 unsigned short NumOperands, NumValues; 1050 1051 /// UsesSize - The size of the uses list. 1052 unsigned UsesSize; 1053 1054 /// Uses - List of uses for this SDNode. 1055 SDUse *Uses; 1056 1057 /// Prev/Next pointers - These pointers form the linked list of of the 1058 /// AllNodes list in the current DAG. 1059 SDNode *Prev, *Next; 1060 friend struct ilist_traits<SDNode>; 1061 1062 /// addUse - add SDUse to the list of uses. 1063 void addUse(SDUse &U) { U.addToList(&Uses); } 1064 1065 // Out-of-line virtual method to give class a home. 1066 virtual void ANCHOR(); 1067public: 1068 virtual ~SDNode() { 1069 assert(NumOperands == 0 && "Operand list not cleared before deletion"); 1070 NodeType = ISD::DELETED_NODE; 1071 } 1072 1073 //===--------------------------------------------------------------------===// 1074 // Accessors 1075 // 1076 unsigned getOpcode() const { return NodeType; } 1077 bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } 1078 unsigned getTargetOpcode() const { 1079 assert(isTargetOpcode() && "Not a target opcode!"); 1080 return NodeType - ISD::BUILTIN_OP_END; 1081 } 1082 1083 size_t use_size() const { return UsesSize; } 1084 bool use_empty() const { return Uses == NULL; } 1085 bool hasOneUse() const { return use_size() == 1; } 1086 1087 /// getNodeId - Return the unique node id. 1088 /// 1089 int getNodeId() const { return NodeId; } 1090 1091 /// setNodeId - Set unique node id. 1092 void setNodeId(int Id) { NodeId = Id; } 1093 1094 /// use_iterator - This class provides iterator support for SDUse 1095 /// operands that use a specific SDNode. 1096 class use_iterator 1097 : public forward_iterator<SDUse, ptrdiff_t> { 1098 SDUse *Op; 1099 explicit use_iterator(SDUse *op) : Op(op) { 1100 } 1101 friend class SDNode; 1102 public: 1103 typedef forward_iterator<SDUse, ptrdiff_t>::reference reference; 1104 typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer; 1105 1106 use_iterator(const use_iterator &I) : Op(I.Op) {} 1107 use_iterator() : Op(0) {} 1108 1109 bool operator==(const use_iterator &x) const { 1110 return Op == x.Op; 1111 } 1112 bool operator!=(const use_iterator &x) const { 1113 return !operator==(x); 1114 } 1115 1116 /// atEnd - return true if this iterator is at the end of uses list. 1117 bool atEnd() const { return Op == 0; } 1118 1119 // Iterator traversal: forward iteration only. 1120 use_iterator &operator++() { // Preincrement 1121 assert(Op && "Cannot increment end iterator!"); 1122 Op = Op->getNext(); 1123 return *this; 1124 } 1125 1126 use_iterator operator++(int) { // Postincrement 1127 use_iterator tmp = *this; ++*this; return tmp; 1128 } 1129 1130 1131 /// getOperandNum - Retrive a number of a current operand. 1132 unsigned getOperandNum() const { 1133 assert(Op && "Cannot dereference end iterator!"); 1134 return (unsigned)(Op - Op->getUser()->OperandList); 1135 } 1136 1137 /// Retrieve a reference to the current operand. 1138 SDUse &operator*() const { 1139 assert(Op && "Cannot dereference end iterator!"); 1140 return *Op; 1141 } 1142 1143 /// Retrieve a pointer to the current operand. 1144 SDUse *operator->() const { 1145 assert(Op && "Cannot dereference end iterator!"); 1146 return Op; 1147 } 1148 }; 1149 1150 /// use_begin/use_end - Provide iteration support to walk over all uses 1151 /// of an SDNode. 1152 1153 use_iterator use_begin(SDNode *node) const { 1154 return use_iterator(node->Uses); 1155 } 1156 1157 use_iterator use_begin() const { 1158 return use_iterator(Uses); 1159 } 1160 1161 static use_iterator use_end() { return use_iterator(0); } 1162 1163 1164 /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the 1165 /// indicated value. This method ignores uses of other values defined by this 1166 /// operation. 1167 bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; 1168 1169 /// hasAnyUseOfValue - Return true if there are any use of the indicated 1170 /// value. This method ignores uses of other values defined by this operation. 1171 bool hasAnyUseOfValue(unsigned Value) const; 1172 1173 /// isOnlyUseOf - Return true if this node is the only use of N. 1174 /// 1175 bool isOnlyUseOf(SDNode *N) const; 1176 1177 /// isOperandOf - Return true if this node is an operand of N. 1178 /// 1179 bool isOperandOf(SDNode *N) const; 1180 1181 /// isPredecessorOf - Return true if this node is a predecessor of N. This 1182 /// node is either an operand of N or it can be reached by recursively 1183 /// traversing up the operands. 1184 /// NOTE: this is an expensive method. Use it carefully. 1185 bool isPredecessorOf(SDNode *N) const; 1186 1187 /// getNumOperands - Return the number of values used by this operation. 1188 /// 1189 unsigned getNumOperands() const { return NumOperands; } 1190 1191 /// getConstantOperandVal - Helper method returns the integer value of a 1192 /// ConstantSDNode operand. 1193 uint64_t getConstantOperandVal(unsigned Num) const; 1194 1195 const SDOperand &getOperand(unsigned Num) const { 1196 assert(Num < NumOperands && "Invalid child # of SDNode!"); 1197 return OperandList[Num].getSDOperand(); 1198 } 1199 1200 typedef SDUse* op_iterator; 1201 op_iterator op_begin() const { return OperandList; } 1202 op_iterator op_end() const { return OperandList+NumOperands; } 1203 1204 1205 SDVTList getVTList() const { 1206 SDVTList X = { ValueList, NumValues }; 1207 return X; 1208 }; 1209 1210 /// getNumValues - Return the number of values defined/returned by this 1211 /// operator. 1212 /// 1213 unsigned getNumValues() const { return NumValues; } 1214 1215 /// getValueType - Return the type of a specified result. 1216 /// 1217 MVT getValueType(unsigned ResNo) const { 1218 assert(ResNo < NumValues && "Illegal result number!"); 1219 return ValueList[ResNo]; 1220 } 1221 1222 /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)). 1223 /// 1224 unsigned getValueSizeInBits(unsigned ResNo) const { 1225 return getValueType(ResNo).getSizeInBits(); 1226 } 1227 1228 typedef const MVT* value_iterator; 1229 value_iterator value_begin() const { return ValueList; } 1230 value_iterator value_end() const { return ValueList+NumValues; } 1231 1232 /// getOperationName - Return the opcode of this operation for printing. 1233 /// 1234 std::string getOperationName(const SelectionDAG *G = 0) const; 1235 static const char* getIndexedModeName(ISD::MemIndexedMode AM); 1236 void dump() const; 1237 void dump(const SelectionDAG *G) const; 1238 1239 static bool classof(const SDNode *) { return true; } 1240 1241 /// Profile - Gather unique data for the node. 1242 /// 1243 void Profile(FoldingSetNodeID &ID); 1244 1245protected: 1246 friend class SelectionDAG; 1247 1248 /// getValueTypeList - Return a pointer to the specified value type. 1249 /// 1250 static const MVT *getValueTypeList(MVT VT); 1251 static SDVTList getSDVTList(MVT VT) { 1252 SDVTList Ret = { getValueTypeList(VT), 1 }; 1253 return Ret; 1254 } 1255 1256 SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps) 1257 : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { 1258 OperandsNeedDelete = true; 1259 NumOperands = NumOps; 1260 OperandList = NumOps ? new SDUse[NumOperands] : 0; 1261 1262 for (unsigned i = 0; i != NumOps; ++i) { 1263 OperandList[i] = Ops[i]; 1264 OperandList[i].setUser(this); 1265 Ops[i].Val->addUse(OperandList[i]); 1266 ++Ops[i].Val->UsesSize; 1267 } 1268 1269 ValueList = VTs.VTs; 1270 NumValues = VTs.NumVTs; 1271 Prev = 0; Next = 0; 1272 } 1273 1274 SDNode(unsigned Opc, SDVTList VTs, const SDUse *Ops, unsigned NumOps) 1275 : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { 1276 OperandsNeedDelete = true; 1277 NumOperands = NumOps; 1278 OperandList = NumOps ? new SDUse[NumOperands] : 0; 1279 1280 for (unsigned i = 0; i != NumOps; ++i) { 1281 OperandList[i] = Ops[i]; 1282 OperandList[i].setUser(this); 1283 Ops[i].getSDOperand().Val->addUse(OperandList[i]); 1284 ++Ops[i].getSDOperand().Val->UsesSize; 1285 } 1286 1287 ValueList = VTs.VTs; 1288 NumValues = VTs.NumVTs; 1289 Prev = 0; Next = 0; 1290 } 1291 1292 SDNode(unsigned Opc, SDVTList VTs) 1293 : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { 1294 OperandsNeedDelete = false; // Operands set with InitOperands. 1295 NumOperands = 0; 1296 OperandList = 0; 1297 ValueList = VTs.VTs; 1298 NumValues = VTs.NumVTs; 1299 Prev = 0; Next = 0; 1300 } 1301 1302 /// InitOperands - Initialize the operands list of this node with the 1303 /// specified values, which are part of the node (thus they don't need to be 1304 /// copied in or allocated). 1305 void InitOperands(SDUse *Ops, unsigned NumOps) { 1306 assert(OperandList == 0 && "Operands already set!"); 1307 NumOperands = NumOps; 1308 OperandList = Ops; 1309 UsesSize = 0; 1310 Uses = NULL; 1311 1312 for (unsigned i = 0; i != NumOps; ++i) { 1313 OperandList[i].setUser(this); 1314 Ops[i].getVal()->addUse(OperandList[i]); 1315 ++Ops[i].getVal()->UsesSize; 1316 } 1317 } 1318 1319 /// DropOperands - Release the operands and set this node to have 1320 /// zero operands. This should only be used by HandleSDNode to clear 1321 /// its operand list. 1322 void DropOperands(); 1323 1324 /// MorphNodeTo - This frees the operands of the current node, resets the 1325 /// opcode, types, and operands to the specified value. This should only be 1326 /// used by the SelectionDAG class. 1327 void MorphNodeTo(unsigned Opc, SDVTList L, 1328 const SDOperand *Ops, unsigned NumOps, 1329 SmallVectorImpl<SDNode *> &DeadNodes); 1330 1331 void addUser(unsigned i, SDNode *User) { 1332 assert(User->OperandList[i].getUser() && "Node without parent"); 1333 addUse(User->OperandList[i]); 1334 ++UsesSize; 1335 } 1336 1337 void removeUser(unsigned i, SDNode *User) { 1338 assert(User->OperandList[i].getUser() && "Node without parent"); 1339 SDUse &Op = User->OperandList[i]; 1340 Op.removeFromList(); 1341 --UsesSize; 1342 } 1343}; 1344 1345 1346// Define inline functions from the SDOperand class. 1347 1348inline unsigned SDOperand::getOpcode() const { 1349 return Val->getOpcode(); 1350} 1351inline MVT SDOperand::getValueType() const { 1352 return Val->getValueType(ResNo); 1353} 1354inline unsigned SDOperand::getNumOperands() const { 1355 return Val->getNumOperands(); 1356} 1357inline const SDOperand &SDOperand::getOperand(unsigned i) const { 1358 return Val->getOperand(i); 1359} 1360inline uint64_t SDOperand::getConstantOperandVal(unsigned i) const { 1361 return Val->getConstantOperandVal(i); 1362} 1363inline bool SDOperand::isTargetOpcode() const { 1364 return Val->isTargetOpcode(); 1365} 1366inline unsigned SDOperand::getTargetOpcode() const { 1367 return Val->getTargetOpcode(); 1368} 1369inline bool SDOperand::hasOneUse() const { 1370 return Val->hasNUsesOfValue(1, ResNo); 1371} 1372inline bool SDOperand::use_empty() const { 1373 return !Val->hasAnyUseOfValue(ResNo); 1374} 1375 1376/// UnarySDNode - This class is used for single-operand SDNodes. This is solely 1377/// to allow co-allocation of node operands with the node itself. 1378class UnarySDNode : public SDNode { 1379 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1380 SDUse Op; 1381public: 1382 UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X) 1383 : SDNode(Opc, VTs) { 1384 Op = X; 1385 InitOperands(&Op, 1); 1386 } 1387}; 1388 1389/// BinarySDNode - This class is used for two-operand SDNodes. This is solely 1390/// to allow co-allocation of node operands with the node itself. 1391class BinarySDNode : public SDNode { 1392 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1393 SDUse Ops[2]; 1394public: 1395 BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y) 1396 : SDNode(Opc, VTs) { 1397 Ops[0] = X; 1398 Ops[1] = Y; 1399 InitOperands(Ops, 2); 1400 } 1401}; 1402 1403/// TernarySDNode - This class is used for three-operand SDNodes. This is solely 1404/// to allow co-allocation of node operands with the node itself. 1405class TernarySDNode : public SDNode { 1406 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1407 SDUse Ops[3]; 1408public: 1409 TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y, 1410 SDOperand Z) 1411 : SDNode(Opc, VTs) { 1412 Ops[0] = X; 1413 Ops[1] = Y; 1414 Ops[2] = Z; 1415 InitOperands(Ops, 3); 1416 } 1417}; 1418 1419 1420/// HandleSDNode - This class is used to form a handle around another node that 1421/// is persistant and is updated across invocations of replaceAllUsesWith on its 1422/// operand. This node should be directly created by end-users and not added to 1423/// the AllNodes list. 1424class HandleSDNode : public SDNode { 1425 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1426 SDUse Op; 1427public: 1428 // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is 1429 // fixed. 1430#ifdef __GNUC__ 1431 explicit __attribute__((__noinline__)) HandleSDNode(SDOperand X) 1432#else 1433 explicit HandleSDNode(SDOperand X) 1434#endif 1435 : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) { 1436 Op = X; 1437 InitOperands(&Op, 1); 1438 } 1439 ~HandleSDNode(); 1440 SDUse getValue() const { return Op; } 1441}; 1442 1443/// Abstact virtual class for operations for memory operations 1444class MemSDNode : public SDNode { 1445 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1446 1447private: 1448 //! SrcValue - Memory location for alias analysis. 1449 const Value *SrcValue; 1450 1451 //! Alignment - Alignment of memory location in bytes. 1452 unsigned Alignment; 1453 1454public: 1455 MemSDNode(unsigned Opc, SDVTList VTs, const Value *srcValue, 1456 unsigned alignment) 1457 : SDNode(Opc, VTs), SrcValue(srcValue), Alignment(alignment) {} 1458 1459 virtual ~MemSDNode() {} 1460 1461 /// Returns alignment and volatility of the memory access 1462 unsigned getAlignment() const { return Alignment; } 1463 virtual bool isVolatile() const = 0; 1464 1465 /// Returns the SrcValue and offset that describes the location of the access 1466 const Value *getSrcValue() const { return SrcValue; } 1467 virtual int getSrcValueOffset() const = 0; 1468 1469 /// getMemOperand - Return a MachineMemOperand object describing the memory 1470 /// reference performed by operation. 1471 virtual MachineMemOperand getMemOperand() const = 0; 1472 1473 // Methods to support isa and dyn_cast 1474 static bool classof(const MemSDNode *) { return true; } 1475 static bool classof(const SDNode *N) { 1476 return N->getOpcode() == ISD::LOAD || 1477 N->getOpcode() == ISD::STORE || 1478 N->getOpcode() == ISD::ATOMIC_CMP_SWAP || 1479 N->getOpcode() == ISD::ATOMIC_LOAD_ADD || 1480 N->getOpcode() == ISD::ATOMIC_SWAP || 1481 N->getOpcode() == ISD::ATOMIC_LOAD_SUB || 1482 N->getOpcode() == ISD::ATOMIC_LOAD_AND || 1483 N->getOpcode() == ISD::ATOMIC_LOAD_OR || 1484 N->getOpcode() == ISD::ATOMIC_LOAD_XOR || 1485 N->getOpcode() == ISD::ATOMIC_LOAD_NAND || 1486 N->getOpcode() == ISD::ATOMIC_LOAD_MIN || 1487 N->getOpcode() == ISD::ATOMIC_LOAD_MAX || 1488 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || 1489 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX; 1490 } 1491}; 1492 1493/// Atomic operations node 1494class AtomicSDNode : public MemSDNode { 1495 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1496 SDUse Ops[4]; 1497 1498 public: 1499 // Opc: opcode for atomic 1500 // VTL: value type list 1501 // Chain: memory chain for operaand 1502 // Ptr: address to update as a SDOperand 1503 // Cmp: compare value 1504 // Swp: swap value 1505 // SrcVal: address to update as a Value (used for MemOperand) 1506 // Align: alignment of memory 1507 AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, 1508 SDOperand Cmp, SDOperand Swp, const Value* SrcVal, 1509 unsigned Align=0) 1510 : MemSDNode(Opc, VTL, SrcVal, Align) { 1511 Ops[0] = Chain; 1512 Ops[1] = Ptr; 1513 Ops[2] = Swp; 1514 Ops[3] = Cmp; 1515 InitOperands(Ops, 4); 1516 } 1517 AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, 1518 SDOperand Val, const Value* SrcVal, unsigned Align=0) 1519 : MemSDNode(Opc, VTL, SrcVal, Align) { 1520 Ops[0] = Chain; 1521 Ops[1] = Ptr; 1522 Ops[2] = Val; 1523 InitOperands(Ops, 3); 1524 } 1525 1526 const SDOperand &getChain() const { return getOperand(0); } 1527 const SDOperand &getBasePtr() const { return getOperand(1); } 1528 const SDOperand &getVal() const { return getOperand(2); } 1529 1530 bool isCompareAndSwap() const { return getOpcode() == ISD::ATOMIC_CMP_SWAP; } 1531 1532 // Implementation for MemSDNode 1533 virtual int getSrcValueOffset() const { return 0; } 1534 virtual bool isVolatile() const { return true; } 1535 1536 /// getMemOperand - Return a MachineMemOperand object describing the memory 1537 /// reference performed by this atomic load/store. 1538 virtual MachineMemOperand getMemOperand() const; 1539 1540 // Methods to support isa and dyn_cast 1541 static bool classof(const AtomicSDNode *) { return true; } 1542 static bool classof(const SDNode *N) { 1543 return N->getOpcode() == ISD::ATOMIC_CMP_SWAP || 1544 N->getOpcode() == ISD::ATOMIC_LOAD_ADD || 1545 N->getOpcode() == ISD::ATOMIC_SWAP || 1546 N->getOpcode() == ISD::ATOMIC_LOAD_SUB || 1547 N->getOpcode() == ISD::ATOMIC_LOAD_AND || 1548 N->getOpcode() == ISD::ATOMIC_LOAD_OR || 1549 N->getOpcode() == ISD::ATOMIC_LOAD_XOR || 1550 N->getOpcode() == ISD::ATOMIC_LOAD_NAND || 1551 N->getOpcode() == ISD::ATOMIC_LOAD_MIN || 1552 N->getOpcode() == ISD::ATOMIC_LOAD_MAX || 1553 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || 1554 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX; 1555 } 1556}; 1557 1558class ConstantSDNode : public SDNode { 1559 APInt Value; 1560 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1561protected: 1562 friend class SelectionDAG; 1563 ConstantSDNode(bool isTarget, const APInt &val, MVT VT) 1564 : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)), 1565 Value(val) { 1566 } 1567public: 1568 1569 const APInt &getAPIntValue() const { return Value; } 1570 uint64_t getValue() const { return Value.getZExtValue(); } 1571 1572 int64_t getSignExtended() const { 1573 unsigned Bits = getValueType(0).getSizeInBits(); 1574 return ((int64_t)Value.getZExtValue() << (64-Bits)) >> (64-Bits); 1575 } 1576 1577 bool isNullValue() const { return Value == 0; } 1578 bool isAllOnesValue() const { 1579 return Value == getValueType(0).getIntegerVTBitMask(); 1580 } 1581 1582 static bool classof(const ConstantSDNode *) { return true; } 1583 static bool classof(const SDNode *N) { 1584 return N->getOpcode() == ISD::Constant || 1585 N->getOpcode() == ISD::TargetConstant; 1586 } 1587}; 1588 1589class ConstantFPSDNode : public SDNode { 1590 APFloat Value; 1591 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1592protected: 1593 friend class SelectionDAG; 1594 ConstantFPSDNode(bool isTarget, const APFloat& val, MVT VT) 1595 : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 1596 getSDVTList(VT)), Value(val) { 1597 } 1598public: 1599 1600 const APFloat& getValueAPF() const { return Value; } 1601 1602 /// isExactlyValue - We don't rely on operator== working on double values, as 1603 /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 1604 /// As such, this method can be used to do an exact bit-for-bit comparison of 1605 /// two floating point values. 1606 1607 /// We leave the version with the double argument here because it's just so 1608 /// convenient to write "2.0" and the like. Without this function we'd 1609 /// have to duplicate its logic everywhere it's called. 1610 bool isExactlyValue(double V) const { 1611 // convert is not supported on this type 1612 if (&Value.getSemantics() == &APFloat::PPCDoubleDouble) 1613 return false; 1614 APFloat Tmp(V); 1615 Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven); 1616 return isExactlyValue(Tmp); 1617 } 1618 bool isExactlyValue(const APFloat& V) const; 1619 1620 bool isValueValidForType(MVT VT, const APFloat& Val); 1621 1622 static bool classof(const ConstantFPSDNode *) { return true; } 1623 static bool classof(const SDNode *N) { 1624 return N->getOpcode() == ISD::ConstantFP || 1625 N->getOpcode() == ISD::TargetConstantFP; 1626 } 1627}; 1628 1629class GlobalAddressSDNode : public SDNode { 1630 GlobalValue *TheGlobal; 1631 int Offset; 1632 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1633protected: 1634 friend class SelectionDAG; 1635 GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT, int o = 0); 1636public: 1637 1638 GlobalValue *getGlobal() const { return TheGlobal; } 1639 int getOffset() const { return Offset; } 1640 1641 static bool classof(const GlobalAddressSDNode *) { return true; } 1642 static bool classof(const SDNode *N) { 1643 return N->getOpcode() == ISD::GlobalAddress || 1644 N->getOpcode() == ISD::TargetGlobalAddress || 1645 N->getOpcode() == ISD::GlobalTLSAddress || 1646 N->getOpcode() == ISD::TargetGlobalTLSAddress; 1647 } 1648}; 1649 1650class FrameIndexSDNode : public SDNode { 1651 int FI; 1652 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1653protected: 1654 friend class SelectionDAG; 1655 FrameIndexSDNode(int fi, MVT VT, bool isTarg) 1656 : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)), 1657 FI(fi) { 1658 } 1659public: 1660 1661 int getIndex() const { return FI; } 1662 1663 static bool classof(const FrameIndexSDNode *) { return true; } 1664 static bool classof(const SDNode *N) { 1665 return N->getOpcode() == ISD::FrameIndex || 1666 N->getOpcode() == ISD::TargetFrameIndex; 1667 } 1668}; 1669 1670class JumpTableSDNode : public SDNode { 1671 int JTI; 1672 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1673protected: 1674 friend class SelectionDAG; 1675 JumpTableSDNode(int jti, MVT VT, bool isTarg) 1676 : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)), 1677 JTI(jti) { 1678 } 1679public: 1680 1681 int getIndex() const { return JTI; } 1682 1683 static bool classof(const JumpTableSDNode *) { return true; } 1684 static bool classof(const SDNode *N) { 1685 return N->getOpcode() == ISD::JumpTable || 1686 N->getOpcode() == ISD::TargetJumpTable; 1687 } 1688}; 1689 1690class ConstantPoolSDNode : public SDNode { 1691 union { 1692 Constant *ConstVal; 1693 MachineConstantPoolValue *MachineCPVal; 1694 } Val; 1695 int Offset; // It's a MachineConstantPoolValue if top bit is set. 1696 unsigned Alignment; 1697 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1698protected: 1699 friend class SelectionDAG; 1700 ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0) 1701 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1702 getSDVTList(VT)), Offset(o), Alignment(0) { 1703 assert((int)Offset >= 0 && "Offset is too large"); 1704 Val.ConstVal = c; 1705 } 1706 ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align) 1707 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1708 getSDVTList(VT)), Offset(o), Alignment(Align) { 1709 assert((int)Offset >= 0 && "Offset is too large"); 1710 Val.ConstVal = c; 1711 } 1712 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1713 MVT VT, int o=0) 1714 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1715 getSDVTList(VT)), Offset(o), Alignment(0) { 1716 assert((int)Offset >= 0 && "Offset is too large"); 1717 Val.MachineCPVal = v; 1718 Offset |= 1 << (sizeof(unsigned)*8-1); 1719 } 1720 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1721 MVT VT, int o, unsigned Align) 1722 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1723 getSDVTList(VT)), Offset(o), Alignment(Align) { 1724 assert((int)Offset >= 0 && "Offset is too large"); 1725 Val.MachineCPVal = v; 1726 Offset |= 1 << (sizeof(unsigned)*8-1); 1727 } 1728public: 1729 1730 bool isMachineConstantPoolEntry() const { 1731 return (int)Offset < 0; 1732 } 1733 1734 Constant *getConstVal() const { 1735 assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1736 return Val.ConstVal; 1737 } 1738 1739 MachineConstantPoolValue *getMachineCPVal() const { 1740 assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1741 return Val.MachineCPVal; 1742 } 1743 1744 int getOffset() const { 1745 return Offset & ~(1 << (sizeof(unsigned)*8-1)); 1746 } 1747 1748 // Return the alignment of this constant pool object, which is either 0 (for 1749 // default alignment) or log2 of the desired value. 1750 unsigned getAlignment() const { return Alignment; } 1751 1752 const Type *getType() const; 1753 1754 static bool classof(const ConstantPoolSDNode *) { return true; } 1755 static bool classof(const SDNode *N) { 1756 return N->getOpcode() == ISD::ConstantPool || 1757 N->getOpcode() == ISD::TargetConstantPool; 1758 } 1759}; 1760 1761class BasicBlockSDNode : public SDNode { 1762 MachineBasicBlock *MBB; 1763 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1764protected: 1765 friend class SelectionDAG; 1766 explicit BasicBlockSDNode(MachineBasicBlock *mbb) 1767 : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) { 1768 } 1769public: 1770 1771 MachineBasicBlock *getBasicBlock() const { return MBB; } 1772 1773 static bool classof(const BasicBlockSDNode *) { return true; } 1774 static bool classof(const SDNode *N) { 1775 return N->getOpcode() == ISD::BasicBlock; 1776 } 1777}; 1778 1779/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is 1780/// used when the SelectionDAG needs to make a simple reference to something 1781/// in the LLVM IR representation. 1782/// 1783/// Note that this is not used for carrying alias information; that is done 1784/// with MemOperandSDNode, which includes a Value which is required to be a 1785/// pointer, and several other fields specific to memory references. 1786/// 1787class SrcValueSDNode : public SDNode { 1788 const Value *V; 1789 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1790protected: 1791 friend class SelectionDAG; 1792 /// Create a SrcValue for a general value. 1793 explicit SrcValueSDNode(const Value *v) 1794 : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {} 1795 1796public: 1797 /// getValue - return the contained Value. 1798 const Value *getValue() const { return V; } 1799 1800 static bool classof(const SrcValueSDNode *) { return true; } 1801 static bool classof(const SDNode *N) { 1802 return N->getOpcode() == ISD::SRCVALUE; 1803 } 1804}; 1805 1806 1807/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is 1808/// used to represent a reference to memory after ISD::LOAD 1809/// and ISD::STORE have been lowered. 1810/// 1811class MemOperandSDNode : public SDNode { 1812 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1813protected: 1814 friend class SelectionDAG; 1815 /// Create a MachineMemOperand node 1816 explicit MemOperandSDNode(const MachineMemOperand &mo) 1817 : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {} 1818 1819public: 1820 /// MO - The contained MachineMemOperand. 1821 const MachineMemOperand MO; 1822 1823 static bool classof(const MemOperandSDNode *) { return true; } 1824 static bool classof(const SDNode *N) { 1825 return N->getOpcode() == ISD::MEMOPERAND; 1826 } 1827}; 1828 1829 1830class RegisterSDNode : public SDNode { 1831 unsigned Reg; 1832 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1833protected: 1834 friend class SelectionDAG; 1835 RegisterSDNode(unsigned reg, MVT VT) 1836 : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) { 1837 } 1838public: 1839 1840 unsigned getReg() const { return Reg; } 1841 1842 static bool classof(const RegisterSDNode *) { return true; } 1843 static bool classof(const SDNode *N) { 1844 return N->getOpcode() == ISD::Register; 1845 } 1846}; 1847 1848class DbgStopPointSDNode : public SDNode { 1849 SDUse Chain; 1850 unsigned Line; 1851 unsigned Column; 1852 const CompileUnitDesc *CU; 1853 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1854protected: 1855 friend class SelectionDAG; 1856 DbgStopPointSDNode(SDOperand ch, unsigned l, unsigned c, 1857 const CompileUnitDesc *cu) 1858 : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)), 1859 Line(l), Column(c), CU(cu) { 1860 Chain = ch; 1861 InitOperands(&Chain, 1); 1862 } 1863public: 1864 unsigned getLine() const { return Line; } 1865 unsigned getColumn() const { return Column; } 1866 const CompileUnitDesc *getCompileUnit() const { return CU; } 1867 1868 static bool classof(const DbgStopPointSDNode *) { return true; } 1869 static bool classof(const SDNode *N) { 1870 return N->getOpcode() == ISD::DBG_STOPPOINT; 1871 } 1872}; 1873 1874class LabelSDNode : public SDNode { 1875 SDUse Chain; 1876 unsigned LabelID; 1877 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1878protected: 1879 friend class SelectionDAG; 1880 LabelSDNode(unsigned NodeTy, SDOperand ch, unsigned id) 1881 : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) { 1882 Chain = ch; 1883 InitOperands(&Chain, 1); 1884 } 1885public: 1886 unsigned getLabelID() const { return LabelID; } 1887 1888 static bool classof(const LabelSDNode *) { return true; } 1889 static bool classof(const SDNode *N) { 1890 return N->getOpcode() == ISD::DBG_LABEL || 1891 N->getOpcode() == ISD::EH_LABEL; 1892 } 1893}; 1894 1895class ExternalSymbolSDNode : public SDNode { 1896 const char *Symbol; 1897 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1898protected: 1899 friend class SelectionDAG; 1900 ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT) 1901 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 1902 getSDVTList(VT)), Symbol(Sym) { 1903 } 1904public: 1905 1906 const char *getSymbol() const { return Symbol; } 1907 1908 static bool classof(const ExternalSymbolSDNode *) { return true; } 1909 static bool classof(const SDNode *N) { 1910 return N->getOpcode() == ISD::ExternalSymbol || 1911 N->getOpcode() == ISD::TargetExternalSymbol; 1912 } 1913}; 1914 1915class CondCodeSDNode : public SDNode { 1916 ISD::CondCode Condition; 1917 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1918protected: 1919 friend class SelectionDAG; 1920 explicit CondCodeSDNode(ISD::CondCode Cond) 1921 : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) { 1922 } 1923public: 1924 1925 ISD::CondCode get() const { return Condition; } 1926 1927 static bool classof(const CondCodeSDNode *) { return true; } 1928 static bool classof(const SDNode *N) { 1929 return N->getOpcode() == ISD::CONDCODE; 1930 } 1931}; 1932 1933namespace ISD { 1934 struct ArgFlagsTy { 1935 private: 1936 static const uint64_t NoFlagSet = 0ULL; 1937 static const uint64_t ZExt = 1ULL<<0; ///< Zero extended 1938 static const uint64_t ZExtOffs = 0; 1939 static const uint64_t SExt = 1ULL<<1; ///< Sign extended 1940 static const uint64_t SExtOffs = 1; 1941 static const uint64_t InReg = 1ULL<<2; ///< Passed in register 1942 static const uint64_t InRegOffs = 2; 1943 static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr 1944 static const uint64_t SRetOffs = 3; 1945 static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value 1946 static const uint64_t ByValOffs = 4; 1947 static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain 1948 static const uint64_t NestOffs = 5; 1949 static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment 1950 static const uint64_t ByValAlignOffs = 6; 1951 static const uint64_t Split = 1ULL << 10; 1952 static const uint64_t SplitOffs = 10; 1953 static const uint64_t OrigAlign = 0x1FULL<<27; 1954 static const uint64_t OrigAlignOffs = 27; 1955 static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size 1956 static const uint64_t ByValSizeOffs = 32; 1957 1958 static const uint64_t One = 1ULL; //< 1 of this type, for shifts 1959 1960 uint64_t Flags; 1961 public: 1962 ArgFlagsTy() : Flags(0) { } 1963 1964 bool isZExt() const { return Flags & ZExt; } 1965 void setZExt() { Flags |= One << ZExtOffs; } 1966 1967 bool isSExt() const { return Flags & SExt; } 1968 void setSExt() { Flags |= One << SExtOffs; } 1969 1970 bool isInReg() const { return Flags & InReg; } 1971 void setInReg() { Flags |= One << InRegOffs; } 1972 1973 bool isSRet() const { return Flags & SRet; } 1974 void setSRet() { Flags |= One << SRetOffs; } 1975 1976 bool isByVal() const { return Flags & ByVal; } 1977 void setByVal() { Flags |= One << ByValOffs; } 1978 1979 bool isNest() const { return Flags & Nest; } 1980 void setNest() { Flags |= One << NestOffs; } 1981 1982 unsigned getByValAlign() const { 1983 return (unsigned) 1984 ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2); 1985 } 1986 void setByValAlign(unsigned A) { 1987 Flags = (Flags & ~ByValAlign) | 1988 (uint64_t(Log2_32(A) + 1) << ByValAlignOffs); 1989 } 1990 1991 bool isSplit() const { return Flags & Split; } 1992 void setSplit() { Flags |= One << SplitOffs; } 1993 1994 unsigned getOrigAlign() const { 1995 return (unsigned) 1996 ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2); 1997 } 1998 void setOrigAlign(unsigned A) { 1999 Flags = (Flags & ~OrigAlign) | 2000 (uint64_t(Log2_32(A) + 1) << OrigAlignOffs); 2001 } 2002 2003 unsigned getByValSize() const { 2004 return (unsigned)((Flags & ByValSize) >> ByValSizeOffs); 2005 } 2006 void setByValSize(unsigned S) { 2007 Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs); 2008 } 2009 2010 /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4". 2011 std::string getArgFlagsString(); 2012 2013 /// getRawBits - Represent the flags as a bunch of bits. 2014 uint64_t getRawBits() const { return Flags; } 2015 }; 2016} 2017 2018/// ARG_FLAGSSDNode - Leaf node holding parameter flags. 2019class ARG_FLAGSSDNode : public SDNode { 2020 ISD::ArgFlagsTy TheFlags; 2021 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 2022protected: 2023 friend class SelectionDAG; 2024 explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags) 2025 : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) { 2026 } 2027public: 2028 ISD::ArgFlagsTy getArgFlags() const { return TheFlags; } 2029 2030 static bool classof(const ARG_FLAGSSDNode *) { return true; } 2031 static bool classof(const SDNode *N) { 2032 return N->getOpcode() == ISD::ARG_FLAGS; 2033 } 2034}; 2035 2036/// VTSDNode - This class is used to represent MVT's, which are used 2037/// to parameterize some operations. 2038class VTSDNode : public SDNode { 2039 MVT ValueType; 2040 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 2041protected: 2042 friend class SelectionDAG; 2043 explicit VTSDNode(MVT VT) 2044 : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) { 2045 } 2046public: 2047 2048 MVT getVT() const { return ValueType; } 2049 2050 static bool classof(const VTSDNode *) { return true; } 2051 static bool classof(const SDNode *N) { 2052 return N->getOpcode() == ISD::VALUETYPE; 2053 } 2054}; 2055 2056/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode 2057/// 2058class LSBaseSDNode : public MemSDNode { 2059private: 2060 // AddrMode - unindexed, pre-indexed, post-indexed. 2061 ISD::MemIndexedMode AddrMode; 2062 2063 // MemoryVT - VT of in-memory value. 2064 MVT MemoryVT; 2065 2066 //! SVOffset - Memory location offset. Note that base is defined in MemSDNode 2067 int SVOffset; 2068 2069 //! IsVolatile - True if the load/store is volatile. 2070 bool IsVolatile; 2071 2072protected: 2073 //! Operand array for load and store 2074 /*! 2075 \note Moving this array to the base class captures more 2076 common functionality shared between LoadSDNode and 2077 StoreSDNode 2078 */ 2079 SDUse Ops[4]; 2080public: 2081 LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned numOperands, 2082 SDVTList VTs, ISD::MemIndexedMode AM, MVT VT, 2083 const Value *SV, int SVO, unsigned Align, bool Vol) 2084 : MemSDNode(NodeTy, VTs, SV, Align), AddrMode(AM), MemoryVT(VT), 2085 SVOffset(SVO), IsVolatile(Vol) { 2086 for (unsigned i = 0; i != numOperands; ++i) 2087 Ops[i] = Operands[i]; 2088 InitOperands(Ops, numOperands); 2089 assert(Align != 0 && "Loads and stores should have non-zero aligment"); 2090 assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) && 2091 "Only indexed loads and stores have a non-undef offset operand"); 2092 } 2093 2094 const SDOperand &getChain() const { return getOperand(0); } 2095 const SDOperand &getBasePtr() const { 2096 return getOperand(getOpcode() == ISD::LOAD ? 1 : 2); 2097 } 2098 const SDOperand &getOffset() const { 2099 return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); 2100 } 2101 2102 MVT getMemoryVT() const { return MemoryVT; } 2103 2104 ISD::MemIndexedMode getAddressingMode() const { return AddrMode; } 2105 2106 /// isIndexed - Return true if this is a pre/post inc/dec load/store. 2107 bool isIndexed() const { return AddrMode != ISD::UNINDEXED; } 2108 2109 /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. 2110 bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; } 2111 2112 // Implementation for MemSDNode 2113 virtual int getSrcValueOffset() const { return SVOffset; } 2114 virtual bool isVolatile() const { return IsVolatile; } 2115 2116 /// getMemOperand - Return a MachineMemOperand object describing the memory 2117 /// reference performed by this load or store. 2118 virtual MachineMemOperand getMemOperand() const; 2119 2120 static bool classof(const LSBaseSDNode *) { return true; } 2121 static bool classof(const SDNode *N) { 2122 return N->getOpcode() == ISD::LOAD || 2123 N->getOpcode() == ISD::STORE; 2124 } 2125}; 2126 2127/// LoadSDNode - This class is used to represent ISD::LOAD nodes. 2128/// 2129class LoadSDNode : public LSBaseSDNode { 2130 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 2131 2132 // ExtType - non-ext, anyext, sext, zext. 2133 ISD::LoadExtType ExtType; 2134 2135protected: 2136 friend class SelectionDAG; 2137 LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs, 2138 ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT, 2139 const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 2140 : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3, 2141 VTs, AM, LVT, SV, O, Align, Vol), 2142 ExtType(ETy) {} 2143public: 2144 2145 ISD::LoadExtType getExtensionType() const { return ExtType; } 2146 const SDOperand &getBasePtr() const { return getOperand(1); } 2147 const SDOperand &getOffset() const { return getOperand(2); } 2148 2149 static bool classof(const LoadSDNode *) { return true; } 2150 static bool classof(const SDNode *N) { 2151 return N->getOpcode() == ISD::LOAD; 2152 } 2153}; 2154 2155/// StoreSDNode - This class is used to represent ISD::STORE nodes. 2156/// 2157class StoreSDNode : public LSBaseSDNode { 2158 virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 2159 2160 // IsTruncStore - True if the op does a truncation before store. For 2161 // integers this is the same as doing a TRUNCATE and storing the result. 2162 // For floats, it is the same as doing an FP_ROUND and storing the result. 2163 bool IsTruncStore; 2164protected: 2165 friend class SelectionDAG; 2166 StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs, 2167 ISD::MemIndexedMode AM, bool isTrunc, MVT SVT, 2168 const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 2169 : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4, 2170 VTs, AM, SVT, SV, O, Align, Vol), 2171 IsTruncStore(isTrunc) {} 2172public: 2173 2174 bool isTruncatingStore() const { return IsTruncStore; } 2175 const SDOperand &getValue() const { return getOperand(1); } 2176 const SDOperand &getBasePtr() const { return getOperand(2); } 2177 const SDOperand &getOffset() const { return getOperand(3); } 2178 2179 static bool classof(const StoreSDNode *) { return true; } 2180 static bool classof(const SDNode *N) { 2181 return N->getOpcode() == ISD::STORE; 2182 } 2183}; 2184 2185 2186class SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { 2187 SDNode *Node; 2188 unsigned Operand; 2189 2190 SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 2191public: 2192 bool operator==(const SDNodeIterator& x) const { 2193 return Operand == x.Operand; 2194 } 2195 bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 2196 2197 const SDNodeIterator &operator=(const SDNodeIterator &I) { 2198 assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 2199 Operand = I.Operand; 2200 return *this; 2201 } 2202 2203 pointer operator*() const { 2204 return Node->getOperand(Operand).Val; 2205 } 2206 pointer operator->() const { return operator*(); } 2207 2208 SDNodeIterator& operator++() { // Preincrement 2209 ++Operand; 2210 return *this; 2211 } 2212 SDNodeIterator operator++(int) { // Postincrement 2213 SDNodeIterator tmp = *this; ++*this; return tmp; 2214 } 2215 2216 static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 2217 static SDNodeIterator end (SDNode *N) { 2218 return SDNodeIterator(N, N->getNumOperands()); 2219 } 2220 2221 unsigned getOperand() const { return Operand; } 2222 const SDNode *getNode() const { return Node; } 2223}; 2224 2225template <> struct GraphTraits<SDNode*> { 2226 typedef SDNode NodeType; 2227 typedef SDNodeIterator ChildIteratorType; 2228 static inline NodeType *getEntryNode(SDNode *N) { return N; } 2229 static inline ChildIteratorType child_begin(NodeType *N) { 2230 return SDNodeIterator::begin(N); 2231 } 2232 static inline ChildIteratorType child_end(NodeType *N) { 2233 return SDNodeIterator::end(N); 2234 } 2235}; 2236 2237template<> 2238struct ilist_traits<SDNode> { 2239 static SDNode *getPrev(const SDNode *N) { return N->Prev; } 2240 static SDNode *getNext(const SDNode *N) { return N->Next; } 2241 2242 static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; } 2243 static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; } 2244 2245 static SDNode *createSentinel() { 2246 return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other)); 2247 } 2248 static void destroySentinel(SDNode *N) { delete N; } 2249 //static SDNode *createNode(const SDNode &V) { return new SDNode(V); } 2250 2251 2252 void addNodeToList(SDNode *) {} 2253 void removeNodeFromList(SDNode *) {} 2254 void transferNodesFromList(iplist<SDNode, ilist_traits> &, 2255 const ilist_iterator<SDNode> &, 2256 const ilist_iterator<SDNode> &) {} 2257}; 2258 2259namespace ISD { 2260 /// isNormalLoad - Returns true if the specified node is a non-extending 2261 /// and unindexed load. 2262 inline bool isNormalLoad(const SDNode *N) { 2263 const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N); 2264 return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD && 2265 Ld->getAddressingMode() == ISD::UNINDEXED; 2266 } 2267 2268 /// isNON_EXTLoad - Returns true if the specified node is a non-extending 2269 /// load. 2270 inline bool isNON_EXTLoad(const SDNode *N) { 2271 return isa<LoadSDNode>(N) && 2272 cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 2273 } 2274 2275 /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 2276 /// 2277 inline bool isEXTLoad(const SDNode *N) { 2278 return isa<LoadSDNode>(N) && 2279 cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 2280 } 2281 2282 /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 2283 /// 2284 inline bool isSEXTLoad(const SDNode *N) { 2285 return isa<LoadSDNode>(N) && 2286 cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 2287 } 2288 2289 /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 2290 /// 2291 inline bool isZEXTLoad(const SDNode *N) { 2292 return isa<LoadSDNode>(N) && 2293 cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 2294 } 2295 2296 /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load. 2297 /// 2298 inline bool isUNINDEXEDLoad(const SDNode *N) { 2299 return isa<LoadSDNode>(N) && 2300 cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 2301 } 2302 2303 /// isNormalStore - Returns true if the specified node is a non-truncating 2304 /// and unindexed store. 2305 inline bool isNormalStore(const SDNode *N) { 2306 const StoreSDNode *St = dyn_cast<StoreSDNode>(N); 2307 return St && !St->isTruncatingStore() && 2308 St->getAddressingMode() == ISD::UNINDEXED; 2309 } 2310 2311 /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 2312 /// store. 2313 inline bool isNON_TRUNCStore(const SDNode *N) { 2314 return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore(); 2315 } 2316 2317 /// isTRUNCStore - Returns true if the specified node is a truncating 2318 /// store. 2319 inline bool isTRUNCStore(const SDNode *N) { 2320 return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore(); 2321 } 2322 2323 /// isUNINDEXEDStore - Returns true if the specified node is an 2324 /// unindexed store. 2325 inline bool isUNINDEXEDStore(const SDNode *N) { 2326 return isa<StoreSDNode>(N) && 2327 cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 2328 } 2329} 2330 2331 2332} // end llvm namespace 2333 2334#endif 2335