SelectionDAGNodes.h revision e1b50639a860934685dff840e1826b16dbe6a344
163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//                     The LLVM Compiler Infrastructure
463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//
563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// This file was developed by the LLVM research group and is distributed under
663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// the University of Illinois Open Source License. See LICENSE.TXT for details.
7ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
9ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
1063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// This file declares the SDNode class and derived classes, which are used to
1163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// represent the nodes and operations present in a SelectionDAG.  These nodes
1263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// and operations are machine code level operations, with some similarities to
1363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// the GCC RTL representation.
1463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//
1563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// Clients should include the SelectionDAG.h file instead of this file directly.
1663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//
1763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
1863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
2063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#define LLVM_CODEGEN_SELECTIONDAGNODES_H
2163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
222d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth#include "llvm/Value.h"
23583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/ADT/FoldingSet.h"
241080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/GraphTraits.h"
251080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/iterator"
268bb369b8072c919ef5802f639a52b17620201190Dale Johannesen#include "llvm/ADT/APFloat.h"
27d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h"
2839931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h"
2963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert>
3063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm {
3263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG;
3463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue;
3563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock;
36d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue;
3763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode;
38c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Chengtemplate <typename T> struct DenseMapKeyInfo;
3963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type;
40b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate <typename T> struct ilist_traits;
41b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<typename NodeTy, typename Traits> class iplist;
42b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<typename NodeTy> class ilist_iterator;
4363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
440b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by
450b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG.  Instances of this simple value class are returned by
460b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...).
470b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner///
480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList {
490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  const MVT::ValueType *VTs;
500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  unsigned short NumVTs;
510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner};
520b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
5363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the
5463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types.
5563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
5663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD {
57d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov  namespace ParamFlags {
58d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov  enum Flags {
59d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    NoFlagSet         = 0,
60d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    ZExt              = 1<<0,  ///< Parameter should be zero extended
61d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    ZExtOffs          = 0,
62d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    SExt              = 1<<1,  ///< Parameter should be sign extended
63d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    SExtOffs          = 1,
64d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    InReg             = 1<<2,  ///< Parameter should be passed in register
65d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    InRegOffs         = 2,
66d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    StructReturn      = 1<<3,  ///< Hidden struct-return pointer
67d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    StructReturnOffs  = 3,
681aa7efbd2c98e761f50992197473304b99257ca9Rafael Espindola    ByVal             = 1<<4,  ///< Struct passed by value
691aa7efbd2c98e761f50992197473304b99257ca9Rafael Espindola    ByValOffs         = 4,
7036397f50343639ce9a25996f2d790c656791ab92Duncan Sands    Nest              = 1<<5,  ///< Parameter is nested function static chain
7136397f50343639ce9a25996f2d790c656791ab92Duncan Sands    NestOffs          = 5,
72594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    ByValAlign        = 0xF << 6, //< The alignment of the struct
73594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    ByValAlignOffs    = 6,
74594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    ByValSize         = 0x1ffff << 10, //< The size of the struct
75594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    ByValSizeOffs     = 10,
76d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    OrigAlignment     = 0x1F<<27,
77d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov    OrigAlignmentOffs = 27
78d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov  };
79d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov  }
80d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov
8163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
8263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::NodeType enum - This enum defines all of the operators valid in a
8363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SelectionDAG.
8463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
8563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum NodeType {
863258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // DELETED_NODE - This is an illegal flag value that is used to catch
873258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // errors.  This opcode is not a legal opcode for any node.
883258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    DELETED_NODE,
893258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner
908a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // EntryToken - This is the marker used to indicate the start of the region.
918a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    EntryToken,
928a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner
938c4bde36a339b1c538002e819daff84caae4cbadReid Spencer    // Token factor - This node takes multiple tokens as input and produces a
948a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // single token result.  This is used to represent the fact that the operand
958a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // operators are independent of each other.
968a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    TokenFactor,
97f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman
98f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // AssertSext, AssertZext - These nodes record if a register contains a
99f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // value that has already been zero or sign extended from a narrower type.
100f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // These nodes take two operands.  The first is the node that has already
101f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // been extended, and the second is a value type node indicating the width
102f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // of the extension
103f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    AssertSext, AssertZext,
104ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
1058a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // Various leaf nodes.
1061ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    STRING, BasicBlock, VALUETYPE, CONDCODE, Register,
1071ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    Constant, ConstantFP,
108b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    GlobalAddress, GlobalTLSAddress, FrameIndex,
109b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    JumpTable, ConstantPool, ExternalSymbol,
1101ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng
11182c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    // The address of the GOT
11282c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    GLOBAL_OFFSET_TABLE,
113bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman
114bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
115bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // llvm.returnaddress on the DAG.  These nodes take one operand, the index
116bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // of the frame or return address to return.  An index of zero corresponds
117bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // to the current function's frame or return address, an index of one to the
118bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // parent's frame or return address, and so on.
119bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    FRAMEADDR, RETURNADDR,
1202365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
1212365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
1222365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // first (possible) on-stack argument. This is needed for correct stack
1232365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // adjustment during unwind.
1242365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    FRAME_TO_ARGS_OFFSET,
125f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
126f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the
127f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // address of the exception block on entry to an landing pad block.
128f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    EXCEPTIONADDR,
129f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
130f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents
131f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // the selection index of the exception thrown.
132f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    EHSELECTION,
133beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth
1342365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
1352365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // 'eh_return' gcc dwarf builtin, which is used to return from
1362365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // exception. The general meaning is: adjust stack by OFFSET and pass
1372365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // execution to HANDLER. Many platform-related details also :)
1382365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    EH_RETURN,
1392365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
140ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // TargetConstant* - Like Constant*, but the DAG does not do any folding or
141ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // simplification of the constant.
142056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    TargetConstant,
143ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    TargetConstantFP,
144f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner
145f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
146f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // anything else with this node, and this is valid in the target-specific
147f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // dag, turning into a GlobalAddress operand.
148f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    TargetGlobalAddress,
149b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    TargetGlobalTLSAddress,
150afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    TargetFrameIndex,
15137efe6764568a3829fee26aba532283131d1a104Nate Begeman    TargetJumpTable,
152aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    TargetConstantPool,
1532a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth    TargetExternalSymbol,
15472601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner
155ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
156ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with no side effects.
157ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// The first operand is the ID number of the intrinsic from the
158ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// llvm::Intrinsic namespace.  The operands to the intrinsic follow.  The
159ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// node has returns the result of the intrinsic.
160ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_WO_CHAIN,
161ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
162ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
163ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
164ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// returns a result.  The first operand is a chain pointer.  The second is
165ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// the ID number of the intrinsic from the llvm::Intrinsic namespace.  The
166ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// operands to the intrinsic follow.  The node has two results, the result
167ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// of the intrinsic and an output chain.
168ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_W_CHAIN,
16963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
170ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
171ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
172ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// does not return a result.  The first operand is a chain pointer.  The
173ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// second is the ID number of the intrinsic from the llvm::Intrinsic
174ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// namespace.  The operands to the intrinsic follow.
175ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_VOID,
176ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
177d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // CopyToReg - This node has three operands: a chain, a register number to
178d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // set to this value, and a value.
17963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyToReg,
18063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
18163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // CopyFromReg - This node indicates that the input value is a virtual or
18263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // physical register that is defined outside of the scope of this
18318c2f13e0f9d0e5d6227cf6d1881e9ee3d1b6109Chris Lattner    // SelectionDAG.  The register is available from the RegSDNode object.
18463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyFromReg,
18563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
186fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    // UNDEF - An undefined node
187fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    UNDEF,
188681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner
189b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
190b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// represents the formal arguments for a function.  CC# is a Constant value
191b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// indicating the calling convention of the function, and ISVARARG is a
192b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// flag that indicates whether the function is varargs or not. This node
193b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// has one result value for each incoming argument, plus one for the output
194b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// chain. It must be custom legalized. See description of CALL node for
195b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FLAG argument contents explanation.
196c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner    ///
197681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner    FORMAL_ARGUMENTS,
1986c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner
1996c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE,
200b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    ///                              ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn)
2016c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    /// This node represents a fully general function call, before the legalizer
202b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// runs.  This has one result value for each argument / flag pair, plus
203b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// a chain result. It must be custom legalized. Flag argument indicates
204b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// misc. argument attributes. Currently:
205b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 0 - signness
206b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 1 - 'inreg' attribute
207b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 2 - 'sret' attribute
208594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 4 - 'byval' attribute
209594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 5 - 'nest' attribute
210594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 6-9 - alignment of byval structures
211594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 10-26 - size of byval structures
21213a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio    /// Bits 31:27 - argument ABI alignment in the first argument piece and
21313a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio    /// alignment '1' in other argument pieces.
2146c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    CALL,
215fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman
21663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // EXTRACT_ELEMENT - This is used to get the first or second (determined by
21763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // a Constant, which is required to be operand #1), element of the aggregate
21863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // value specified as operand #0.  This is only for use before legalization,
21963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // for values that will be broken into multiple registers.
22063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    EXTRACT_ELEMENT,
22163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
22263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.  Given
22363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // two values of the same integer value type, this produces a value twice as
22463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // big.  Like EXTRACT_ELEMENT, this can only be used before legalization.
22563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BUILD_PAIR,
226006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner
227006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // MERGE_VALUES - This node takes multiple discrete operands and returns
228006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // them all as its individual results.  This nodes has exactly the same
229006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // number of inputs and outputs, and is only valid before legalization.
230006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // This node is useful for some pieces of the code generator that want to
231006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // think about a single node with multiple results, not multiple nodes.
232006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    MERGE_VALUES,
23363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
234615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple integer binary arithmetic operators.
235bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
236615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner
23755e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    // CARRY_FALSE - This node is used when folding other nodes,
23855e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    // like ADDC/SUBC, which indicate the carry result is always false.
23955e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    CARRY_FALSE,
24055e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner
241551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-setting nodes for multiple precision addition and subtraction.
242551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // These nodes take two operands of the same value type, and produce two
243551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // results.  The first result is the normal add or sub result, the second
244551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // result is the carry flag result.
245551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDC, SUBC,
246551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman
247551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-using nodes for multiple precision addition and subtraction.  These
248551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // nodes take three operands: The first two are the normal lhs and rhs to
249551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // the add or sub, and the third is the input carry flag.  These nodes
250551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // produce two results; the normal result of the add or sub, and the output
251551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // carry flag.  These nodes both read and write a carry flag to allow them
252551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // to them to be chained together for add and sub of arbitrarily large
253551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // values.
254551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDE, SUBE,
255551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman
256615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple binary floating point operators.
257615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    FADD, FSUB, FMUL, FDIV, FREM,
25838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
25938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.  NOTE: This
26038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // DAG node does not require that X and Y have the same type, just that they
26138bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // are both floating point.  X and the result must have the same type.
26238bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(f32, f64) is allowed.
26338bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    FCOPYSIGN,
264fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner
265664e9546d674096c5a012536f1a424b1681ece51Dan Gohman    /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector
26622232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// with the specified, possibly variable, elements.  The number of elements
26722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// is required to be a power of two.
26822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    BUILD_VECTOR,
26922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
2707f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
2717f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// at IDX replaced with VAL.
27222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    INSERT_VECTOR_ELT,
2734b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner
2744b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
2757f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// identified by the (potentially variable) element number IDX.
2764b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    EXTRACT_VECTOR_ELT,
27722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
2787f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
2797f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// vector type with the same length and element type, this produces a
2807f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// concatenated vector result value, with length equal to the sum of the
281b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman    /// lengths of the input vectors.
2827f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    CONCAT_VECTORS,
2836595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman
2847f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
2857f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// vector value) starting with the (potentially variable) element number
2867f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// IDX, which must be a multiple of the result vector length.
2877f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    EXTRACT_SUBVECTOR,
2886595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman
28949c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
29049c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// type as VEC1/VEC2.  SHUFFLEVEC is a BUILD_VECTOR of constant int values
29149c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// (regardless of whether its datatype is legal or not) that indicate
29249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// which value each result element will get.  The elements of VEC1/VEC2 are
29349c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// enumerated in order.  This is quite similar to the Altivec 'vperm'
29449c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// instruction, except that the indices must be constants and are in terms
29549c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// of the element size of VEC1/VEC2, not in terms of bytes.
29649c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    VECTOR_SHUFFLE,
29749c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner
298210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
299210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// scalar value into the low element of the resultant vector type.  The top
300210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// elements of the vector are undefined.
301210721aecc0916315f61660dc387a96b89ec423bChris Lattner    SCALAR_TO_VECTOR,
302210721aecc0916315f61660dc387a96b89ec423bChris Lattner
303557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // EXTRACT_SUBREG - This node is used to extract a sub-register value.
304557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // This node takes a superreg and a constant sub-register index as operands.
305557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    EXTRACT_SUBREG,
306557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb
307557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // INSERT_SUBREG - This node is used to insert a sub-register value.
308557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // This node takes a superreg, a subreg value, and a constant sub-register
309557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // index as operands.
310557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    INSERT_SUBREG,
311557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb
312bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
313bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    // an unsigned/signed value of type i[2*n], then return the top part.
314bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    MULHU, MULHS,
31563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
31635ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // Bitwise operators - logical and, logical or, logical xor, shift left,
31735ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // shift right algebraic (shift in sign bits), shift right logical (shift in
31835ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // zeroes), rotate left, rotate right, and byteswap.
31935ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
32063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
321691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    // Counting operators
322691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    CTTZ, CTLZ, CTPOP,
323691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth
324fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner    // Select(COND, TRUEVAL, FALSEVAL)
3259373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    SELECT,
3269373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman
3279373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // Select with condition operator - This selects between a true value and
3289373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // a false value (ops #2 and #3) based on the boolean result of comparing
3299373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // the lhs and rhs (ops #0 and #1) of a conditional expression with the
3309373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // condition code in op #4, a CondCodeSDNode.
3319373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    SELECT_CC,
33263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
33363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // SetCC operator - This evaluates to a boolean (i1) true value if the
3347cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    // condition is true.  The operands to this are the left and right operands
3357cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    // to compare (ops #0, and #1) and the condition code to compare them with
3367cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    // (op #2) as a CondCodeSDNode.
33763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETCC,
33863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
33914c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
34014c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // integer shift operations, just like ADD/SUB_PARTS.  The operation
34114c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // ordering is:
3426b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner    //       [Lo,Hi] = op [LoLHS,HiLHS], Amt
34314c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    SHL_PARTS, SRA_PARTS, SRL_PARTS,
34414c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner
34563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Conversion operators.  These are all single input single output
34663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operations.  For all of these, the result type must be strictly
34763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // wider or narrower (depending on the operation) than the source
34863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // type.
34963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
35063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // SIGN_EXTEND - Used for integer types, replicating the sign bit
35163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // into new bits.
35263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SIGN_EXTEND,
35363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
35463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // ZERO_EXTEND - Used for integer types, zeroing the new bits.
35563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    ZERO_EXTEND,
35663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3577e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    // ANY_EXTEND - Used for integer types.  The high bits are undefined.
3587e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    ANY_EXTEND,
3597e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner
36063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // TRUNCATE - Completely drop the high bits.
36163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    TRUNCATE,
36263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3631645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
3641645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // depends on the first letter) to floating point.
3651645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    SINT_TO_FP,
3661645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    UINT_TO_FP,
3671645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
368ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
369ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // sign extend a small value in a large integer register (e.g. sign
370ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // extending the low 8 bits of a 32-bit register to fill the top 24 bits
37115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // with the 7th bit).  The size of the smaller type is indicated by the 1th
37215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // operand, a ValueType node.
373859157daee6a4b49e99921832e1dde065167b317Chris Lattner    SIGN_EXTEND_INREG,
374859157daee6a4b49e99921832e1dde065167b317Chris Lattner
3751645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
3761645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // integer.
3771645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_SINT,
3781645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_UINT,
3791645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
38063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // FP_ROUND - Perform a rounding operation from the current
381859157daee6a4b49e99921832e1dde065167b317Chris Lattner    // precision down to the specified precision (currently always 64->32).
38263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_ROUND,
38363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
384859157daee6a4b49e99921832e1dde065167b317Chris Lattner    // FP_ROUND_INREG - This operator takes a floating point register, and
385859157daee6a4b49e99921832e1dde065167b317Chris Lattner    // rounds it to a floating point value.  It then promotes it and returns it
386859157daee6a4b49e99921832e1dde065167b317Chris Lattner    // in a register of the same size.  This operation effectively just discards
38715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // excess precision.  The type to round down to is specified by the 1th
38815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // operation, a VTSDNode (currently always 64->32->64).
389859157daee6a4b49e99921832e1dde065167b317Chris Lattner    FP_ROUND_INREG,
390859157daee6a4b49e99921832e1dde065167b317Chris Lattner
39163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // FP_EXTEND - Extend a smaller FP type into a larger FP type.
39263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_EXTEND,
39363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3941ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // BIT_CONVERT - Theis operator converts between integer and FP values, as
3951ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // if one was stored to memory as integer and the other was loaded from the
39680f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // same address (or equivalently for vector format conversions, etc).  The
39780f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // source and result are required to have the same bit size (e.g.
39880f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // f32 <-> i32).  This can also be used for int-to-int or fp-to-fp
39980f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // conversions, but that is a noop, deleted by getNode().
4001ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    BIT_CONVERT,
4011ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner
402dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner    // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI - Perform unary floating point
403dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner    // negation, absolute value, square root, sine and cosine, and powi
404dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner    // operations.
405dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner    FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI,
40638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
4078862ef148100070b7bf28beead3951464250c926Evan Cheng    // LOAD and STORE have token chains as their first operand, then the same
4088862ef148100070b7bf28beead3951464250c926Evan Cheng    // operands as an LLVM load/store instruction, then an offset node that
4098862ef148100070b7bf28beead3951464250c926Evan Cheng    // is added / subtracted from the base pointer to form the address (for
4108862ef148100070b7bf28beead3951464250c926Evan Cheng    // indexed memory ops).
41163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    LOAD, STORE,
4125fbb5d2459a5410590f285250faa604576308a93Nate Begeman
4131cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner    // TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a
4141cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner    // value and stores it to memory in one operation.  This can be used for
415f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner    // either integer or floating point operands.  The first four operands of
416f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner    // this are the same as a standard store.  The fifth is the ValueType to
417f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner    // store it as (which will be smaller than the source value).
4181cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner    TRUNCSTORE,
4191cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner
42063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
42157fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // to a specified boundary.  This node always has two return values: a new
42257fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // stack pointer value and a chain. The first operand is the token chain,
42357fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // the second is the number of bytes to allocate, and the third is the
42457fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // alignment boundary.  The size is guaranteed to be a multiple of the stack
42557fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // alignment, and the alignment is guaranteed to be bigger than the stack
42674fe063e90045931eefaba561730e6a9175ced78Chris Lattner    // alignment (if required) or 0 to get standard stack alignment.
42763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    DYNAMIC_STACKALLOC,
42863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
42963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Control flow instructions.  These all have token chains.
430ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
43163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BR - Unconditional branch.  The first operand is the chain
43263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operand, the second is the MBB to branch to.
43363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BR,
43463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
43537efe6764568a3829fee26aba532283131d1a104Nate Begeman    // BRIND - Indirect branch.  The first operand is the chain, the second
43637efe6764568a3829fee26aba532283131d1a104Nate Begeman    // is the value to branch to, which must be of the same type as the target's
43737efe6764568a3829fee26aba532283131d1a104Nate Begeman    // pointer type.
43837efe6764568a3829fee26aba532283131d1a104Nate Begeman    BRIND,
439c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng
440c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // BR_JT - Jumptable branch. The first operand is the chain, the second
441c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // is the jumptable index, the last one is the jumptable entry index.
442c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    BR_JT,
44337efe6764568a3829fee26aba532283131d1a104Nate Begeman
44463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BRCOND - Conditional branch.  The first operand is the chain,
44563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // the second is the condition, the third is the block to branch
44663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // to if the condition is true.
44763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BRCOND,
44863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4497cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // BR_CC - Conditional branch.  The behavior is like that of SELECT_CC, in
4507cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // that the condition is represented as condition code, and two nodes to
4517cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // compare, rather than as a combined SetCC node.  The operands in order are
4527cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // chain, cc, lhs, rhs, block to branch to if condition is true.
4537cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    BR_CC,
4547cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman
45563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // RET - Return from function.  The first operand is the chain,
4568e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // and any subsequent operands are pairs of return value and return value
4578e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // signness for the function.  This operation can have variable number of
4588e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // operands.
45963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    RET,
46063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4617572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // INLINEASM - Represents an inline asm block.  This node always has two
4627572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // return values: a chain and a flag result.  The inputs are as follows:
4637572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #0   : Input chain.
4647572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #1   : a ExternalSymbolSDNode with a pointer to the asm string.
4657572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+2: A RegisterNode.
4667572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
4677572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #last: Optional, an incoming flag.
4687572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    INLINEASM,
4691ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey
4701ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    // LABEL - Represents a label in mid basic block used to track
4711ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    // locations needed for debug and exception handling tables.  This node
4721ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    // returns a chain.
4731ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    //   Operand #0 : input chain.
4741ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    //   Operand #1 : module unique number use to identify the label.
4751ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    LABEL,
476f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
4775a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKSAVE - STACKSAVE has one operand, an input chain.  It produces a
4785a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // value, the same type as the pointer type for the system, and an output
4795a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // chain.
4805a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKSAVE,
4815a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
4825a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKRESTORE has two operands, an input chain and a pointer to restore to
4835a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // it returns an output chain.
4845a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKRESTORE,
4855a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
486ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain, and the rest
487ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    // correspond to the operands of the LLVM intrinsic functions.  The only
488ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    // result is a token chain.  The alignment argument is guaranteed to be a
489ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    // Constant node.
490ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    MEMSET,
491ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    MEMMOVE,
492ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    MEMCPY,
493ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
49416cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
49516cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // a call sequence, and carry arbitrary information that target might want
49616cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // to know.  The first operand is a chain, the rest are specified by the
49716cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // target and not touched by the DAG optimizers.
49816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_START,  // Beginning of a call sequence
49916cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_END,    // End of a call sequence
500acc398c195a697795bff3245943d104eb19192b9Nate Begeman
501acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAARG - VAARG has three operands: an input chain, a pointer, and a
502acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // SRCVALUE.  It returns a pair of values: the vaarg value and a new chain.
503acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAARG,
504acc398c195a697795bff3245943d104eb19192b9Nate Begeman
505acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
506acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
507acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // source.
508acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VACOPY,
509acc398c195a697795bff3245943d104eb19192b9Nate Begeman
510acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
511acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // pointer, and a SRCVALUE.
512acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAEND, VASTART,
51363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
51421074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    // SRCVALUE - This corresponds to a Value*, and is used to associate memory
51521074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    // locations with their value.  This allows one use alias analysis
51621074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    // information in the backend.
51721074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    SRCVALUE,
51821074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner
519e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman    // PCMARKER - This corresponds to the pcmarker intrinsic.
52095762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth    PCMARKER,
52163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
522aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
5238b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // The only operand is a chain and a value and a chain are produced.  The
5248b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // value is the contents of the architecture specific cycle counter like
5258b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // register (or other high accuracy low latency clock source)
526aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    READCYCLECOUNTER,
527aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth
528d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    // HANDLENODE node - Used as a handle for various purposes.
529d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    HANDLENODE,
5302d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
53147725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    // LOCATION - This node is used to represent a source location for debug
53247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    // info.  It takes token chain as input, then a line number, then a column
53347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    // number, then a filename, then a working dir.  It produces a token chain
53447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    // as output.
53547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    LOCATION,
53647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner
537f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    // DEBUG_LOC - This node is used to represent source line information
538abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // embedded in the code.  It takes a token chain as input, then a line
53944c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey    // number, then a column then a file id (provided by MachineModuleInfo.) It
540abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // produces a token chain as output.
541f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    DEBUG_LOC,
54236397f50343639ce9a25996f2d790c656791ab92Duncan Sands
54336397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
54436397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // It takes as input a token chain, the pointer to the trampoline,
54536397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // the pointer to the nested function, the pointer to pass for the
54636397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // 'nest' parameter, a SRCVALUE for the trampoline and another for
54736397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // the nested function (allowing targets to access the original
548f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands    // Function*).  It produces the result of the intrinsic and a token
549f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands    // chain as output.
55036397f50343639ce9a25996f2d790c656791ab92Duncan Sands    TRAMPOLINE,
55136397f50343639ce9a25996f2d790c656791ab92Duncan Sands
55263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILTIN_OP_END - This must be the last enum value in this list.
553410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    BUILTIN_OP_END
55463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
55563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
556322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// Node predicates
557322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
558a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  /// isBuildVectorAllOnes - Return true if the specified node is a
559322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// BUILD_VECTOR where all of the elements are ~0 or undef.
560a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  bool isBuildVectorAllOnes(const SDNode *N);
5614a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng
5624a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// isBuildVectorAllZeros - Return true if the specified node is a
5634a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// BUILD_VECTOR where all of the elements are 0 or undef.
5644a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  bool isBuildVectorAllZeros(const SDNode *N);
565322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
56663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
567144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// MemIndexedMode enum - This enum defines the load / store indexed
568144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// addressing modes.
56924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
57024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// UNINDEXED    "Normal" load / store. The effective address is already
57124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computed and is available in the base pointer. The offset
57281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              operand is always undefined. In addition to producing a
57381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              chain, an unindexed load produces one value (result of the
57481c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              load); an unindexed store does not produces a value.
57524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
57635acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// PRE_INC      Similar to the unindexed mode where the effective address is
5778862ef148100070b7bf28beead3951464250c926Evan Cheng  /// PRE_DEC      the value of the base pointer add / subtract the offset.
5788862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              It considers the computation as being folded into the load /
57924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              store operation (i.e. the load / store does the address
58024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computation as well as performing the memory transaction).
58181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              The base operand is always undefined. In addition to
58281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              producing a chain, pre-indexed load produces two values
58381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              (result of the load and the result of the address
58481c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              computation); a pre-indexed store produces one value (result
58581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              of the address computation).
58624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
58735acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// POST_INC     The effective address is the value of the base pointer. The
5888862ef148100070b7bf28beead3951464250c926Evan Cheng  /// POST_DEC     value of the offset operand is then added to / subtracted
5898862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              from the base after memory transaction. In addition to
5908862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              producing a chain, post-indexed load produces two values
5918862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              (the result of the load and the result of the base +/- offset
5928862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              computation); a post-indexed store produces one value (the
5938862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              the result of the base +/- offset computation).
59424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
595144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  enum MemIndexedMode {
59624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    UNINDEXED = 0,
59735acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_INC,
59835acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_DEC,
59935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    POST_INC,
600144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    POST_DEC,
601144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    LAST_INDEXED_MODE
60224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  };
60324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
60424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  //===--------------------------------------------------------------------===//
605c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// LoadExtType enum - This enum defines the three variants of LOADEXT
606c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// (load with extension).
607c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
60824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// SEXTLOAD loads the integer operand and sign extends it to a larger
60924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
61024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// ZEXTLOAD loads the integer operand and zero extends it to a larger
61124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
61224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// EXTLOAD  is used for three things: floating point extending loads,
61324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer extending loads [the top bits are undefined], and vector
61424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          extending loads [load into low elt].
61524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
616c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  enum LoadExtType {
61724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    NON_EXTLOAD = 0,
618c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    EXTLOAD,
619c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    SEXTLOAD,
620c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    ZEXTLOAD,
621c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    LAST_LOADX_TYPE
622c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  };
623c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
624c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  //===--------------------------------------------------------------------===//
62563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::CondCode enum - These are ordered carefully to make the bitfields
62663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// below work out, when considering SETFALSE (something that never exists
62763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// dynamically) as 0.  "U" -> Unsigned (for integer operands) or Unordered
62863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
62963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to.  If the "N" column is 1, the result of the comparison is undefined if
63063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the input is a NAN.
63163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
63263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// All of these (except for the 'always folded ops') should be handled for
63363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// floating point.  For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
63463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
63563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
63663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// Note that these are laid out in a specific order to allow bit-twiddling
63763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to transform conditions.
63863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum CondCode {
63963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Opcode          N U L G E       Intuitive operation
64063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE,      //    0 0 0 0       Always false (always folded)
64163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOEQ,        //    0 0 0 1       True if ordered and equal
64263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGT,        //    0 0 1 0       True if ordered and greater than
64363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGE,        //    0 0 1 1       True if ordered and greater than or equal
64463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLT,        //    0 1 0 0       True if ordered and less than
64563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLE,        //    0 1 0 1       True if ordered and less than or equal
64663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETONE,        //    0 1 1 0       True if ordered and operands are unequal
64763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETO,          //    0 1 1 1       True if ordered (no nans)
64863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUO,         //    1 0 0 0       True if unordered: isnan(X) | isnan(Y)
64963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUEQ,        //    1 0 0 1       True if unordered or equal
65063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGT,        //    1 0 1 0       True if unordered or greater than
65163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGE,        //    1 0 1 1       True if unordered, greater than, or equal
65263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETULT,        //    1 1 0 0       True if unordered or less than
653ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETULE,        //    1 1 0 1       True if unordered, less than, or equal
65463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUNE,        //    1 1 1 0       True if unordered or not equal
65563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE,       //    1 1 1 1       Always true (always folded)
65663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Don't care operations: undefined if the input is a nan.
65763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE2,     //  1 X 0 0 0       Always false (always folded)
65863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETEQ,         //  1 X 0 0 1       True if equal
65963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGT,         //  1 X 0 1 0       True if greater than
66063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGE,         //  1 X 0 1 1       True if greater than or equal
66163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETLT,         //  1 X 1 0 0       True if less than
662ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETLE,         //  1 X 1 0 1       True if less than or equal
66363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETNE,         //  1 X 1 1 0       True if not equal
66463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE2,      //  1 X 1 1 1       Always true (always folded)
66563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
666410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    SETCC_INVALID       // Marker value.
66763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
66863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
66963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isSignedIntSetCC - Return true if this is a setcc instruction that
67063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs a signed comparison when used with integer operands.
67163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isSignedIntSetCC(CondCode Code) {
67263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
67363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
67463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
67563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
67663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs an unsigned comparison when used with integer operands.
67763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isUnsignedIntSetCC(CondCode Code) {
67863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
67963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
68063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
68163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isTrueWhenEqual - Return true if the specified condition returns true if
68263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the two operands to the condition are equal.  Note that if one of the two
68363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operands is a NaN, this value is meaningless.
68463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isTrueWhenEqual(CondCode Cond) {
68563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond & 1) != 0;
68663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
68763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
68863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getUnorderedFlavor - This function returns 0 if the condition is always
68963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// false if an operand is a NaN, 1 if the condition is always true if the
69063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operand is a NaN, and 2 if the condition is undefined if the operand is a
69163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// NaN.
69263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getUnorderedFlavor(CondCode Cond) {
69363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond >> 3) & 3;
69463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
69563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
69663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
69763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// 'op' is a valid SetCC operation.
69863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCInverse(CondCode Operation, bool isInteger);
69963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
70063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
70163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// when given the operation for (X op Y).
70263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCSwappedOperands(CondCode Operation);
70363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
70463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCOrOperation - Return the result of a logical OR between different
70563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// comparisons of identical values: ((X op1 Y) | (X op2 Y)).  This
70663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
70763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
70863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
70963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
71063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCAndOperation - Return the result of a logical AND between
71163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)).  This
71263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
71363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
71463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
71563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}  // end llvm::ISD namespace
71663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
71763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
71863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
71963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple
72063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation.  Many nodes return multiple values,
72163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns
72263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number
72363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values).
72463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
72563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that
72663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node.  This pair
72763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of information is represented with the SDOperand value type.
72863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
729f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerclass SDOperand {
730f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerpublic:
73163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  SDNode *Val;        // The node defining the value we are using.
73263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned ResNo;     // Which return value of the node we are using.
73363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
734ace44dbbabe9ee0498834957632df2af0dbf9c59Reid Spencer  SDOperand() : Val(0), ResNo(0) {}
73563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {}
73663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
73763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool operator==(const SDOperand &O) const {
73863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Val == O.Val && ResNo == O.ResNo;
73963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
74063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool operator!=(const SDOperand &O) const {
74163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return !operator==(O);
74263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
74363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool operator<(const SDOperand &O) const {
74463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Val < O.Val || (Val == O.Val && ResNo < O.ResNo);
74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
74763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  SDOperand getValue(unsigned R) const {
74863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return SDOperand(Val, R);
74963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
75063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
751bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng  // isOperand - Return true if this node is an operand of N.
752bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng  bool isOperand(SDNode *N) const;
753bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng
75463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the ValueType of the referenced return value.
75563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
75663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline MVT::ValueType getValueType() const;
757ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  // Forwarding methods - These forward to the corresponding methods in SDNode.
75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getOpcode() const;
76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getNumOperands() const;
76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline const SDOperand &getOperand(unsigned i) const;
762c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline uint64_t getConstantOperandVal(unsigned i) const;
7630f66a9172175aa7c3055333358170581c999219bNate Begeman  inline bool isTargetOpcode() const;
7640f66a9172175aa7c3055333358170581c999219bNate Begeman  inline unsigned getTargetOpcode() const;
765a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner
766a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner  /// hasOneUse - Return true if there is exactly one operation using this
767a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner  /// result value of the defining operator.
768a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner  inline bool hasOneUse() const;
769e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman
770e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman  /// use_empty - Return true if there are no operations using this
771e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman  /// result value of the defining operator.
772e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman  inline bool use_empty() const;
77363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
776c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Chengtemplate<> struct DenseMapKeyInfo<SDOperand> {
777c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); }
778c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);}
779c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  static unsigned getHashValue(const SDOperand &Val) {
780c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng    return (unsigned)((uintptr_t)Val.Val >> 4) ^
781c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng           (unsigned)((uintptr_t)Val.Val >> 9) + Val.ResNo;
782c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  }
783c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  static bool isPod() { return true; }
784c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng};
785c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng
78663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on
78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperands as if they were SDNode*'s.
78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<SDOperand> {
78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static SimpleType getSimplifiedValue(const SDOperand &Val) {
79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return static_cast<SimpleType>(Val.Val);
79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
79463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<const SDOperand> {
79563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static SimpleType getSimplifiedValue(const SDOperand &Val) {
79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return static_cast<SimpleType>(Val.Val);
79863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
80163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
80263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG.
80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
804583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskeyclass SDNode : public FoldingSetNode {
8050442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  /// NodeType - The operation that this node performs.
8060442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
8070442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  unsigned short NodeType;
80863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
80963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// OperandsNeedDelete - This is true if OperandList was new[]'d.  If true,
81063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// then they will be delete[]'d when the node is destroyed.
81163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  bool OperandsNeedDelete : 1;
8120442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
813b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// NodeId - Unique id per SDNode in the DAG.
814b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int NodeId;
8150442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
816f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// OperandList - The values that are used by this operation.
8170442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
818f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  SDOperand *OperandList;
819f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner
820f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// ValueList - The types of the values this node defines.  SDNode's may
821f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// define multiple values simultaneously.
8222fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner  const MVT::ValueType *ValueList;
82363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
824f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// NumOperands/NumValues - The number of entries in the Operand/Value list.
825f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned short NumOperands, NumValues;
826b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
827b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  /// Prev/Next pointers - These pointers form the linked list of of the
828b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  /// AllNodes list in the current DAG.
829b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  SDNode *Prev, *Next;
830b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  friend struct ilist_traits<SDNode>;
83163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
83263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// Uses - These are all of the SDNode's that use a value produced by this
83363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// node.
8345892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner  SmallVector<SDNode*,3> Uses;
835917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner
836917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner  // Out-of-line virtual method to give class a home.
837917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner  virtual void ANCHOR();
83863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
839b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  virtual ~SDNode() {
840b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner    assert(NumOperands == 0 && "Operand list not cleared before deletion");
8413258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    NodeType = ISD::DELETED_NODE;
842b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  }
843b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
84463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
84563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //  Accessors
84663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //
84763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned getOpcode()  const { return NodeType; }
8480f66a9172175aa7c3055333358170581c999219bNate Begeman  bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
8490f66a9172175aa7c3055333358170581c999219bNate Begeman  unsigned getTargetOpcode() const {
8500f66a9172175aa7c3055333358170581c999219bNate Begeman    assert(isTargetOpcode() && "Not a target opcode!");
8510f66a9172175aa7c3055333358170581c999219bNate Begeman    return NodeType - ISD::BUILTIN_OP_END;
8520f66a9172175aa7c3055333358170581c999219bNate Begeman  }
85363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
85463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  size_t use_size() const { return Uses.size(); }
85563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool use_empty() const { return Uses.empty(); }
85663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool hasOneUse() const { return Uses.size() == 1; }
85763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
858b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// getNodeId - Return the unique node id.
859b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  ///
860b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int getNodeId() const { return NodeId; }
8610442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
8625892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner  typedef SmallVector<SDNode*,3>::const_iterator use_iterator;
8637ece380440238ad0630a225b85a09a2dbed1165aChris Lattner  use_iterator use_begin() const { return Uses.begin(); }
8647ece380440238ad0630a225b85a09a2dbed1165aChris Lattner  use_iterator use_end() const { return Uses.end(); }
8657ece380440238ad0630a225b85a09a2dbed1165aChris Lattner
866b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
867b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// indicated value.  This method ignores uses of other values defined by this
868b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// operation.
8694ee621125876cc954cba5280dd9395552755a871Evan Cheng  bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
8704ee621125876cc954cba5280dd9395552755a871Evan Cheng
87133d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  /// hasAnyUseOfValue - Return true if there are any use of the indicated
87233d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  /// value. This method ignores uses of other values defined by this operation.
87333d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  bool hasAnyUseOfValue(unsigned Value) const;
87433d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng
875e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// isOnlyUse - Return true if this node is the only use of N.
876e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
8774ee621125876cc954cba5280dd9395552755a871Evan Cheng  bool isOnlyUse(SDNode *N) const;
878b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner
879e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// isOperand - Return true if this node is an operand of N.
880e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
88180d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng  bool isOperand(SDNode *N) const;
88280d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng
883e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// isPredecessor - Return true if this node is a predecessor of N. This node
884e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// is either an operand of N or it can be reached by recursively traversing
885e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// up the operands.
886e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// NOTE: this is an expensive method. Use it carefully.
8877ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng  bool isPredecessor(SDNode *N) const;
8887ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng
88963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumOperands - Return the number of values used by this operation.
89063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
891f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumOperands() const { return NumOperands; }
89263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
893c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// getConstantOperandVal - Helper method returns the integer value of a
894c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// ConstantSDNode operand.
895c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  uint64_t getConstantOperandVal(unsigned Num) const;
896c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
89763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const SDOperand &getOperand(unsigned Num) const {
898f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(Num < NumOperands && "Invalid child # of SDNode!");
899f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    return OperandList[Num];
90063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
901c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
902f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  typedef const SDOperand* op_iterator;
903f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_begin() const { return OperandList; }
904f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_end() const { return OperandList+NumOperands; }
90550f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner
90663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
9070b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  SDVTList getVTList() const {
9080b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    SDVTList X = { ValueList, NumValues };
9090b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    return X;
9100b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  };
9110b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
91263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumValues - Return the number of values defined/returned by this
91363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operator.
91463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
915f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumValues() const { return NumValues; }
91663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
91763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the type of a specified result.
91863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
91963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MVT::ValueType getValueType(unsigned ResNo) const {
920f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(ResNo < NumValues && "Illegal result number!");
921f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    return ValueList[ResNo];
92263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
9239eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen
924f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  typedef const MVT::ValueType* value_iterator;
925f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_begin() const { return ValueList; }
926f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_end() const { return ValueList+NumValues; }
92763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
9286e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  /// getOperationName - Return the opcode of this operation for printing.
9296e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  ///
930ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer  std::string getOperationName(const SelectionDAG *G = 0) const;
931144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  static const char* getIndexedModeName(ISD::MemIndexedMode AM);
93263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  void dump() const;
933efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner  void dump(const SelectionDAG *G) const;
93463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
93563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *) { return true; }
93663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
937583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  /// Profile - Gather unique data for the node.
938583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  ///
939583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  void Profile(FoldingSetNodeID &ID);
940583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey
94163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
94263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
943109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner
944109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  /// getValueTypeList - Return a pointer to the specified value type.
945109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  ///
946109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  static MVT::ValueType *getValueTypeList(MVT::ValueType VT);
94763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  static SDVTList getSDVTList(MVT::ValueType VT) {
94863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    SDVTList Ret = { getValueTypeList(VT), 1 };
94963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    return Ret;
9502d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
95163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
952ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner  SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps)
953b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng    : NodeType(Opc), NodeId(-1) {
95463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    OperandsNeedDelete = true;
955f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner    NumOperands = NumOps;
956bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    OperandList = NumOps ? new SDOperand[NumOperands] : 0;
957f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner
958bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    for (unsigned i = 0; i != NumOps; ++i) {
959f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner      OperandList[i] = Ops[i];
960bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      Ops[i].Val->Uses.push_back(this);
9610442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner    }
962bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
963ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    ValueList = VTs.VTs;
964ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    NumValues = VTs.NumVTs;
965b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner    Prev = 0; Next = 0;
966f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  }
967bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  SDNode(unsigned Opc, SDVTList VTs) : NodeType(Opc), NodeId(-1) {
968bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    OperandsNeedDelete = false;  // Operands set with InitOperands.
969bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    NumOperands = 0;
970bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    OperandList = 0;
971bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
972bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    ValueList = VTs.VTs;
973bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    NumValues = VTs.NumVTs;
974bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    Prev = 0; Next = 0;
975bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
976bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
977bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  /// InitOperands - Initialize the operands list of this node with the
978bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  /// specified values, which are part of the node (thus they don't need to be
979bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  /// copied in or allocated).
980bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  void InitOperands(SDOperand *Ops, unsigned NumOps) {
981bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    assert(OperandList == 0 && "Operands already set!");
982bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    NumOperands = NumOps;
983bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    OperandList = Ops;
984bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
985bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    for (unsigned i = 0; i != NumOps; ++i)
986bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      Ops[i].Val->Uses.push_back(this);
987bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
988bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
989d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner  /// MorphNodeTo - This frees the operands of the current node, resets the
990d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner  /// opcode, types, and operands to the specified value.  This should only be
991d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner  /// used by the SelectionDAG class.
992d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner  void MorphNodeTo(unsigned Opc, SDVTList L,
993d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner                   const SDOperand *Ops, unsigned NumOps);
9941b95095857b78e12138c22e76c7936611c51355bChris Lattner
9958c3484c5181834e6b7060a6064ac769878101f23Chris Lattner  void addUser(SDNode *User) {
9968c3484c5181834e6b7060a6064ac769878101f23Chris Lattner    Uses.push_back(User);
9971b95095857b78e12138c22e76c7936611c51355bChris Lattner  }
998d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner  void removeUser(SDNode *User) {
999d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner    // Remove this user from the operand's use list.
1000d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner    for (unsigned i = Uses.size(); ; --i) {
1001d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner      assert(i != 0 && "Didn't find user!");
1002d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner      if (Uses[i-1] == User) {
10038c3484c5181834e6b7060a6064ac769878101f23Chris Lattner        Uses[i-1] = Uses.back();
10048c3484c5181834e6b7060a6064ac769878101f23Chris Lattner        Uses.pop_back();
10058c3484c5181834e6b7060a6064ac769878101f23Chris Lattner        return;
1006d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner      }
1007d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner    }
1008d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner  }
1009b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng
1010b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  void setNodeId(int Id) {
1011b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng    NodeId = Id;
1012b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  }
101363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
101463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
101563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
101663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// Define inline functions from the SDOperand class.
101763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
101863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getOpcode() const {
101963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  return Val->getOpcode();
102063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
102163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline MVT::ValueType SDOperand::getValueType() const {
102263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  return Val->getValueType(ResNo);
102363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
102463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getNumOperands() const {
102563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  return Val->getNumOperands();
102663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
102763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline const SDOperand &SDOperand::getOperand(unsigned i) const {
102863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  return Val->getOperand(i);
102963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1030c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chenginline uint64_t SDOperand::getConstantOperandVal(unsigned i) const {
1031c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  return Val->getConstantOperandVal(i);
1032c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
10330f66a9172175aa7c3055333358170581c999219bNate Begemaninline bool SDOperand::isTargetOpcode() const {
10340f66a9172175aa7c3055333358170581c999219bNate Begeman  return Val->isTargetOpcode();
10350f66a9172175aa7c3055333358170581c999219bNate Begeman}
10360f66a9172175aa7c3055333358170581c999219bNate Begemaninline unsigned SDOperand::getTargetOpcode() const {
10370f66a9172175aa7c3055333358170581c999219bNate Begeman  return Val->getTargetOpcode();
10380f66a9172175aa7c3055333358170581c999219bNate Begeman}
1039a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattnerinline bool SDOperand::hasOneUse() const {
1040a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner  return Val->hasNUsesOfValue(1, ResNo);
1041a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner}
1042e1b50639a860934685dff840e1826b16dbe6a344Dan Gohmaninline bool SDOperand::use_empty() const {
1043e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman  return !Val->hasAnyUseOfValue(ResNo);
1044e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman}
104563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
10463f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes.  This is solely
10473f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
10483f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode {
10493f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
10503f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  SDOperand Op;
10513f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
10523f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X)
10533f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs), Op(X) {
10543f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    InitOperands(&Op, 1);
10553f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
10563f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
10573f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
10583f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes.  This is solely
10593f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
10603f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode {
10613f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
10623f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  SDOperand Ops[2];
10633f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
10643f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y)
10653f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs) {
10663f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[0] = X;
10673f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[1] = Y;
10683f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    InitOperands(Ops, 2);
10693f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
10703f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
10713f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
10723f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely
10733f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
10743f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode {
10753f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
10763f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  SDOperand Ops[3];
10773f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
10783f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y,
10793f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner                SDOperand Z)
10803f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs) {
10813f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[0] = X;
10823f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[1] = Y;
10833f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[2] = Z;
10843f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    InitOperands(Ops, 3);
10853f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
10863f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
10873f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
10883f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
1089d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that
1090d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its
1091d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand.  This node should be directly created by end-users and not added to
1092d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list.
1093d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode {
1094c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1095bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  SDOperand Op;
1096d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic:
1097423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit HandleSDNode(SDOperand X)
1098bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) {
1099bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    InitOperands(&Op, 1);
1100bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
110148b85926524f9d29ae600123c90194cd73fd629eChris Lattner  ~HandleSDNode();
1102bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  SDOperand getValue() const { return Op; }
1103d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner};
1104d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner
110547725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerclass StringSDNode : public SDNode {
110647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  std::string Value;
1107c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
110847725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerprotected:
110947725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  friend class SelectionDAG;
1110423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit StringSDNode(const std::string &val)
1111bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) {
111247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  }
111347725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerpublic:
111447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  const std::string &getValue() const { return Value; }
111547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  static bool classof(const StringSDNode *) { return true; }
111647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  static bool classof(const SDNode *N) {
111747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    return N->getOpcode() == ISD::STRING;
111847725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  }
111947725d059b259f8a0c145478300c9e9caa006b59Chris Lattner};
112063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
112163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode {
112263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  uint64_t Value;
1123c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
112463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
112563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1126056f9f61d071c6c583951678f2bf543a1316efccChris Lattner  ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT)
1127bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1128bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      Value(val) {
112963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
113063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
113163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
113263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  uint64_t getValue() const { return Value; }
113363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
113463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int64_t getSignExtended() const {
113563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    unsigned Bits = MVT::getSizeInBits(getValueType(0));
1136f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattner    return ((int64_t)Value << (64-Bits)) >> (64-Bits);
113763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
113863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
113963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool isNullValue() const { return Value == 0; }
114063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool isAllOnesValue() const {
1141885a87ef8512a184a58a0ebe39705ccb221749efChris Lattner    return Value == MVT::getIntVTBitMask(getValueType(0));
114263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
114363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
114463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantSDNode *) { return true; }
114563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1146056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    return N->getOpcode() == ISD::Constant ||
1147056f9f61d071c6c583951678f2bf543a1316efccChris Lattner           N->getOpcode() == ISD::TargetConstant;
114863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
114963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
115063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
115163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode {
11528bb369b8072c919ef5802f639a52b17620201190Dale Johannesen  APFloat Value;
1153c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1154c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  // Longterm plan: replace all uses of getValue with getValueAPF, remove
1155c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  // getValue, rename getValueAPF to getValue.
115663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
115763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1158e6c1742914149d44360fbf05a653041a672282afDale Johannesen  ConstantFPSDNode(bool isTarget, const APFloat& val, MVT::ValueType VT)
115987503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
116087503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen             getSDVTList(VT)), Value(val) {
116163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
116263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
116363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1164e6c1742914149d44360fbf05a653041a672282afDale Johannesen  const APFloat& getValueAPF() const { return Value; }
116563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
116663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isExactlyValue - We don't rely on operator== working on double values, as
116763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
116863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// As such, this method can be used to do an exact bit-for-bit comparison of
116963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// two floating point values.
1170c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen
1171c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// We leave the version with the double argument here because it's just so
1172c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// convenient to write "2.0" and the like.  Without this function we'd
1173c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// have to duplicate its logic everywhere it's called.
117487503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen  bool isExactlyValue(double V) const {
117587503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen    if (getValueType(0)==MVT::f64)
117687503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen      return isExactlyValue(APFloat(V));
117787503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen    else
117887503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen      return isExactlyValue(APFloat((float)V));
117987503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen  }
1180e6c1742914149d44360fbf05a653041a672282afDale Johannesen  bool isExactlyValue(const APFloat& V) const;
118163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1182f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen  bool isValueValidForType(MVT::ValueType VT, const APFloat& Val);
1183f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen
118463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantFPSDNode *) { return true; }
118563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1186ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    return N->getOpcode() == ISD::ConstantFP ||
1187ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner           N->getOpcode() == ISD::TargetConstantFP;
118863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
118963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
119063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
119163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode {
119263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *TheGlobal;
1193404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng  int Offset;
1194c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
119563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
119663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
119761ca74bc3a29b2af2be7e4bd612289da8aae85b5Evan Cheng  GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
11982c5c111b6c144b05718404c85b9dfcc76b1619e7Lauro Ramos Venancio                      int o = 0);
119963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
120063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
120163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *getGlobal() const { return TheGlobal; }
1202404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng  int getOffset() const { return Offset; }
120363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
120463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const GlobalAddressSDNode *) { return true; }
120563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1206f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    return N->getOpcode() == ISD::GlobalAddress ||
1207b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::TargetGlobalAddress ||
1208b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::GlobalTLSAddress ||
1209b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::TargetGlobalTLSAddress;
121063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
121163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
121263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
121363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode {
121463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int FI;
1215c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
121663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
121763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1218afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner  FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
1219bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1220bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      FI(fi) {
122163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
122263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
122363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
122463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int getIndex() const { return FI; }
122563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
122663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const FrameIndexSDNode *) { return true; }
122763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1228afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    return N->getOpcode() == ISD::FrameIndex ||
1229afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner           N->getOpcode() == ISD::TargetFrameIndex;
123063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
123163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
123263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
123337efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode {
123437efe6764568a3829fee26aba532283131d1a104Nate Begeman  int JTI;
1235c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
123637efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected:
123737efe6764568a3829fee26aba532283131d1a104Nate Begeman  friend class SelectionDAG;
123837efe6764568a3829fee26aba532283131d1a104Nate Begeman  JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg)
1239bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1240bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      JTI(jti) {
124163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
124237efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic:
124337efe6764568a3829fee26aba532283131d1a104Nate Begeman
124437efe6764568a3829fee26aba532283131d1a104Nate Begeman    int getIndex() const { return JTI; }
124537efe6764568a3829fee26aba532283131d1a104Nate Begeman
124637efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const JumpTableSDNode *) { return true; }
124737efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const SDNode *N) {
124837efe6764568a3829fee26aba532283131d1a104Nate Begeman    return N->getOpcode() == ISD::JumpTable ||
124937efe6764568a3829fee26aba532283131d1a104Nate Begeman           N->getOpcode() == ISD::TargetJumpTable;
125037efe6764568a3829fee26aba532283131d1a104Nate Begeman  }
125137efe6764568a3829fee26aba532283131d1a104Nate Begeman};
125237efe6764568a3829fee26aba532283131d1a104Nate Begeman
125363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode {
1254d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  union {
1255d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Constant *ConstVal;
1256d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    MachineConstantPoolValue *MachineCPVal;
1257d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  } Val;
1258baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1259b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned Alignment;
1260c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
126163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
126263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1263404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng  ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT,
1264404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng                     int o=0)
1265ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1266bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(0) {
1267d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1268d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1269d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1270404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng  ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o,
1271404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng                     unsigned Align)
1272ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1273bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(Align) {
1274d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1275d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1276d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1277d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1278d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng                     MVT::ValueType VT, int o=0)
1279ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1280bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(0) {
1281d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1282d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1283d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1284d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1285d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1286d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng                     MVT::ValueType VT, int o, unsigned Align)
1287ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1288bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(Align) {
1289d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1290d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1291d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1292d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
129363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
129463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1295d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  bool isMachineConstantPoolEntry() const {
1296d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return (int)Offset < 0;
1297d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1298d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1299d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  Constant *getConstVal() const {
1300d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1301d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.ConstVal;
1302d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1303d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1304d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  MachineConstantPoolValue *getMachineCPVal() const {
1305d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1306d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.MachineCPVal;
1307d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1308d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1309baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int getOffset() const {
1310baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng    return Offset & ~(1 << (sizeof(unsigned)*8-1));
1311baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  }
1312ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner
1313ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // Return the alignment of this constant pool object, which is either 0 (for
1314ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // default alignment) or log2 of the desired value.
1315b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned getAlignment() const { return Alignment; }
131663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1317d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  const Type *getType() const;
1318d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
131963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantPoolSDNode *) { return true; }
132063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1321aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    return N->getOpcode() == ISD::ConstantPool ||
1322aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner           N->getOpcode() == ISD::TargetConstantPool;
132363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
132463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
132563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
132663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode {
132763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *MBB;
1328c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
132963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
133063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1331423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1332bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
133363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
133463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
133563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
133663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *getBasicBlock() const { return MBB; }
133763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
133863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const BasicBlockSDNode *) { return true; }
133963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
134063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return N->getOpcode() == ISD::BasicBlock;
134163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
134263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
134363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
13442d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode {
13452d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *V;
1346691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth  int offset;
1347c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
13482d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected:
13492d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  friend class SelectionDAG;
1350691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth  SrcValueSDNode(const Value* v, int o)
1351bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v), offset(o) {
135263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
13532d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
13542d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic:
13552d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *getValue() const { return V; }
1356691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth  int getOffset() const { return offset; }
13572d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
13582d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SrcValueSDNode *) { return true; }
13592d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SDNode *N) {
13602d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth    return N->getOpcode() == ISD::SRCVALUE;
13612d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
13622d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth};
13632d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
136463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1365d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode {
136663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned Reg;
1367c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
136863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
136963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1370d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner  RegisterSDNode(unsigned reg, MVT::ValueType VT)
1371bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
137263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
137363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
137463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
137563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned getReg() const { return Reg; }
137663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1377d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner  static bool classof(const RegisterSDNode *) { return true; }
137863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1379d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    return N->getOpcode() == ISD::Register;
138063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
138163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
138263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
138363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ExternalSymbolSDNode : public SDNode {
138463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *Symbol;
1385c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
138663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
138763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
13882a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth  ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
1389ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
1390bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Symbol(Sym) {
139163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
139263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
139363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
139463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *getSymbol() const { return Symbol; }
139563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
139663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ExternalSymbolSDNode *) { return true; }
139763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
13982a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth    return N->getOpcode() == ISD::ExternalSymbol ||
13992a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth           N->getOpcode() == ISD::TargetExternalSymbol;
140063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
140163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
140263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
14037cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode {
140463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ISD::CondCode Condition;
1405c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
140663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
140763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1408423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit CondCodeSDNode(ISD::CondCode Cond)
1409bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
141063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
141163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
141263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
14137cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  ISD::CondCode get() const { return Condition; }
141463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
14157cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  static bool classof(const CondCodeSDNode *) { return true; }
141663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
14177cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    return N->getOpcode() == ISD::CONDCODE;
141863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
141963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
142063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
142115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// VTSDNode - This class is used to represent MVT::ValueType's, which are used
142215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations.
142315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode {
142415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  MVT::ValueType ValueType;
1425c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
142615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected:
142715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  friend class SelectionDAG;
1428423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit VTSDNode(MVT::ValueType VT)
1429bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
143063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
143115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic:
143215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
143315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  MVT::ValueType getVT() const { return ValueType; }
143415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
143515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const VTSDNode *) { return true; }
143615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const SDNode *N) {
143715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    return N->getOpcode() == ISD::VALUETYPE;
143815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  }
143915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner};
144015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
144124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
144224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
144324446e253a17720f6462288255ab5ebd13b8491fEvan Chengclass LoadSDNode : public SDNode {
1444c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1445bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  SDOperand Ops[3];
1446bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
144781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // AddrMode - unindexed, pre-indexed, post-indexed.
1448144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  ISD::MemIndexedMode AddrMode;
144981c384578828dde08f63a4f030f4860a92391cddEvan Cheng
145081c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // ExtType - non-ext, anyext, sext, zext.
145181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ISD::LoadExtType ExtType;
145281c384578828dde08f63a4f030f4860a92391cddEvan Cheng
14532e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng  // LoadedVT - VT of loaded value before extension.
14542e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng  MVT::ValueType LoadedVT;
145581c384578828dde08f63a4f030f4860a92391cddEvan Cheng
145681c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // SrcValue - Memory location for alias analysis.
145724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  const Value *SrcValue;
145881c384578828dde08f63a4f030f4860a92391cddEvan Cheng
145981c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // SVOffset - Memory location offset.
146024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  int SVOffset;
146181c384578828dde08f63a4f030f4860a92391cddEvan Cheng
146281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // Alignment - Alignment of memory location in bytes.
146324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  unsigned Alignment;
146481c384578828dde08f63a4f030f4860a92391cddEvan Cheng
146581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // IsVolatile - True if the load is volatile.
146624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool IsVolatile;
146724446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
146824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
1469ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner  LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs,
1470144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
147195c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb             const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
1472bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::LOAD, VTs),
14732e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng      AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O),
147424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      Alignment(Align), IsVolatile(Vol) {
1475bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    Ops[0] = ChainPtrOff[0]; // Chain
1476bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    Ops[1] = ChainPtrOff[1]; // Ptr
1477bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    Ops[2] = ChainPtrOff[2]; // Off
1478bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    InitOperands(Ops, 3);
147995c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb    assert(Align != 0 && "Loads should have non-zero aligment");
148063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    assert((getOffset().getOpcode() == ISD::UNDEF ||
148163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner            AddrMode != ISD::UNINDEXED) &&
14828862ef148100070b7bf28beead3951464250c926Evan Cheng           "Only indexed load has a non-undef offset operand");
148324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
148424446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
148524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
148681c384578828dde08f63a4f030f4860a92391cddEvan Cheng  const SDOperand getChain() const { return getOperand(0); }
148781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  const SDOperand getBasePtr() const { return getOperand(1); }
148881c384578828dde08f63a4f030f4860a92391cddEvan Cheng  const SDOperand getOffset() const { return getOperand(2); }
1489144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  ISD::MemIndexedMode getAddressingMode() const { return AddrMode; }
149024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ISD::LoadExtType getExtensionType() const { return ExtType; }
14912e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng  MVT::ValueType getLoadedVT() const { return LoadedVT; }
149224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  const Value *getSrcValue() const { return SrcValue; }
149324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  int getSrcValueOffset() const { return SVOffset; }
149424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  unsigned getAlignment() const { return Alignment; }
149524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool isVolatile() const { return IsVolatile; }
149624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
149724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const LoadSDNode *) { return true; }
149824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
149924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD;
150024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
150124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
150224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
150324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes.
150424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
150524446e253a17720f6462288255ab5ebd13b8491fEvan Chengclass StoreSDNode : public SDNode {
1506c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1507bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  SDOperand Ops[4];
1508bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
150981c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // AddrMode - unindexed, pre-indexed, post-indexed.
1510144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  ISD::MemIndexedMode AddrMode;
151181c384578828dde08f63a4f030f4860a92391cddEvan Cheng
151281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // IsTruncStore - True is the op does a truncation before store.
151381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  bool IsTruncStore;
151481c384578828dde08f63a4f030f4860a92391cddEvan Cheng
15152e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng  // StoredVT - VT of the value after truncation.
151681c384578828dde08f63a4f030f4860a92391cddEvan Cheng  MVT::ValueType StoredVT;
151781c384578828dde08f63a4f030f4860a92391cddEvan Cheng
151881c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // SrcValue - Memory location for alias analysis.
151924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  const Value *SrcValue;
152081c384578828dde08f63a4f030f4860a92391cddEvan Cheng
152181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // SVOffset - Memory location offset.
152224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  int SVOffset;
152381c384578828dde08f63a4f030f4860a92391cddEvan Cheng
152481c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // Alignment - Alignment of memory location in bytes.
152524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  unsigned Alignment;
152681c384578828dde08f63a4f030f4860a92391cddEvan Cheng
152781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // IsVolatile - True if the store is volatile.
152824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool IsVolatile;
152924446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
153024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
1531ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner  StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs,
1532144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng              ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT,
153324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
1534bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::STORE, VTs),
153524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      AddrMode(AM), IsTruncStore(isTrunc), StoredVT(SVT), SrcValue(SV),
153624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      SVOffset(O), Alignment(Align), IsVolatile(Vol) {
1537bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    Ops[0] = ChainValuePtrOff[0]; // Chain
1538bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    Ops[1] = ChainValuePtrOff[1]; // Value
1539bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    Ops[2] = ChainValuePtrOff[2]; // Ptr
1540bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    Ops[3] = ChainValuePtrOff[3]; // Off
1541bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    InitOperands(Ops, 4);
154295c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb    assert(Align != 0 && "Stores should have non-zero aligment");
154363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    assert((getOffset().getOpcode() == ISD::UNDEF ||
154463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner            AddrMode != ISD::UNINDEXED) &&
15458862ef148100070b7bf28beead3951464250c926Evan Cheng           "Only indexed store has a non-undef offset operand");
154624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
154724446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
154824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
154981c384578828dde08f63a4f030f4860a92391cddEvan Cheng  const SDOperand getChain() const { return getOperand(0); }
15508b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  const SDOperand getValue() const { return getOperand(1); }
15518b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  const SDOperand getBasePtr() const { return getOperand(2); }
15528b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  const SDOperand getOffset() const { return getOperand(3); }
1553144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  ISD::MemIndexedMode getAddressingMode() const { return AddrMode; }
155424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool isTruncatingStore() const { return IsTruncStore; }
155524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  MVT::ValueType getStoredVT() const { return StoredVT; }
155624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  const Value *getSrcValue() const { return SrcValue; }
155724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  int getSrcValueOffset() const { return SVOffset; }
155824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  unsigned getAlignment() const { return Alignment; }
155924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool isVolatile() const { return IsVolatile; }
156024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
15616d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng  static bool classof(const StoreSDNode *) { return true; }
156224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
156324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::STORE;
156424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
156524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
156624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
156715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
15681080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
15691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNode *Node;
15701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned Operand;
1571ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
15721080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
15731080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic:
15741080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator==(const SDNodeIterator& x) const {
15751080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return Operand == x.Operand;
15761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
15771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
15781080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
15791080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNodeIterator &operator=(const SDNodeIterator &I) {
15801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
15811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    Operand = I.Operand;
15821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
15831080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
1584ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
15851080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator*() const {
15861080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return Node->getOperand(Operand).Val;
15871080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
15881080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator->() const { return operator*(); }
1589ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
15901080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator& operator++() {                // Preincrement
15911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    ++Operand;
15921080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
15931080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
15941080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator operator++(int) { // Postincrement
1595ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SDNodeIterator tmp = *this; ++*this; return tmp;
15961080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
15971080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
15981080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
15991080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator end  (SDNode *N) {
16001080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator(N, N->getNumOperands());
16011080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
16021080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
16031080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned getOperand() const { return Operand; }
16041080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNode *getNode() const { return Node; }
16051080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
16061080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
16071080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> {
16081080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNode NodeType;
16091080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNodeIterator ChildIteratorType;
16101080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static inline NodeType *getEntryNode(SDNode *N) { return N; }
1611ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_begin(NodeType *N) {
16121080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::begin(N);
16131080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
1614ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_end(NodeType *N) {
16151080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::end(N);
16161080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
16171080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
16181080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
1619b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<>
1620b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnerstruct ilist_traits<SDNode> {
1621b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static SDNode *getPrev(const SDNode *N) { return N->Prev; }
1622b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static SDNode *getNext(const SDNode *N) { return N->Next; }
1623b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1624b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; }
1625b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; }
1626b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1627b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static SDNode *createSentinel() {
1628bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other));
1629b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  }
1630b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static void destroySentinel(SDNode *N) { delete N; }
1631b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  //static SDNode *createNode(const SDNode &V) { return new SDNode(V); }
1632b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1633b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1634b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  void addNodeToList(SDNode *NTy) {}
1635b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  void removeNodeFromList(SDNode *NTy) {}
1636b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  void transferNodesFromList(iplist<SDNode, ilist_traits> &L2,
1637b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner                             const ilist_iterator<SDNode> &X,
1638b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner                             const ilist_iterator<SDNode> &Y) {}
1639b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner};
1640b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1641c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD {
164224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// isNON_EXTLoad - Returns true if the specified node is a non-extending
164324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// load.
164424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  inline bool isNON_EXTLoad(const SDNode *N) {
164524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD &&
164624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
164724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
164824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
1649c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
1650c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
1651c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isEXTLoad(const SDNode *N) {
165224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD &&
165324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
1654c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
1655c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1656c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
1657c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
1658c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isSEXTLoad(const SDNode *N) {
165924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD &&
166024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
1661c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
1662c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1663c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
1664c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
1665c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isZEXTLoad(const SDNode *N) {
166624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD &&
166724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
1668c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
16698b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
167002c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  /// isUNINDEXEDLoad - Returns true if the specified node is a unindexed load.
167102c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  ///
167202c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  inline bool isUNINDEXEDLoad(const SDNode *N) {
167302c50e4891841c28b2a743731dfc60744bb78879Evan Cheng    return N->getOpcode() == ISD::LOAD &&
167402c50e4891841c28b2a743731dfc60744bb78879Evan Cheng      cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
167502c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  }
167602c50e4891841c28b2a743731dfc60744bb78879Evan Cheng
16778b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
16788b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
16798b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isNON_TRUNCStore(const SDNode *N) {
16808b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng    return N->getOpcode() == ISD::STORE &&
16818b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng      !cast<StoreSDNode>(N)->isTruncatingStore();
16828b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
16838b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
16848b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isTRUNCStore - Returns true if the specified node is a truncating
16858b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
16868b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isTRUNCStore(const SDNode *N) {
16878b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng    return N->getOpcode() == ISD::STORE &&
16888b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng      cast<StoreSDNode>(N)->isTruncatingStore();
16898b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
1690c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
1691c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1692c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
169363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace
169463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
169563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif
1696