SelectionDAGNodes.h revision d23e0f81bc76902052e9198cad3a0d87a412a632
163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//                     The LLVM Compiler Infrastructure
463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// 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"
234fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman#include "llvm/Constants.h"
24583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/ADT/FoldingSet.h"
251080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/GraphTraits.h"
2643d1fd449f1a0ac9d9dafa0b9569bb6b2e976198Anton Korobeynikov#include "llvm/ADT/iterator.h"
27fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/ilist_node.h"
28fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/STLExtras.h"
29d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h"
3036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman#include "llvm/CodeGen/MachineMemOperand.h"
310e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/Allocator.h"
320e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/RecyclingAllocator.h"
3339931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h"
3463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert>
3563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm {
3763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG;
3963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue;
4063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock;
41d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue;
4263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode;
437f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanclass CompileUnitDesc;
4476c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate <typename T> struct DenseMapInfo;
4563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type;
468e4018e2de52c534405d7155c7009d0b35afb861Cedric Venettemplate <typename T> struct ilist_traits;
4763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by
490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG.  Instances of this simple value class are returned by
500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...).
510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner///
520b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList {
5383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  const MVT *VTs;
540b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  unsigned short NumVTs;
550b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner};
560b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
5763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the
5863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types.
5963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
60e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen/// If you add new elements here you should increase OpActionsCapacity in
61e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen/// TargetLowering.h by the number of new elements.
6263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD {
63d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov
6463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
6563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::NodeType enum - This enum defines all of the operators valid in a
6663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SelectionDAG.
6763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
6863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum NodeType {
693258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // DELETED_NODE - This is an illegal flag value that is used to catch
703258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // errors.  This opcode is not a legal opcode for any node.
713258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    DELETED_NODE,
723258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner
738a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // EntryToken - This is the marker used to indicate the start of the region.
748a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    EntryToken,
758a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner
76b2ab0e7471df7126a5b63fe8414b95c9584a0214Bill Wendling    // TokenFactor - This node takes multiple tokens as input and produces a
778a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // single token result.  This is used to represent the fact that the operand
788a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // operators are independent of each other.
798a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    TokenFactor,
80f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman
81f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // AssertSext, AssertZext - These nodes record if a register contains a
82f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // value that has already been zero or sign extended from a narrower type.
83f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // These nodes take two operands.  The first is the node that has already
84f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // been extended, and the second is a value type node indicating the width
85f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // of the extension
86f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    AssertSext, AssertZext,
87ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
888a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // Various leaf nodes.
897f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register,
901ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    Constant, ConstantFP,
91b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    GlobalAddress, GlobalTLSAddress, FrameIndex,
92056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    JumpTable, ConstantPool, ExternalSymbol,
931ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng
9482c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    // The address of the GOT
9582c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    GLOBAL_OFFSET_TABLE,
96bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman
97bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
98bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // llvm.returnaddress on the DAG.  These nodes take one operand, the index
99bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // of the frame or return address to return.  An index of zero corresponds
100bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // to the current function's frame or return address, an index of one to the
101bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // parent's frame or return address, and so on.
102bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    FRAMEADDR, RETURNADDR,
1032365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
1042365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
1052365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // first (possible) on-stack argument. This is needed for correct stack
1062365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // adjustment during unwind.
1072365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    FRAME_TO_ARGS_OFFSET,
108f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
109f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the
110f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // address of the exception block on entry to an landing pad block.
111f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    EXCEPTIONADDR,
112f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
113f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents
114f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // the selection index of the exception thrown.
115f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    EHSELECTION,
116beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth
1172365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
1182365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // 'eh_return' gcc dwarf builtin, which is used to return from
1192365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // exception. The general meaning is: adjust stack by OFFSET and pass
1202365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // execution to HANDLER. Many platform-related details also :)
1212365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    EH_RETURN,
1222365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
123ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // TargetConstant* - Like Constant*, but the DAG does not do any folding or
124ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // simplification of the constant.
125056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    TargetConstant,
126ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    TargetConstantFP,
127f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner
128f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
129f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // anything else with this node, and this is valid in the target-specific
130f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // dag, turning into a GlobalAddress operand.
131f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    TargetGlobalAddress,
132b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    TargetGlobalTLSAddress,
133afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    TargetFrameIndex,
13437efe6764568a3829fee26aba532283131d1a104Nate Begeman    TargetJumpTable,
135aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    TargetConstantPool,
136056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    TargetExternalSymbol,
13772601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner
138ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
139ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with no side effects.
140ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// The first operand is the ID number of the intrinsic from the
141ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// llvm::Intrinsic namespace.  The operands to the intrinsic follow.  The
142ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// node has returns the result of the intrinsic.
143ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_WO_CHAIN,
144ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
145ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
146ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
147ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// returns a result.  The first operand is a chain pointer.  The second is
148ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// the ID number of the intrinsic from the llvm::Intrinsic namespace.  The
149ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// operands to the intrinsic follow.  The node has two results, the result
150ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// of the intrinsic and an output chain.
151ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_W_CHAIN,
15263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
153ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
154ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
155ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// does not return a result.  The first operand is a chain pointer.  The
156ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// second is the ID number of the intrinsic from the llvm::Intrinsic
157ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// namespace.  The operands to the intrinsic follow.
158ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_VOID,
159ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
160d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // CopyToReg - This node has three operands: a chain, a register number to
161d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // set to this value, and a value.
16263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyToReg,
16363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
16463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // CopyFromReg - This node indicates that the input value is a virtual or
16563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // physical register that is defined outside of the scope of this
166ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman    // SelectionDAG.  The register is available from the RegisterSDNode object.
16763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyFromReg,
16863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
169fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    // UNDEF - An undefined node
170fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    UNDEF,
171681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner
172b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
173b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// represents the formal arguments for a function.  CC# is a Constant value
174b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// indicating the calling convention of the function, and ISVARARG is a
175b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// flag that indicates whether the function is varargs or not. This node
176b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// has one result value for each incoming argument, plus one for the output
177b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// chain. It must be custom legalized. See description of CALL node for
178b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FLAG argument contents explanation.
179c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner    ///
180681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner    FORMAL_ARGUMENTS,
1816c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner
182095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CALLEE,
183b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    ///                              ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn)
1846c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    /// This node represents a fully general function call, before the legalizer
185b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// runs.  This has one result value for each argument / flag pair, plus
186b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// a chain result. It must be custom legalized. Flag argument indicates
187b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// misc. argument attributes. Currently:
188b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 0 - signness
189b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 1 - 'inreg' attribute
190b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 2 - 'sret' attribute
191594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 4 - 'byval' attribute
192594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 5 - 'nest' attribute
193594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 6-9 - alignment of byval structures
194594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 10-26 - size of byval structures
19513a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio    /// Bits 31:27 - argument ABI alignment in the first argument piece and
19613a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio    /// alignment '1' in other argument pieces.
197095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    ///
198095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// CALL nodes use the CallSDNode subclass of SDNode, which
199095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// additionally carries information about the calling convention,
200095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// whether the call is varargs, and if it's marked as a tail call.
201095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    ///
2026c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    CALL,
203fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman
20425eb043759c23b61769108f78382eb9701c41db2Duncan Sands    // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by
205041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // a Constant, which is required to be operand #1) half of the integer or
206041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // float value specified as operand #0.  This is only for use before
207041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // legalization, for values that will be broken into multiple registers.
20863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    EXTRACT_ELEMENT,
20963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
21063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.  Given
21163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // two values of the same integer value type, this produces a value twice as
21263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // big.  Like EXTRACT_ELEMENT, this can only be used before legalization.
21363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BUILD_PAIR,
214041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands
215006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // MERGE_VALUES - This node takes multiple discrete operands and returns
216006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // them all as its individual results.  This nodes has exactly the same
217006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // number of inputs and outputs, and is only valid before legalization.
218006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // This node is useful for some pieces of the code generator that want to
219006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // think about a single node with multiple results, not multiple nodes.
220006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    MERGE_VALUES,
22163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
222615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple integer binary arithmetic operators.
223bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
224fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman
225fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing
226b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands    // a signed/unsigned value of type i[2*N], and return the full value as
227fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // two results, each of type iN.
228fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    SMUL_LOHI, UMUL_LOHI,
229fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman
230fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and
231fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // remainder result.
232fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    SDIVREM, UDIVREM,
233615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner
23455e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    // CARRY_FALSE - This node is used when folding other nodes,
23555e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    // like ADDC/SUBC, which indicate the carry result is always false.
23655e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    CARRY_FALSE,
23755e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner
238551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-setting nodes for multiple precision addition and subtraction.
239551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // These nodes take two operands of the same value type, and produce two
240551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // results.  The first result is the normal add or sub result, the second
241551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // result is the carry flag result.
242551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDC, SUBC,
243551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman
244551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-using nodes for multiple precision addition and subtraction.  These
245551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // nodes take three operands: The first two are the normal lhs and rhs to
246551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // the add or sub, and the third is the input carry flag.  These nodes
247551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // produce two results; the normal result of the add or sub, and the output
248551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // carry flag.  These nodes both read and write a carry flag to allow them
249551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // to them to be chained together for add and sub of arbitrarily large
250551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // values.
251551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDE, SUBE,
252551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman
253615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple binary floating point operators.
254615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    FADD, FSUB, FMUL, FDIV, FREM,
25538bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
25638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.  NOTE: This
25738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // DAG node does not require that X and Y have the same type, just that they
25838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // are both floating point.  X and the result must have the same type.
25938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(f32, f64) is allowed.
26038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    FCOPYSIGN,
261fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner
2621a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point
2631a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    // value as an integer 0/1 value.
2641a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    FGETSIGN,
2651a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner
266664e9546d674096c5a012536f1a424b1681ece51Dan Gohman    /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector
26722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// with the specified, possibly variable, elements.  The number of elements
26822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// is required to be a power of two.
26922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    BUILD_VECTOR,
27022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
2717f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
2724f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands    /// at IDX replaced with VAL.  If the type of VAL is larger than the vector
2734f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands    /// element type then VAL is truncated before replacement.
27422232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    INSERT_VECTOR_ELT,
2754b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner
2764b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
2777f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// identified by the (potentially variable) element number IDX.
2784b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    EXTRACT_VECTOR_ELT,
27922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
2807f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
2817f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// vector type with the same length and element type, this produces a
2827f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// concatenated vector result value, with length equal to the sum of the
283b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman    /// lengths of the input vectors.
2847f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    CONCAT_VECTORS,
2856595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman
2867f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
2877f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// vector value) starting with the (potentially variable) element number
2887f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// IDX, which must be a multiple of the result vector length.
2897f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    EXTRACT_SUBVECTOR,
29059c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands
29149c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
29249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// type as VEC1/VEC2.  SHUFFLEVEC is a BUILD_VECTOR of constant int values
29359c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// (maybe of an illegal datatype) or undef that indicate which value each
29459c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// result element will get.  The elements of VEC1/VEC2 are enumerated in
29559c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// order.  This is quite similar to the Altivec 'vperm' instruction, except
29659c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// that the indices must be constants and are in terms of the element size
29759c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// of VEC1/VEC2, not in terms of bytes.
29849c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    VECTOR_SHUFFLE,
29959c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands
300210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
301a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman    /// scalar value into element 0 of the resultant vector type.  The top
302a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman    /// elements 1 to N-1 of the N-element vector are undefined.
303210721aecc0916315f61660dc387a96b89ec423bChris Lattner    SCALAR_TO_VECTOR,
304210721aecc0916315f61660dc387a96b89ec423bChris Lattner
305557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // EXTRACT_SUBREG - This node is used to extract a sub-register value.
306557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // This node takes a superreg and a constant sub-register index as operands.
307709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // Note sub-register indices must be increasing. That is, if the
308709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // sub-register index of a 8-bit sub-register is N, then the index for a
309709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // 16-bit sub-register must be at least N+1.
310557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    EXTRACT_SUBREG,
311557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb
3124499e495eabe8de7d595416a03c56af4688df507Evan Cheng    // INSERT_SUBREG - This node is used to insert a sub-register value.
313557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // This node takes a superreg, a subreg value, and a constant sub-register
3144499e495eabe8de7d595416a03c56af4688df507Evan Cheng    // index as operands.
315557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    INSERT_SUBREG,
316557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb
317bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
318b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands    // an unsigned/signed value of type i[2*N], then return the top part.
319bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    MULHU, MULHS,
32063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
32135ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // Bitwise operators - logical and, logical or, logical xor, shift left,
32235ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // shift right algebraic (shift in sign bits), shift right logical (shift in
32335ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // zeroes), rotate left, rotate right, and byteswap.
32435ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
32563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
326691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    // Counting operators
327691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    CTTZ, CTLZ, CTPOP,
328691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth
3293b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // Select(COND, TRUEVAL, FALSEVAL).  If the type of the boolean COND is not
3303b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // i1 then the high bits must conform to getSetCCResultContents.
3313b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    SELECT,
3323b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands
3339373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // Select with condition operator - This selects between a true value and
3349373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // a false value (ops #2 and #3) based on the boolean result of comparing
3359373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // the lhs and rhs (ops #0 and #1) of a conditional expression with the
3369373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // condition code in op #4, a CondCodeSDNode.
3379373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    SELECT_CC,
33863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3393b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // SetCC operator - This evaluates to a true value iff the condition is
3403b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // true.  If the result value type is not i1 then the high bits conform
3413b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // to getSetCCResultContents.  The operands to this are the left and right
3423b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // operands to compare (ops #0, and #1) and the condition code to compare
3433b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // them with (op #2) as a CondCodeSDNode.
34463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETCC,
34563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
346b43e9c196542acc80c9e4643809661065710848fNate Begeman    // Vector SetCC operator - This evaluates to a vector of integer elements
347b43e9c196542acc80c9e4643809661065710848fNate Begeman    // with the high bit in each element set to true if the comparison is true
348b43e9c196542acc80c9e4643809661065710848fNate Begeman    // and false if the comparison is false.  All other bits in each element
349b43e9c196542acc80c9e4643809661065710848fNate Begeman    // are undefined.  The operands to this are the left and right operands
350b43e9c196542acc80c9e4643809661065710848fNate Begeman    // to compare (ops #0, and #1) and the condition code to compare them with
351b43e9c196542acc80c9e4643809661065710848fNate Begeman    // (op #2) as a CondCodeSDNode.
352b43e9c196542acc80c9e4643809661065710848fNate Begeman    VSETCC,
353b43e9c196542acc80c9e4643809661065710848fNate Begeman
35414c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
35514c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // integer shift operations, just like ADD/SUB_PARTS.  The operation
35614c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // ordering is:
3576b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner    //       [Lo,Hi] = op [LoLHS,HiLHS], Amt
35814c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    SHL_PARTS, SRA_PARTS, SRL_PARTS,
35914c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner
36063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Conversion operators.  These are all single input single output
36163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operations.  For all of these, the result type must be strictly
36263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // wider or narrower (depending on the operation) than the source
36363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // type.
36463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
36563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // SIGN_EXTEND - Used for integer types, replicating the sign bit
36663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // into new bits.
36763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SIGN_EXTEND,
36863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
36963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // ZERO_EXTEND - Used for integer types, zeroing the new bits.
37063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    ZERO_EXTEND,
37163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3727e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    // ANY_EXTEND - Used for integer types.  The high bits are undefined.
3737e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    ANY_EXTEND,
3747e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner
37563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // TRUNCATE - Completely drop the high bits.
37663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    TRUNCATE,
37763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3781645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
3791645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // depends on the first letter) to floating point.
3801645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    SINT_TO_FP,
3811645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    UINT_TO_FP,
3821645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
383ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
384ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // sign extend a small value in a large integer register (e.g. sign
385ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // extending the low 8 bits of a 32-bit register to fill the top 24 bits
38615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // with the 7th bit).  The size of the smaller type is indicated by the 1th
38715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // operand, a ValueType node.
388859157daee6a4b49e99921832e1dde065167b317Chris Lattner    SIGN_EXTEND_INREG,
389859157daee6a4b49e99921832e1dde065167b317Chris Lattner
3900bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
3910bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// integer.
3921645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_SINT,
3931645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_UINT,
3941645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
3950bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type
3960bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// down to the precision of the destination VT.  TRUNC is a flag, which is
3970bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// always an integer that is zero or one.  If TRUNC is 0, this is a
3980bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// normal rounding, if it is 1, this FP_ROUND is known to not change the
3990bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// value of Y.
4000bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    ///
4010bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// The TRUNC = 1 case is used in cases where we know that the value will
4020bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// not be modified by the node, because Y is not using any of the extra
4030bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// precision of source type.  This allows certain transformations like
4040bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for
4050bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed.
40663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_ROUND,
4070bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner
4081a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman    // FLT_ROUNDS_ - Returns current rounding mode:
409917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    // -1 Undefined
410917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  0 Round to 0
411917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  1 Round to nearest
412917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  2 Round to +inf
413917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  3 Round to -inf
4141a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman    FLT_ROUNDS_,
415917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov
4160bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and
4170bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// rounds it to a floating point value.  It then promotes it and returns it
4180bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// in a register of the same size.  This operation effectively just
4190bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// discards excess precision.  The type to round down to is specified by
4200bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// the VT operand, a VTSDNode.
421859157daee6a4b49e99921832e1dde065167b317Chris Lattner    FP_ROUND_INREG,
422859157daee6a4b49e99921832e1dde065167b317Chris Lattner
4230bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
42463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_EXTEND,
42563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4261ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // BIT_CONVERT - Theis operator converts between integer and FP values, as
4271ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // if one was stored to memory as integer and the other was loaded from the
42880f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // same address (or equivalently for vector format conversions, etc).  The
42980f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // source and result are required to have the same bit size (e.g.
43080f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // f32 <-> i32).  This can also be used for int-to-int or fp-to-fp
43180f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // conversions, but that is a noop, deleted by getNode().
4321ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    BIT_CONVERT,
4331ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner
43477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    // CONVERT_RNDSAT - This operator is used to support various conversions
43500ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // between various types (float, signed, unsigned and vectors of those
43600ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // types) with rounding and saturation. NOTE: Avoid using this operator as
43700ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // most target don't support it and the operator might be removed in the
43800ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // future. It takes the following arguments:
43977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   0) value
44077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   1) dest type (type to convert to)
44177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   2) src type (type to convert from)
44277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   3) rounding imm
44377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   4) saturation imm
44477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   5) ISD::CvtCode indicating the type of conversion to do
44577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CONVERT_RNDSAT,
44677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
447509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
4487794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen    // FLOG, FLOG2, FLOG10, FEXP, FEXP2,
4498471ef5f4e79fbe4d7021e91d45e39fdbf8783fcDan Gohman    // FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR - Perform various unary floating
450509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    // point operations. These are inspired by libm.
45107f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman    FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
4527794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen    FLOG, FLOG2, FLOG10, FEXP, FEXP2,
453509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR,
45438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
4558862ef148100070b7bf28beead3951464250c926Evan Cheng    // LOAD and STORE have token chains as their first operand, then the same
4568862ef148100070b7bf28beead3951464250c926Evan Cheng    // operands as an LLVM load/store instruction, then an offset node that
4578862ef148100070b7bf28beead3951464250c926Evan Cheng    // is added / subtracted from the base pointer to form the address (for
4588862ef148100070b7bf28beead3951464250c926Evan Cheng    // indexed memory ops).
45963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    LOAD, STORE,
460ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
46163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
46257fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // to a specified boundary.  This node always has two return values: a new
46357fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // stack pointer value and a chain. The first operand is the token chain,
46457fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // the second is the number of bytes to allocate, and the third is the
46557fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // alignment boundary.  The size is guaranteed to be a multiple of the stack
46657fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // alignment, and the alignment is guaranteed to be bigger than the stack
46774fe063e90045931eefaba561730e6a9175ced78Chris Lattner    // alignment (if required) or 0 to get standard stack alignment.
46863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    DYNAMIC_STACKALLOC,
46963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
47063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Control flow instructions.  These all have token chains.
471ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
47263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BR - Unconditional branch.  The first operand is the chain
47363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operand, the second is the MBB to branch to.
47463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BR,
47563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
47637efe6764568a3829fee26aba532283131d1a104Nate Begeman    // BRIND - Indirect branch.  The first operand is the chain, the second
47737efe6764568a3829fee26aba532283131d1a104Nate Begeman    // is the value to branch to, which must be of the same type as the target's
47837efe6764568a3829fee26aba532283131d1a104Nate Begeman    // pointer type.
47937efe6764568a3829fee26aba532283131d1a104Nate Begeman    BRIND,
480c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng
481c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // BR_JT - Jumptable branch. The first operand is the chain, the second
482c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // is the jumptable index, the last one is the jumptable entry index.
483c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    BR_JT,
48447b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands
48547b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // BRCOND - Conditional branch.  The first operand is the chain, the
48647b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // second is the condition, the third is the block to branch to if the
48747b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // condition is true.  If the type of the condition is not i1, then the
48847b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // high bits must conform to getSetCCResultContents.
48963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BRCOND,
49063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4917cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // BR_CC - Conditional branch.  The behavior is like that of SELECT_CC, in
4927cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // that the condition is represented as condition code, and two nodes to
4937cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // compare, rather than as a combined SetCC node.  The operands in order are
4947cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // chain, cc, lhs, rhs, block to branch to if condition is true.
4957cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    BR_CC,
4967cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman
49763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // RET - Return from function.  The first operand is the chain,
4988e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // and any subsequent operands are pairs of return value and return value
499c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen    // attributes (see CALL for description of attributes) for the function.
500c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen    // This operation can have variable number of operands.
50163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    RET,
50263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
5037572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // INLINEASM - Represents an inline asm block.  This node always has two
5047572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // return values: a chain and a flag result.  The inputs are as follows:
5057572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #0   : Input chain.
506056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    //   Operand #1   : a ExternalSymbolSDNode with a pointer to the asm string.
5077572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+2: A RegisterNode.
5087572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
5097572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #last: Optional, an incoming flag.
5107572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    INLINEASM,
5111ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey
5124406604047423576e36657c7ede266ca42e79642Dan Gohman    // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track
5134406604047423576e36657c7ede266ca42e79642Dan Gohman    // locations needed for debug and exception handling tables.  These nodes
5144406604047423576e36657c7ede266ca42e79642Dan Gohman    // take a chain as input and return a chain.
5154406604047423576e36657c7ede266ca42e79642Dan Gohman    DBG_LABEL,
5164406604047423576e36657c7ede266ca42e79642Dan Gohman    EH_LABEL,
517a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng
518a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track
519a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // local variable declarations for debugging information. First operand is
520a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // a chain, while the next two operands are first two arguments (address
521a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // and variable) of a llvm.dbg.declare instruction.
522a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    DECLARE,
523f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
5245a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKSAVE - STACKSAVE has one operand, an input chain.  It produces a
5255a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // value, the same type as the pointer type for the system, and an output
5265a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // chain.
5275a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKSAVE,
5285a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
5295a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKRESTORE has two operands, an input chain and a pointer to restore to
5305a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // it returns an output chain.
5315a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKRESTORE,
5325a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
53316cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
53416cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // a call sequence, and carry arbitrary information that target might want
53516cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // to know.  The first operand is a chain, the rest are specified by the
53616cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // target and not touched by the DAG optimizers.
5370ea0356dff38dfd0420b8c0a2fdf2fae7898c024Dale Johannesen    // CALLSEQ_START..CALLSEQ_END pairs may not be nested.
53816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_START,  // Beginning of a call sequence
53916cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_END,    // End of a call sequence
540acc398c195a697795bff3245943d104eb19192b9Nate Begeman
541acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAARG - VAARG has three operands: an input chain, a pointer, and a
542acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // SRCVALUE.  It returns a pair of values: the vaarg value and a new chain.
543acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAARG,
544acc398c195a697795bff3245943d104eb19192b9Nate Begeman
545acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
546acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
547acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // source.
548acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VACOPY,
549acc398c195a697795bff3245943d104eb19192b9Nate Begeman
550acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
551acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // pointer, and a SRCVALUE.
552acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAEND, VASTART,
55363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
55469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    // SRCVALUE - This is a node type that holds a Value* that is used to
55569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    // make reference to a value in the LLVM IR.
55621074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    SRCVALUE,
55721074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner
55836b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // MEMOPERAND - This is a node that contains a MachineMemOperand which
55936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // records information about a memory reference. This is used to make
56036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // AliasAnalysis queries from the backend.
56169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    MEMOPERAND,
56269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
563e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman    // PCMARKER - This corresponds to the pcmarker intrinsic.
56495762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth    PCMARKER,
56563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
566aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
5678b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // The only operand is a chain and a value and a chain are produced.  The
5688b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // value is the contents of the architecture specific cycle counter like
5698b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // register (or other high accuracy low latency clock source)
570aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    READCYCLECOUNTER,
571aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth
572d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    // HANDLENODE node - Used as a handle for various purposes.
573d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    HANDLENODE,
5742d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
5757f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // DBG_STOPPOINT - This node is used to represent a source location for
5767f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // debug info.  It takes token chain as input, and carries a line number,
5777f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // column number, and a pointer to a CompileUnitDesc object identifying
5787f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // the containing compilation unit.  It produces a token chain as output.
5797f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    DBG_STOPPOINT,
58047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner
581f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    // DEBUG_LOC - This node is used to represent source line information
582abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // embedded in the code.  It takes a token chain as input, then a line
58344c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey    // number, then a column then a file id (provided by MachineModuleInfo.) It
584abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // produces a token chain as output.
585f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    DEBUG_LOC,
58636397f50343639ce9a25996f2d790c656791ab92Duncan Sands
58736397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
58836397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // It takes as input a token chain, the pointer to the trampoline,
58936397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // the pointer to the nested function, the pointer to pass for the
59036397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // 'nest' parameter, a SRCVALUE for the trampoline and another for
59136397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // the nested function (allowing targets to access the original
592f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands    // Function*).  It produces the result of the intrinsic and a token
593f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands    // chain as output.
59436397f50343639ce9a25996f2d790c656791ab92Duncan Sands    TRAMPOLINE,
59536397f50343639ce9a25996f2d790c656791ab92Duncan Sands
59666fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov    // TRAP - Trapping instruction
59766fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov    TRAP,
59866fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov
59927b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are
60027b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // their first operand. The other operands are the address to prefetch,
60127b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // read / write specifier, and locality specifier.
60227b7db549e4c5bff4579d209304de5628513edebEvan Cheng    PREFETCH,
60327b7db549e4c5bff4579d209304de5628513edebEvan Cheng
60422c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load,
60522c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    //                       store-store, device)
606ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // This corresponds to the memory.barrier intrinsic.
60722c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // it takes an input chain, 4 operands to specify the type of barrier, an
60822c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // operand specifying if the barrier applies to device and uncached memory
60922c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // and produces an output chain.
61022c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    MEMBARRIER,
61122c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth
61228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang    // Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)
613ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // this corresponds to the atomic.lcs intrinsic.
614ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // cmp is compared to *ptr, and if equal, swap is stored in *ptr.
615ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // the return is always the original value in *ptr
616e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_CMP_SWAP_8,
617e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_CMP_SWAP_16,
618e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_CMP_SWAP_32,
619e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_CMP_SWAP_64,
620ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
621ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt)
622ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // this corresponds to the atomic.swap intrinsic.
623ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // amt is stored to *ptr atomically.
624ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // the return is always the original value in *ptr
625e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_SWAP_8,
626e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_SWAP_16,
627e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_SWAP_32,
628e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_SWAP_64,
629ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
63063307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    // Val, OUTCHAIN = ATOMIC_L[OpName]S(INCHAIN, ptr, amt)
63163307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    // this corresponds to the atomic.[OpName] intrinsic.
63263307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    // op(*ptr, amt) is stored to *ptr atomically.
63363307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    // the return is always the original value in *ptr
634e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_ADD_8,
635e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_SUB_8,
636e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_AND_8,
637e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_OR_8,
638e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_XOR_8,
639e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_NAND_8,
640e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_MIN_8,
641e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_MAX_8,
642e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_UMIN_8,
643e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_UMAX_8,
644e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_ADD_16,
645e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_SUB_16,
646e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_AND_16,
647e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_OR_16,
648e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_XOR_16,
649e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_NAND_16,
650e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_MIN_16,
651e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_MAX_16,
652e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_UMIN_16,
653e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_UMAX_16,
654e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_ADD_32,
655e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_SUB_32,
656e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_AND_32,
657e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_OR_32,
658e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_XOR_32,
659e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_NAND_32,
660e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_MIN_32,
661e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_MAX_32,
662e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_UMIN_32,
663e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_UMAX_32,
664e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_ADD_64,
665e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_SUB_64,
666e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_AND_64,
667e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_OR_64,
668e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_XOR_64,
669e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_NAND_64,
670e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_MIN_64,
671e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_MAX_64,
672e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_UMIN_64,
673e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    ATOMIC_LOAD_UMAX_64,
67463307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang
67563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILTIN_OP_END - This must be the last enum value in this list.
676410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    BUILTIN_OP_END
67763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
67863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
679322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// Node predicates
680322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
681a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  /// isBuildVectorAllOnes - Return true if the specified node is a
682322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// BUILD_VECTOR where all of the elements are ~0 or undef.
683a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  bool isBuildVectorAllOnes(const SDNode *N);
6844a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng
6854a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// isBuildVectorAllZeros - Return true if the specified node is a
6864a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// BUILD_VECTOR where all of the elements are 0 or undef.
6874a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  bool isBuildVectorAllZeros(const SDNode *N);
688bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng
689efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// isScalarToVector - Return true if the specified node is a
690efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
691efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// element is not an undef.
692efec751a1b786724862ceff52748df94873a807eEvan Cheng  bool isScalarToVector(const SDNode *N);
693efec751a1b786724862ceff52748df94873a807eEvan Cheng
694bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng  /// isDebugLabel - Return true if the specified node represents a debug
6954406604047423576e36657c7ede266ca42e79642Dan Gohman  /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node).
696bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng  bool isDebugLabel(const SDNode *N);
697322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
69863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
699144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// MemIndexedMode enum - This enum defines the load / store indexed
700144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// addressing modes.
70124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
70224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// UNINDEXED    "Normal" load / store. The effective address is already
70324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computed and is available in the base pointer. The offset
70481c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              operand is always undefined. In addition to producing a
70581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              chain, an unindexed load produces one value (result of the
706276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ///              load); an unindexed store does not produce a value.
70724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
70835acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// PRE_INC      Similar to the unindexed mode where the effective address is
7098862ef148100070b7bf28beead3951464250c926Evan Cheng  /// PRE_DEC      the value of the base pointer add / subtract the offset.
7108862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              It considers the computation as being folded into the load /
71124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              store operation (i.e. the load / store does the address
71224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computation as well as performing the memory transaction).
71381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              The base operand is always undefined. In addition to
71481c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              producing a chain, pre-indexed load produces two values
71581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              (result of the load and the result of the address
71681c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              computation); a pre-indexed store produces one value (result
71781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              of the address computation).
71824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
71935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// POST_INC     The effective address is the value of the base pointer. The
7208862ef148100070b7bf28beead3951464250c926Evan Cheng  /// POST_DEC     value of the offset operand is then added to / subtracted
7218862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              from the base after memory transaction. In addition to
7228862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              producing a chain, post-indexed load produces two values
7238862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              (the result of the load and the result of the base +/- offset
7248862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              computation); a post-indexed store produces one value (the
7258862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              the result of the base +/- offset computation).
72624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
727144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  enum MemIndexedMode {
72824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    UNINDEXED = 0,
72935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_INC,
73035acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_DEC,
73135acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    POST_INC,
732144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    POST_DEC,
733144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    LAST_INDEXED_MODE
73424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  };
73524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
73624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  //===--------------------------------------------------------------------===//
737c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// LoadExtType enum - This enum defines the three variants of LOADEXT
738c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// (load with extension).
739c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
74024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// SEXTLOAD loads the integer operand and sign extends it to a larger
74124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
74224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// ZEXTLOAD loads the integer operand and zero extends it to a larger
74324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
74424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// EXTLOAD  is used for three things: floating point extending loads,
74524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer extending loads [the top bits are undefined], and vector
74624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          extending loads [load into low elt].
74724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
748c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  enum LoadExtType {
74924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    NON_EXTLOAD = 0,
750c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    EXTLOAD,
751c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    SEXTLOAD,
752c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    ZEXTLOAD,
7530329466b6b4927f4e6f5d144891fef06a027fec5Evan Cheng    LAST_LOADEXT_TYPE
754c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  };
755c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
756c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  //===--------------------------------------------------------------------===//
75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::CondCode enum - These are ordered carefully to make the bitfields
75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// below work out, when considering SETFALSE (something that never exists
75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// dynamically) as 0.  "U" -> Unsigned (for integer operands) or Unordered
76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to.  If the "N" column is 1, the result of the comparison is undefined if
76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the input is a NAN.
76363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
76463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// All of these (except for the 'always folded ops') should be handled for
76563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// floating point.  For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
76763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
76863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// Note that these are laid out in a specific order to allow bit-twiddling
76963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to transform conditions.
77063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum CondCode {
77163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Opcode          N U L G E       Intuitive operation
77263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE,      //    0 0 0 0       Always false (always folded)
77363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOEQ,        //    0 0 0 1       True if ordered and equal
77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGT,        //    0 0 1 0       True if ordered and greater than
77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGE,        //    0 0 1 1       True if ordered and greater than or equal
77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLT,        //    0 1 0 0       True if ordered and less than
77763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLE,        //    0 1 0 1       True if ordered and less than or equal
77863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETONE,        //    0 1 1 0       True if ordered and operands are unequal
77963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETO,          //    0 1 1 1       True if ordered (no nans)
78063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUO,         //    1 0 0 0       True if unordered: isnan(X) | isnan(Y)
78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUEQ,        //    1 0 0 1       True if unordered or equal
78263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGT,        //    1 0 1 0       True if unordered or greater than
78363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGE,        //    1 0 1 1       True if unordered, greater than, or equal
78463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETULT,        //    1 1 0 0       True if unordered or less than
785ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETULE,        //    1 1 0 1       True if unordered, less than, or equal
78663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUNE,        //    1 1 1 0       True if unordered or not equal
78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE,       //    1 1 1 1       Always true (always folded)
78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Don't care operations: undefined if the input is a nan.
78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE2,     //  1 X 0 0 0       Always false (always folded)
79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETEQ,         //  1 X 0 0 1       True if equal
79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGT,         //  1 X 0 1 0       True if greater than
79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGE,         //  1 X 0 1 1       True if greater than or equal
79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETLT,         //  1 X 1 0 0       True if less than
794ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETLE,         //  1 X 1 0 1       True if less than or equal
79563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETNE,         //  1 X 1 1 0       True if not equal
79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE2,      //  1 X 1 1 1       Always true (always folded)
79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
798410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    SETCC_INVALID       // Marker value.
79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
80163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isSignedIntSetCC - Return true if this is a setcc instruction that
80263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs a signed comparison when used with integer operands.
80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isSignedIntSetCC(CondCode Code) {
80463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
80563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
80663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
80763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
80863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs an unsigned comparison when used with integer operands.
80963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isUnsignedIntSetCC(CondCode Code) {
81063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
81163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
81263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
81363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isTrueWhenEqual - Return true if the specified condition returns true if
81463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the two operands to the condition are equal.  Note that if one of the two
81563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operands is a NaN, this value is meaningless.
81663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isTrueWhenEqual(CondCode Cond) {
81763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond & 1) != 0;
81863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
81963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
82063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getUnorderedFlavor - This function returns 0 if the condition is always
82163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// false if an operand is a NaN, 1 if the condition is always true if the
82263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operand is a NaN, and 2 if the condition is undefined if the operand is a
82363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// NaN.
82463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getUnorderedFlavor(CondCode Cond) {
82563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond >> 3) & 3;
82663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
82763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
82863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
82963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// 'op' is a valid SetCC operation.
83063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCInverse(CondCode Operation, bool isInteger);
83163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
83263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
83363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// when given the operation for (X op Y).
83463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCSwappedOperands(CondCode Operation);
83563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
83663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCOrOperation - Return the result of a logical OR between different
83763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// comparisons of identical values: ((X op1 Y) | (X op2 Y)).  This
83863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
83963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
84063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
84163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
84263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCAndOperation - Return the result of a logical AND between
84363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)).  This
84463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
84563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
84663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
84777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
84877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  //===--------------------------------------------------------------------===//
84977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  /// CvtCode enum - This enum defines the various converts CONVERT_RNDSAT
85077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  /// supports.
85177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  enum CvtCode {
85277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FF,     // Float from Float
85377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FS,     // Float from Signed
85477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FU,     // Float from Unsigned
85577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SF,     // Signed from Float
85677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_UF,     // Unsigned from Float
85777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SS,     // Signed from Signed
85877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SU,     // Signed from Unsigned
85977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_US,     // Unsigned from Signed
86077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_UU,     // Unsigned from Unsigned
86177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_INVALID // Marker - Invalid opcode
86277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  };
86363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}  // end llvm::ISD namespace
86463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
86563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
86663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
867475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple
86863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation.  Many nodes return multiple values,
86963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns
87063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number
87163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values).
87263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
87363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that
87463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node.  This pair
875475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// of information is represented with the SDValue value type.
87663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
877475871a144eb604ddaf37503397ba0941442e5fbDan Gohmanclass SDValue {
878ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDNode *Node;       // The node defining the value we are using.
87963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned ResNo;     // Which return value of the node we are using.
88099a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greifpublic:
881ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDValue() : Node(0), ResNo(0) {}
882ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {}
88363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
88499a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif  /// get the index which selects a specific result in the SDNode
88599a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif  unsigned getResNo() const { return ResNo; }
88699a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif
887ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// get the SDNode which holds the desired result
888ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDNode *getNode() const { return Node; }
889ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif
890ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// set the SDNode
891ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  void setNode(SDNode *N) { Node = N; }
892ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif
893475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator==(const SDValue &O) const {
894ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node == O.Node && ResNo == O.ResNo;
89563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
896475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator!=(const SDValue &O) const {
89763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return !operator==(O);
89863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
899475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator<(const SDValue &O) const {
900ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node < O.Node || (Node == O.Node && ResNo < O.ResNo);
90163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
90263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
903475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDValue getValue(unsigned R) const {
904ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return SDValue(Node, R);
90563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
90663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
907917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  // isOperandOf - Return true if this node is an operand of N.
908917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isOperandOf(SDNode *N) const;
909bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng
91063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the ValueType of the referenced return value.
91163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
91283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  inline MVT getValueType() const;
913ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
91483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  /// getValueSizeInBits - Returns the size of the value in bits.
9154fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  ///
9164fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  unsigned getValueSizeInBits() const {
91783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands    return getValueType().getSizeInBits();
9184fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  }
9194fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman
92063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  // Forwarding methods - These forward to the corresponding methods in SDNode.
92163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getOpcode() const;
92263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getNumOperands() const;
923475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  inline const SDValue &getOperand(unsigned i) const;
924c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline uint64_t getConstantOperandVal(unsigned i) const;
9250f66a9172175aa7c3055333358170581c999219bNate Begeman  inline bool isTargetOpcode() const;
926e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  inline bool isMachineOpcode() const;
927e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  inline unsigned getMachineOpcode() const;
928a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner
929572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner
930572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// reachesChainWithoutSideEffects - Return true if this operand (which must
931572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// be a chain) reaches the specified operand without crossing any
932572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// side-effecting instructions.  In practice, this looks through token
933572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// factors and non-volatile loads.  In order to remain efficient, this only
934572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// looks a couple of nodes in, it does not do an exhaustive search.
935475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool reachesChainWithoutSideEffects(SDValue Dest,
936dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein                                      unsigned Depth = 2) const;
937572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner
9387a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  /// use_empty - Return true if there are no nodes using value ResNo
939ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// of Node.
9407a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
941e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman  inline bool use_empty() const;
9427a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
943231fe7054160d2953e0cc6635f9a171a4b311af2Gabor Greif  /// hasOneUse - Return true if there is exactly one node using value
944ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// ResNo of Node.
9457a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
9467a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  inline bool hasOneUse() const;
94763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
94863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
94963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
950475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct DenseMapInfo<SDValue> {
951475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static inline SDValue getEmptyKey() {
952475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return SDValue((SDNode*)-1, -1U);
953dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
954475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static inline SDValue getTombstoneKey() {
955475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return SDValue((SDNode*)-1, 0);
956dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
957475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static unsigned getHashValue(const SDValue &Val) {
958ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
959ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif            (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
960c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  }
961475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
96276c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner    return LHS == RHS;
96376c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner  }
964c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  static bool isPod() { return true; }
965c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng};
966c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng
96763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on
968475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s.
969475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<SDValue> {
970dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  typedef SDNode* SimpleType;
971475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static SimpleType getSimplifiedValue(const SDValue &Val) {
972ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return static_cast<SimpleType>(Val.getNode());
973dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
974dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
975475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<const SDValue> {
976dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  typedef SDNode* SimpleType;
977475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static SimpleType getSimplifiedValue(const SDValue &Val) {
978ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return static_cast<SimpleType>(Val.getNode());
979dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
980dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
981dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
9829cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// SDUse - Represents a use of the SDNode referred by
983475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// the SDValue.
9849cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDUse {
985475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDValue Operand;
98602819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein  /// User - Parent node of this operand.
98702819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein  SDNode    *User;
988dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// Prev, next - Pointers to the uses list of the SDNode referred by
989dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// this operand.
9909cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse **Prev, *Next;
991dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinpublic:
992dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  friend class SDNode;
99302819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein  SDUse(): Operand(), User(NULL), Prev(NULL), Next(NULL) {}
994dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
9959cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse(SDNode *val, unsigned resno) :
99602819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein    Operand(val,resno), User(NULL), Prev(NULL), Next(NULL) {}
997dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
998475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDUse& operator= (const SDValue& Op) {
9999cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein      Operand = Op;
1000dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      Next = NULL;
1001dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      Prev = NULL;
1002dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return *this;
1003dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1004dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
10059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse& operator= (const SDUse& Op) {
10069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein      Operand = Op;
1007dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      Next = NULL;
1008dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      Prev = NULL;
1009dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return *this;
1010dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1011dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
10128968450305c28444edc3c272d8752a8db0c2f34aDan Gohman  SDUse *getNext() { return Next; }
1013dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
101402819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein  SDNode *getUser() { return User; }
10159cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
101602819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein  void setUser(SDNode *p) { User = p; }
1017dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1018475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  operator SDValue() const { return Operand; }
10199cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1020475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue& getSDValue() const { return Operand; }
10219cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1022ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDValue &getSDValue() { return Operand; }
1023ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDNode *getVal() { return Operand.getNode(); }
1024ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDNode *getVal() const { return Operand.getNode(); } // FIXME: const correct?
10259cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1026475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator==(const SDValue &O) const {
10279cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    return Operand == O;
10289cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10299cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1030475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator!=(const SDValue &O) const {
10319cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    return !(Operand == O);
10329cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10339cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1034475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator<(const SDValue &O) const {
10359cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    return Operand < O;
10369cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10379cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1038dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprotected:
10399cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  void addToList(SDUse **List) {
1040dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    Next = *List;
1041dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    if (Next) Next->Prev = &Next;
1042dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    Prev = List;
1043dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    *List = this;
1044dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1045dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1046dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  void removeFromList() {
1047dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    *Prev = Next;
1048dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    if (Next) Next->Prev = Prev;
1049dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1050dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
1051dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1052dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1053dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein/// simplify_type specializations - Allow casting operators to work directly on
1054475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s.
10559cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<SDUse> {
105663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
10579cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  static SimpleType getSimplifiedValue(const SDUse &Val) {
1058475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return static_cast<SimpleType>(Val.getVal());
105963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
106063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
10619cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<const SDUse> {
106263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
10639cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  static SimpleType getSimplifiedValue(const SDUse &Val) {
1064475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return static_cast<SimpleType>(Val.getVal());
106563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
106663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
106763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
106863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1069475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDOperandPtr - A helper SDValue pointer class, that can handle
1070475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// arrays of SDUse and arrays of SDValue objects. This is required
10719cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// in many places inside the SelectionDAG.
10729cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein///
10739cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDOperandPtr {
1074475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue *ptr; // The pointer to the SDValue object
1075475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  int object_size;      // The size of the object containg the SDValue
10769cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinpublic:
107735b31bea0dc9e16d4c384a6a78404bdd791b6693Dan Gohman  SDOperandPtr() : ptr(0), object_size(0) {}
107835b31bea0dc9e16d4c384a6a78404bdd791b6693Dan Gohman
10799cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDOperandPtr(SDUse * use_ptr) {
1080475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    ptr = &use_ptr->getSDValue();
108134cd4a484e532cc463fd5a4bf59b88d13c5467c1Evan Cheng    object_size = (int)sizeof(SDUse);
10829cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10839cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1084475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDOperandPtr(const SDValue * op_ptr) {
10859cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    ptr = op_ptr;
1086475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    object_size = (int)sizeof(SDValue);
10879cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10889cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1089475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue operator *() { return *ptr; }
1090475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue *operator ->() { return ptr; }
10919cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDOperandPtr operator ++ () {
1092475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    ptr = (SDValue*)((char *)ptr + object_size);
10939cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    return *this;
10949cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10959cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
10969cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDOperandPtr operator ++ (int) {
10979cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    SDOperandPtr tmp = *this;
1098475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    ptr = (SDValue*)((char *)ptr + object_size);
10999cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    return tmp;
11009cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
11019cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1102475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDValue operator[] (int idx) const {
1103475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return *(SDValue*)((char*) ptr + object_size * idx);
11049cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
11059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein};
11069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
110763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG.
110863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
1109fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass SDNode : public FoldingSetNode, public ilist_node<SDNode> {
1110dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprivate:
11110442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  /// NodeType - The operation that this node performs.
11120442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
1113e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  short NodeType;
111463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
111563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// OperandsNeedDelete - This is true if OperandList was new[]'d.  If true,
111663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// then they will be delete[]'d when the node is destroyed.
1117ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  unsigned short OperandsNeedDelete : 1;
11180442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
1119ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprotected:
1120ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// SubclassData - This member is defined by this class, but is not used for
1121ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// anything.  Subclasses can use it to hold whatever state they find useful.
1122ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// This field is initialized to zero by the ctor.
1123ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  unsigned short SubclassData : 15;
1124ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
1125ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprivate:
1126b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// NodeId - Unique id per SDNode in the DAG.
1127b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int NodeId;
11280442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
1129f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// OperandList - The values that are used by this operation.
11300442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
11319cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse *OperandList;
1132f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner
1133f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// ValueList - The types of the values this node defines.  SDNode's may
1134f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// define multiple values simultaneously.
113583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  const MVT *ValueList;
113663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1137f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// NumOperands/NumValues - The number of entries in the Operand/Value list.
1138f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned short NumOperands, NumValues;
1139b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1140dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// Uses - List of uses for this SDNode.
11419cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse *Uses;
1142dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
11439cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  /// addUse - add SDUse to the list of uses.
11449cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  void addUse(SDUse &U) { U.addToList(&Uses); }
1145dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1146917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner  // Out-of-line virtual method to give class a home.
1147917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner  virtual void ANCHOR();
114863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
1149b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  virtual ~SDNode() {
1150b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner    assert(NumOperands == 0 && "Operand list not cleared before deletion");
11513258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    NodeType = ISD::DELETED_NODE;
1152b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  }
1153b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
115463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
115563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //  Accessors
115663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //
1157e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1158e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// getOpcode - Return the SelectionDAG opcode value for this node. For
1159e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// pre-isel nodes (those for which isMachineOpcode returns false), these
1160e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// are the opcode values in the ISD and <target>ISD namespaces. For
1161e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// post-isel opcodes, see getMachineOpcode.
1162e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  unsigned getOpcode()  const { return (unsigned short)NodeType; }
1163e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1164e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// isTargetOpcode - Test if this node has a target-specific opcode (in the
1165e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// <target>ISD namespace).
11660f66a9172175aa7c3055333358170581c999219bNate Begeman  bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
1167e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1168e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// isMachineOpcode - Test if this node has a post-isel opcode, directly
1169e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// corresponding to a MachineInstr opcode.
1170e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  bool isMachineOpcode() const { return NodeType < 0; }
1171e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1172e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// getMachineOpcode - This may only be called if isMachineOpcode returns
1173e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// true. It returns the MachineInstr opcode value that the node's opcode
1174e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// corresponds to.
1175e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  unsigned getMachineOpcode() const {
1176ec89a364b86ccd943fc6cf3ad8f84825ba1550fdDan Gohman    assert(isMachineOpcode() && "Not a MachineInstr opcode!");
1177e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman    return ~NodeType;
11780f66a9172175aa7c3055333358170581c999219bNate Begeman  }
117963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
11806da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// use_empty - Return true if there are no uses of this node.
11817a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
1182dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  bool use_empty() const { return Uses == NULL; }
11837a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
11846da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// hasOneUse - Return true if there is exactly one use of this node.
11857a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
1186b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman  bool hasOneUse() const {
1187b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman    return !use_empty() && next(use_begin()) == use_end();
1188b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman  }
118963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
11906da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// use_size - Return the number of uses of this node. This method takes
11917a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  /// time proportional to the number of uses.
11927a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
11937a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  size_t use_size() const { return std::distance(use_begin(), use_end()); }
11947a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
1195b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// getNodeId - Return the unique node id.
1196b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  ///
1197b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int getNodeId() const { return NodeId; }
11980442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
11992e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng  /// setNodeId - Set unique node id.
12002e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng  void setNodeId(int Id) { NodeId = Id; }
12012e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng
12029cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  /// use_iterator - This class provides iterator support for SDUse
1203dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// operands that use a specific SDNode.
1204dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  class use_iterator
12059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : public forward_iterator<SDUse, ptrdiff_t> {
12069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    SDUse *Op;
12079cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    explicit use_iterator(SDUse *op) : Op(op) {
1208dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1209dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    friend class SDNode;
1210dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  public:
12119cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    typedef forward_iterator<SDUse, ptrdiff_t>::reference reference;
12129cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer;
1213dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1214dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator(const use_iterator &I) : Op(I.Op) {}
1215dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator() : Op(0) {}
1216dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1217dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool operator==(const use_iterator &x) const {
1218dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return Op == x.Op;
1219dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1220dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool operator!=(const use_iterator &x) const {
1221dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return !operator==(x);
1222dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1223dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1224dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    /// atEnd - return true if this iterator is at the end of uses list.
1225dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool atEnd() const { return Op == 0; }
1226dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1227dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    // Iterator traversal: forward iteration only.
1228dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator &operator++() {          // Preincrement
1229dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot increment end iterator!");
1230dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      Op = Op->getNext();
1231dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return *this;
1232dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1233dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1234dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator operator++(int) {        // Postincrement
1235dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      use_iterator tmp = *this; ++*this; return tmp;
1236dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1237dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
12388968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    /// Retrieve a pointer to the current user node.
12398968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDNode *operator*() const {
1240dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot dereference end iterator!");
12418968450305c28444edc3c272d8752a8db0c2f34aDan Gohman      return Op->getUser();
1242dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1243dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
12448968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDNode *operator->() const { return operator*(); }
12458968450305c28444edc3c272d8752a8db0c2f34aDan Gohman
12468968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDUse &getUse() const { return *Op; }
1247dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
12488968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    /// getOperandNo - Retrive the operand # of this use in its user.
12498968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    ///
12508968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    unsigned getOperandNo() const {
1251dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot dereference end iterator!");
12528968450305c28444edc3c272d8752a8db0c2f34aDan Gohman      return (unsigned)(Op - Op->getUser()->OperandList);
1253dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1254dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  };
1255dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1256dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// use_begin/use_end - Provide iteration support to walk over all uses
1257dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// of an SDNode.
1258dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1259dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  use_iterator use_begin() const {
1260dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    return use_iterator(Uses);
1261dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1262dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1263dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  static use_iterator use_end() { return use_iterator(0); }
1264dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
12657ece380440238ad0630a225b85a09a2dbed1165aChris Lattner
1266b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
1267b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// indicated value.  This method ignores uses of other values defined by this
1268b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// operation.
12694ee621125876cc954cba5280dd9395552755a871Evan Cheng  bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
12704ee621125876cc954cba5280dd9395552755a871Evan Cheng
127133d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  /// hasAnyUseOfValue - Return true if there are any use of the indicated
127233d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  /// value. This method ignores uses of other values defined by this operation.
127333d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  bool hasAnyUseOfValue(unsigned Value) const;
127433d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng
12752a6299543fa22f389158409e897fe7099fda3812Dan Gohman  /// isOnlyUserOf - Return true if this node is the only use of N.
1276e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
12772a6299543fa22f389158409e897fe7099fda3812Dan Gohman  bool isOnlyUserOf(SDNode *N) const;
1278b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner
1279917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// isOperandOf - Return true if this node is an operand of N.
1280e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
1281917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isOperandOf(SDNode *N) const;
128280d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng
1283917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// isPredecessorOf - Return true if this node is a predecessor of N. This
1284917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// node is either an operand of N or it can be reached by recursively
1285917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// traversing up the operands.
1286e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// NOTE: this is an expensive method. Use it carefully.
1287917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isPredecessorOf(SDNode *N) const;
12887ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng
128963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumOperands - Return the number of values used by this operation.
129063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
1291f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumOperands() const { return NumOperands; }
129263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1293c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// getConstantOperandVal - Helper method returns the integer value of a
1294c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// ConstantSDNode operand.
1295c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  uint64_t getConstantOperandVal(unsigned Num) const;
1296c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1297475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOperand(unsigned Num) const {
1298f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(Num < NumOperands && "Invalid child # of SDNode!");
1299475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return OperandList[Num].getSDValue();
130063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
1301c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
13029cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  typedef SDUse* op_iterator;
1303f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_begin() const { return OperandList; }
1304f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_end() const { return OperandList+NumOperands; }
130550f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner
130663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
13070b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  SDVTList getVTList() const {
13080b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    SDVTList X = { ValueList, NumValues };
13090b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    return X;
13100b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  };
1311d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman
1312d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  /// getFlaggedNode - If this node has a flag operand, return the node
1313d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  /// to which the flag operand points. Otherwise return NULL.
1314d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  SDNode *getFlaggedNode() const {
1315d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman    if (getNumOperands() != 0 &&
1316d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman        getOperand(getNumOperands()-1).getValueType() == MVT::Flag)
1317d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman      return getOperand(getNumOperands()-1).getNode();
1318d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman    return 0;
1319d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  }
13200b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
132163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumValues - Return the number of values defined/returned by this
132263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operator.
132363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
1324f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumValues() const { return NumValues; }
132563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
132663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the type of a specified result.
132763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
132883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT getValueType(unsigned ResNo) const {
1329f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(ResNo < NumValues && "Illegal result number!");
1330f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    return ValueList[ResNo];
133163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
13329eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen
13334fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
13344fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  ///
13354fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  unsigned getValueSizeInBits(unsigned ResNo) const {
133683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands    return getValueType(ResNo).getSizeInBits();
13374fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  }
13384fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman
133983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  typedef const MVT* value_iterator;
1340f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_begin() const { return ValueList; }
1341f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_end() const { return ValueList+NumValues; }
134263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
13436e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  /// getOperationName - Return the opcode of this operation for printing.
13446e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  ///
1345ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer  std::string getOperationName(const SelectionDAG *G = 0) const;
1346144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  static const char* getIndexedModeName(ISD::MemIndexedMode AM);
1347944fac71e082cc2664cc71b4d3f6c72bab7143fbChris Lattner  void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
134863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  void dump() const;
1349efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner  void dump(const SelectionDAG *G) const;
135063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
135163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *) { return true; }
135263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1353583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  /// Profile - Gather unique data for the node.
1354583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  ///
1355b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  void Profile(FoldingSetNodeID &ID) const;
1356583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey
135763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
135863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
13598e4018e2de52c534405d7155c7009d0b35afb861Cedric Venet  friend struct ilist_traits<SDNode>;
1360109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner
1361109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  /// getValueTypeList - Return a pointer to the specified value type.
1362109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  ///
136383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  static const MVT *getValueTypeList(MVT VT);
136483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  static SDVTList getSDVTList(MVT VT) {
136563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    SDVTList Ret = { getValueTypeList(VT), 1 };
136663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    return Ret;
13672d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
136863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
1369475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
1370ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1371ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman      NodeId(-1), Uses(NULL) {
1372f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner    NumOperands = NumOps;
13739cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    OperandList = NumOps ? new SDUse[NumOperands] : 0;
13749cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
13759cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    for (unsigned i = 0; i != NumOps; ++i) {
13769cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein      OperandList[i] = Ops[i];
13779cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein      OperandList[i].setUser(this);
1378ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif      Ops[i].getNode()->addUse(OperandList[i]);
13799cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    }
13809cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
13819cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    ValueList = VTs.VTs;
13829cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    NumValues = VTs.NumVTs;
13839cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
13849cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
13856d9cdd56173fb915a9e3a8f0f6b5a8ed9bed1098Dan Gohman  SDNode(unsigned Opc, SDVTList VTs, const SDUse *Ops, unsigned NumOps)
1386ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1387ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman      NodeId(-1), Uses(NULL) {
13889cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    OperandsNeedDelete = true;
13899cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    NumOperands = NumOps;
13909cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    OperandList = NumOps ? new SDUse[NumOperands] : 0;
1391f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner
1392bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    for (unsigned i = 0; i != NumOps; ++i) {
1393f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner      OperandList[i] = Ops[i];
1394dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      OperandList[i].setUser(this);
1395475871a144eb604ddaf37503397ba0941442e5fbDan Gohman      Ops[i].getVal()->addUse(OperandList[i]);
13960442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner    }
1397bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
1398ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    ValueList = VTs.VTs;
1399ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    NumValues = VTs.NumVTs;
1400f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  }
1401dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1402ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// This constructor adds no operands itself; operands can be
1403ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// set later with InitOperands.
1404dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  SDNode(unsigned Opc, SDVTList VTs)
1405ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
1406ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman      NodeId(-1), Uses(NULL) {
1407bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    NumOperands = 0;
1408bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    OperandList = 0;
1409bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    ValueList = VTs.VTs;
1410bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    NumValues = VTs.NumVTs;
1411bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
1412bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
1413bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  /// InitOperands - Initialize the operands list of this node with the
1414bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  /// specified values, which are part of the node (thus they don't need to be
1415bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  /// copied in or allocated).
14169cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  void InitOperands(SDUse *Ops, unsigned NumOps) {
1417bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    assert(OperandList == 0 && "Operands already set!");
1418bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    NumOperands = NumOps;
1419bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    OperandList = Ops;
1420dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    Uses = NULL;
1421bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
1422dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    for (unsigned i = 0; i != NumOps; ++i) {
1423dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      OperandList[i].setUser(this);
14249cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein      Ops[i].getVal()->addUse(OperandList[i]);
1425dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1426bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
14270fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman
14280fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman  /// DropOperands - Release the operands and set this node to have
1429e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// zero operands.
14300fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman  void DropOperands();
1431bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
1432dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  void addUser(unsigned i, SDNode *User) {
1433dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    assert(User->OperandList[i].getUser() && "Node without parent");
1434dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    addUse(User->OperandList[i]);
14351b95095857b78e12138c22e76c7936611c51355bChris Lattner  }
1436dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1437dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  void removeUser(unsigned i, SDNode *User) {
1438dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    assert(User->OperandList[i].getUser() && "Node without parent");
14399cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    SDUse &Op = User->OperandList[i];
1440dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    Op.removeFromList();
1441d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner  }
144263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
144363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
144463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1445475871a144eb604ddaf37503397ba0941442e5fbDan Gohman// Define inline functions from the SDValue class.
144663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1447475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getOpcode() const {
1448ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getOpcode();
144963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1450475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline MVT SDValue::getValueType() const {
1451ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getValueType(ResNo);
145263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1453475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getNumOperands() const {
1454ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getNumOperands();
145563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1456475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline const SDValue &SDValue::getOperand(unsigned i) const {
1457ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getOperand(i);
145863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1459475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
1460ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getConstantOperandVal(i);
1461c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
1462475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isTargetOpcode() const {
1463ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->isTargetOpcode();
14640f66a9172175aa7c3055333358170581c999219bNate Begeman}
1465475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isMachineOpcode() const {
1466ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->isMachineOpcode();
1467e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman}
1468475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getMachineOpcode() const {
1469ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getMachineOpcode();
14700f66a9172175aa7c3055333358170581c999219bNate Begeman}
1471475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::use_empty() const {
1472ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return !Node->hasAnyUseOfValue(ResNo);
1473e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman}
1474475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::hasOneUse() const {
1475ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->hasNUsesOfValue(1, ResNo);
14767a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman}
147763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
14783f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes.  This is solely
14793f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
14803f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode {
14813f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
14829cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Op;
14833f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1484475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X)
14859cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : SDNode(Opc, VTs) {
14869cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    Op = X;
14873f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    InitOperands(&Op, 1);
14883f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
14893f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
14903f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
14913f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes.  This is solely
14923f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
14933f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode {
14943f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
14959cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[2];
14963f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1497475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y)
14983f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs) {
14993f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[0] = X;
15003f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[1] = Y;
15013f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    InitOperands(Ops, 2);
15023f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
15033f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
15043f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
15053f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely
15063f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
15073f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode {
15083f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
15099cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[3];
15103f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1511475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y,
1512475871a144eb604ddaf37503397ba0941442e5fbDan Gohman                SDValue Z)
15133f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs) {
15143f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[0] = X;
15153f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[1] = Y;
15163f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    Ops[2] = Z;
15173f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    InitOperands(Ops, 3);
15183f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
15193f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
15203f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
15213f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
1522d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that
1523d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its
1524d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand.  This node should be directly created by end-users and not added to
1525d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list.
1526d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode {
1527c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
15289cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Op;
1529d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic:
1530ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling  // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is
1531ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling  // fixed.
153269cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#ifdef __GNUC__
1533475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  explicit __attribute__((__noinline__)) HandleSDNode(SDValue X)
153469cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#else
1535475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  explicit HandleSDNode(SDValue X)
153669cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#endif
15379cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) {
15389cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    Op = X;
1539bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    InitOperands(&Op, 1);
1540bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
154148b85926524f9d29ae600123c90194cd73fd629eChris Lattner  ~HandleSDNode();
1542ec20183c35f1a8d308b619dbe580d0ed0db21d12Dan Gohman  const SDValue &getValue() const { return Op.getSDValue(); }
1543d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner};
1544d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner
154528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang/// Abstact virtual class for operations for memory operations
154628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass MemSDNode : public SDNode {
154728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
154828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
154928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangprivate:
15501ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  // MemoryVT - VT of in-memory value.
15511ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MVT MemoryVT;
15521ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
155328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  //! SrcValue - Memory location for alias analysis.
155428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  const Value *SrcValue;
155528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1556492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  //! SVOffset - Memory location offset. Note that base is defined in MemSDNode
1557492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  int SVOffset;
1558492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman
1559492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  /// Flags - the low bit indicates whether this is a volatile reference;
1560492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  /// the remainder is a log2 encoding of the alignment in bytes.
1561492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  unsigned Flags;
156228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
156328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangpublic:
15641ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT,
1565492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman            const Value *srcValue, int SVOff,
1566492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman            unsigned alignment, bool isvolatile);
156728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1568c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  MemSDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps,
1569c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang            MVT MemoryVT, const Value *srcValue, int SVOff,
1570c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang            unsigned alignment, bool isvolatile);
1571c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
157228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// Returns alignment and volatility of the memory access
1573492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  unsigned getAlignment() const { return (1u << (Flags >> 1)) >> 1; }
1574492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  bool isVolatile() const { return Flags & 1; }
157528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
157628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// Returns the SrcValue and offset that describes the location of the access
157728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  const Value *getSrcValue() const { return SrcValue; }
1578492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  int getSrcValueOffset() const { return SVOffset; }
157928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
15801ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  /// getMemoryVT - Return the type of the in-memory value.
15811ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MVT getMemoryVT() const { return MemoryVT; }
15821ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
158328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// getMemOperand - Return a MachineMemOperand object describing the memory
158428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// reference performed by operation.
15851ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MachineMemOperand getMemOperand() const;
15861ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
1587475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getChain() const { return getOperand(0); }
1588475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const {
15891ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman    return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
15901ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  }
159128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1592b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  /// getRawFlags - Represent the flags as a bunch of bits.
1593b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  ///
1594b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  unsigned getRawFlags() const { return Flags; }
1595b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman
159628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Methods to support isa and dyn_cast
159728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const MemSDNode *) { return true; }
159828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const SDNode *N) {
1599c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // For some targets, we lower some target intrinsics to a MemIntrinsicNode
1600c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // with either an intrinsic or a target opcode.
1601e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    return N->getOpcode() == ISD::LOAD                ||
1602e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::STORE               ||
1603e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_CMP_SWAP_8   ||
1604e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_SWAP_8       ||
1605e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_ADD_8   ||
1606e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_SUB_8   ||
1607e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_AND_8   ||
1608e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_OR_8    ||
1609e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_XOR_8   ||
1610e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_NAND_8  ||
1611e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MIN_8   ||
1612e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MAX_8   ||
1613e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_8  ||
1614e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_8  ||
1615e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen
1616e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_CMP_SWAP_16  ||
1617e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_SWAP_16      ||
1618e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_ADD_16  ||
1619e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_SUB_16  ||
1620e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_AND_16  ||
1621e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_OR_16   ||
1622e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_XOR_16  ||
1623e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_NAND_16 ||
1624e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MIN_16  ||
1625e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MAX_16  ||
1626e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_16 ||
1627e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_16 ||
1628e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen
1629e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_CMP_SWAP_32  ||
1630e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_SWAP_32      ||
1631e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_ADD_32  ||
1632e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_SUB_32  ||
1633e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_AND_32  ||
1634e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_OR_32   ||
1635e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_XOR_32  ||
1636e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_NAND_32 ||
1637e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MIN_32  ||
1638e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MAX_32  ||
1639e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_32 ||
1640e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_32 ||
1641e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen
1642e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_CMP_SWAP_64  ||
1643e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_SWAP_64      ||
1644e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_ADD_64  ||
1645e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_SUB_64  ||
1646e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_AND_64  ||
1647e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_OR_64   ||
1648e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_XOR_64  ||
1649e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_NAND_64 ||
1650e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MIN_64  ||
1651e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MAX_64  ||
1652e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_64 ||
1653c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_64 ||
1654c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
1655c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_W_CHAIN   ||
1656c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_VOID      ||
1657c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->isTargetOpcode();
165828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  }
165928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang};
166028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1661c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// AtomicSDNode - A SDNode reprenting atomic operations.
1662c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang///
166328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass AtomicSDNode : public MemSDNode {
1664ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
16659cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[4];
166628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
166728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang public:
166828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Opc:   opcode for atomic
166928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // VTL:    value type list
167028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Chain:  memory chain for operaand
1671475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  // Ptr:    address to update as a SDValue
167228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Cmp:    compare value
167328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Swp:    swap value
167428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // SrcVal: address to update as a Value (used for MemOperand)
167528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Align:  alignment of memory
1676475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr,
1677475871a144eb604ddaf37503397ba0941442e5fbDan Gohman               SDValue Cmp, SDValue Swp, const Value* SrcVal,
167828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang               unsigned Align=0)
16791ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman    : MemSDNode(Opc, VTL, Cmp.getValueType(), SrcVal, /*SVOffset=*/0,
1680492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman                Align, /*isVolatile=*/true) {
1681ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    Ops[0] = Chain;
1682c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth    Ops[1] = Ptr;
1683d18a462bdd8ba6a7dd14e40ff0ebaedf9c46de26Dale Johannesen    Ops[2] = Cmp;
1684d18a462bdd8ba6a7dd14e40ff0ebaedf9c46de26Dale Johannesen    Ops[3] = Swp;
1685ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    InitOperands(Ops, 4);
1686ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth  }
1687475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr,
1688475871a144eb604ddaf37503397ba0941442e5fbDan Gohman               SDValue Val, const Value* SrcVal, unsigned Align=0)
16891ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman    : MemSDNode(Opc, VTL, Val.getValueType(), SrcVal, /*SVOffset=*/0,
1690492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman                Align, /*isVolatile=*/true) {
1691ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    Ops[0] = Chain;
1692c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth    Ops[1] = Ptr;
1693c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth    Ops[2] = Val;
1694ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    InitOperands(Ops, 3);
1695ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth  }
169628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1697475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(1); }
1698475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getVal() const { return getOperand(2); }
169928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1700e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen  bool isCompareAndSwap() const {
1701e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    unsigned Op = getOpcode();
1702e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    return Op == ISD::ATOMIC_CMP_SWAP_8 ||
1703e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           Op == ISD::ATOMIC_CMP_SWAP_16 ||
1704e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           Op == ISD::ATOMIC_CMP_SWAP_32 ||
1705e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           Op == ISD::ATOMIC_CMP_SWAP_64;
1706e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen  }
170728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
170828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Methods to support isa and dyn_cast
170928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const AtomicSDNode *) { return true; }
171028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const SDNode *N) {
1711e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    return N->getOpcode() == ISD::ATOMIC_CMP_SWAP_8   ||
1712e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_SWAP_8       ||
1713e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_ADD_8   ||
1714e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_SUB_8   ||
1715e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_AND_8   ||
1716e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_OR_8    ||
1717e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_XOR_8   ||
1718e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_NAND_8  ||
1719e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MIN_8   ||
1720e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MAX_8   ||
1721e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_8  ||
1722e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_8  ||
1723e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_CMP_SWAP_16  ||
1724e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_SWAP_16      ||
1725e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_ADD_16  ||
1726e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_SUB_16  ||
1727e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_AND_16  ||
1728e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_OR_16   ||
1729e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_XOR_16  ||
1730e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_NAND_16 ||
1731e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MIN_16  ||
1732e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MAX_16  ||
1733e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_16 ||
1734e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_16 ||
1735e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_CMP_SWAP_32  ||
1736e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_SWAP_32      ||
1737e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_ADD_32  ||
1738e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_SUB_32  ||
1739e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_AND_32  ||
1740e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_OR_32   ||
1741e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_XOR_32  ||
1742e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_NAND_32 ||
1743e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MIN_32  ||
1744e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MAX_32  ||
1745e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_32 ||
1746e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_32 ||
1747e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_CMP_SWAP_64  ||
1748e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_SWAP_64      ||
1749e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_ADD_64  ||
1750e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_SUB_64  ||
1751e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_AND_64  ||
1752e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_OR_64   ||
1753e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_XOR_64  ||
1754e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_NAND_64 ||
1755e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MIN_64  ||
1756e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_MAX_64  ||
1757e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_64 ||
1758e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_64;
175928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  }
1760ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth};
1761ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
1762c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// MemIntrinsicSDNode - This SDNode is used for target intrinsic that touches
1763c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// memory and need an associated memory operand.
1764c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang///
1765c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wangclass MemIntrinsicSDNode : public MemSDNode {
1766c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1767c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool ReadMem;  // Intrinsic reads memory
1768c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool WriteMem; // Intrinsic writes memory
1769c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  public:
1770c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  MemIntrinsicSDNode(unsigned Opc, SDVTList VTs,
1771c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     const SDValue *Ops, unsigned NumOps,
1772c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     MVT MemoryVT, const Value *srcValue, int SVO,
1773c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     unsigned Align, bool Vol, bool ReadMem, bool WriteMem)
1774c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    : MemSDNode(Opc, VTs, Ops, NumOps, MemoryVT, srcValue, SVO, Align, Vol),
1775c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang      ReadMem(ReadMem), WriteMem(WriteMem) {
1776c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  }
1777c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
1778c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool readMem() const { return ReadMem; }
1779c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool writeMem() const { return WriteMem; }
1780c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
1781c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  // Methods to support isa and dyn_cast
1782c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  static bool classof(const MemIntrinsicSDNode *) { return true; }
1783c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  static bool classof(const SDNode *N) {
1784c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // We lower some target intrinsics to their target opcode
1785c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // early a node with a target opcode can be of this class
1786c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    return N->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1787c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_VOID ||
1788c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->isTargetOpcode();
1789c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  }
1790c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang};
1791c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
179263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode {
17934fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantInt *Value;
1794c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
179563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
179663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
17974fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT)
1798bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1799bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      Value(val) {
180063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
180163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
180263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
18034fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantInt *getConstantIntValue() const { return Value; }
18044fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const APInt &getAPIntValue() const { return Value->getValue(); }
18054fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  uint64_t getZExtValue() const { return Value->getZExtValue(); }
18067810bfed5570c192e0714a8fd0e5130a0c38dd2eDan Gohman  int64_t getSExtValue() const { return Value->getSExtValue(); }
180763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
18084fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  bool isNullValue() const { return Value->isNullValue(); }
18094fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  bool isAllOnesValue() const { return Value->isAllOnesValue(); }
181063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
181163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantSDNode *) { return true; }
181263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1813056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    return N->getOpcode() == ISD::Constant ||
1814056f9f61d071c6c583951678f2bf543a1316efccChris Lattner           N->getOpcode() == ISD::TargetConstant;
181563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
181663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
181763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
181863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode {
18194fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantFP *Value;
1820c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
182163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
182263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
18234fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT)
182487503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
182587503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen             getSDVTList(VT)), Value(val) {
182663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
182763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
182863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
18294fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const APFloat& getValueAPF() const { return Value->getValueAPF(); }
18304fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantFP *getConstantFPValue() const { return Value; }
183163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
183263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isExactlyValue - We don't rely on operator== working on double values, as
183363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
183463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// As such, this method can be used to do an exact bit-for-bit comparison of
183563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// two floating point values.
1836c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen
1837c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// We leave the version with the double argument here because it's just so
1838c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// convenient to write "2.0" and the like.  Without this function we'd
1839c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// have to duplicate its logic everywhere it's called.
18409dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen  bool isExactlyValue(double V) const {
184123a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen    bool ignored;
18429dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen    // convert is not supported on this type
18434fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman    if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble)
18449dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen      return false;
184584cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner    APFloat Tmp(V);
18464fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman    Tmp.convert(Value->getValueAPF().getSemantics(),
184723a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen                APFloat::rmNearestTiesToEven, &ignored);
184884cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner    return isExactlyValue(Tmp);
184987503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen  }
1850e6c1742914149d44360fbf05a653041a672282afDale Johannesen  bool isExactlyValue(const APFloat& V) const;
185163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
185283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  bool isValueValidForType(MVT VT, const APFloat& Val);
1853f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen
185463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantFPSDNode *) { return true; }
185563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1856ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    return N->getOpcode() == ISD::ConstantFP ||
1857ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner           N->getOpcode() == ISD::TargetConstantFP;
185863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
185963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
186063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
186163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode {
186263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *TheGlobal;
18636520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  int64_t Offset;
1864c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
186563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
186663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
18676520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT,
18686520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman                      int64_t o = 0);
186963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
187063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
187163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *getGlobal() const { return TheGlobal; }
18726520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  int64_t getOffset() const { return Offset; }
187363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
187463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const GlobalAddressSDNode *) { return true; }
187563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1876f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    return N->getOpcode() == ISD::GlobalAddress ||
1877b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::TargetGlobalAddress ||
1878b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::GlobalTLSAddress ||
1879b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::TargetGlobalTLSAddress;
188063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
188163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
188263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
188363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode {
188463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int FI;
1885c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
188663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
188763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
188883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  FrameIndexSDNode(int fi, MVT VT, bool isTarg)
1889bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1890bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      FI(fi) {
189163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
189263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
189363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
189463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int getIndex() const { return FI; }
189563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
189663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const FrameIndexSDNode *) { return true; }
189763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1898afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    return N->getOpcode() == ISD::FrameIndex ||
1899afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner           N->getOpcode() == ISD::TargetFrameIndex;
190063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
190163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
190263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
190337efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode {
190437efe6764568a3829fee26aba532283131d1a104Nate Begeman  int JTI;
1905c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
190637efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected:
190737efe6764568a3829fee26aba532283131d1a104Nate Begeman  friend class SelectionDAG;
190883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  JumpTableSDNode(int jti, MVT VT, bool isTarg)
1909bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1910bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      JTI(jti) {
191163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
191237efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic:
191337efe6764568a3829fee26aba532283131d1a104Nate Begeman
191459a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner  int getIndex() const { return JTI; }
191537efe6764568a3829fee26aba532283131d1a104Nate Begeman
191637efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const JumpTableSDNode *) { return true; }
191737efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const SDNode *N) {
191837efe6764568a3829fee26aba532283131d1a104Nate Begeman    return N->getOpcode() == ISD::JumpTable ||
191937efe6764568a3829fee26aba532283131d1a104Nate Begeman           N->getOpcode() == ISD::TargetJumpTable;
192037efe6764568a3829fee26aba532283131d1a104Nate Begeman  }
192137efe6764568a3829fee26aba532283131d1a104Nate Begeman};
192237efe6764568a3829fee26aba532283131d1a104Nate Begeman
192363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode {
1924d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  union {
1925d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Constant *ConstVal;
1926d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    MachineConstantPoolValue *MachineCPVal;
1927d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  } Val;
1928baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1929b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned Alignment;
1930c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
193163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
193263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
193383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0)
1934ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1935bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(0) {
1936d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1937d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1938d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
193983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align)
1940ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1941bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(Align) {
1942d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1943d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1944d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1945d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
194683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands                     MVT VT, int o=0)
1947ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1948bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(0) {
1949d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1950d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1951d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1952d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1953d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
195483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands                     MVT VT, int o, unsigned Align)
1955ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1956bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(Align) {
1957d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1958d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1959d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1960d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
196163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
196263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1963d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  bool isMachineConstantPoolEntry() const {
1964d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return (int)Offset < 0;
1965d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1966d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1967d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  Constant *getConstVal() const {
1968d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1969d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.ConstVal;
1970d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1971d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1972d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  MachineConstantPoolValue *getMachineCPVal() const {
1973d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1974d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.MachineCPVal;
1975d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1976d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1977baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int getOffset() const {
1978baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng    return Offset & ~(1 << (sizeof(unsigned)*8-1));
1979baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  }
1980ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner
1981ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // Return the alignment of this constant pool object, which is either 0 (for
1982ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // default alignment) or log2 of the desired value.
1983b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned getAlignment() const { return Alignment; }
198463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1985d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  const Type *getType() const;
1986d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
198763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantPoolSDNode *) { return true; }
198863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1989aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    return N->getOpcode() == ISD::ConstantPool ||
1990aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner           N->getOpcode() == ISD::TargetConstantPool;
199163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
199263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
199363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
199463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode {
199563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *MBB;
1996c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
199763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
199863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1999423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit BasicBlockSDNode(MachineBasicBlock *mbb)
2000bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
200163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
200263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
200363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
200463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *getBasicBlock() const { return MBB; }
200563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
200663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const BasicBlockSDNode *) { return true; }
200763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
200863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return N->getOpcode() == ISD::BasicBlock;
200963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
201063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
201163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
201214471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
201314471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// used when the SelectionDAG needs to make a simple reference to something
201414471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// in the LLVM IR representation.
201514471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman///
201614471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// Note that this is not used for carrying alias information; that is done
201714471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// with MemOperandSDNode, which includes a Value which is required to be a
201814471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// pointer, and several other fields specific to memory references.
201914471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman///
20202d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode {
20212d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *V;
2022c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
20232d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected:
20242d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  friend class SelectionDAG;
202569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  /// Create a SrcValue for a general value.
202669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  explicit SrcValueSDNode(const Value *v)
202769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {}
20282d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
20292d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic:
203069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  /// getValue - return the contained Value.
20312d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *getValue() const { return V; }
20322d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
20332d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SrcValueSDNode *) { return true; }
20342d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SDNode *N) {
20352d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth    return N->getOpcode() == ISD::SRCVALUE;
20362d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
20372d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth};
20382d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
203963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
204036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is
204169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// used to represent a reference to memory after ISD::LOAD
204269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// and ISD::STORE have been lowered.
204369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman///
204469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanclass MemOperandSDNode : public SDNode {
204569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
204669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanprotected:
204769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  friend class SelectionDAG;
204836b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  /// Create a MachineMemOperand node
204936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  explicit MemOperandSDNode(const MachineMemOperand &mo)
205069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {}
205169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
205269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanpublic:
205336b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  /// MO - The contained MachineMemOperand.
205436b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  const MachineMemOperand MO;
205569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
205669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  static bool classof(const MemOperandSDNode *) { return true; }
205769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  static bool classof(const SDNode *N) {
205869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    return N->getOpcode() == ISD::MEMOPERAND;
205969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  }
206069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman};
206169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
206269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
2063d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode {
206463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned Reg;
2065c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
206663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
206763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
206883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  RegisterSDNode(unsigned reg, MVT VT)
2069bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
207063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
207163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
207263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
207363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned getReg() const { return Reg; }
207463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
2075d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner  static bool classof(const RegisterSDNode *) { return true; }
207663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
2077d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    return N->getOpcode() == ISD::Register;
207863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
207963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
208063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
20817f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanclass DbgStopPointSDNode : public SDNode {
20827f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  SDUse Chain;
20837f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned Line;
20847f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned Column;
20857f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  const CompileUnitDesc *CU;
20867f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
20877f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanprotected:
20887f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  friend class SelectionDAG;
2089475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
20907f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman                     const CompileUnitDesc *cu)
20917f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)),
20927f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman      Line(l), Column(c), CU(cu) {
20937f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    Chain = ch;
20947f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    InitOperands(&Chain, 1);
20957f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  }
20967f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanpublic:
20977f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned getLine() const { return Line; }
20987f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned getColumn() const { return Column; }
20997f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  const CompileUnitDesc *getCompileUnit() const { return CU; }
21007f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman
21017f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  static bool classof(const DbgStopPointSDNode *) { return true; }
21027f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  static bool classof(const SDNode *N) {
21037f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    return N->getOpcode() == ISD::DBG_STOPPOINT;
21047f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  }
21057f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman};
21067f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman
21074406604047423576e36657c7ede266ca42e79642Dan Gohmanclass LabelSDNode : public SDNode {
21084406604047423576e36657c7ede266ca42e79642Dan Gohman  SDUse Chain;
21094406604047423576e36657c7ede266ca42e79642Dan Gohman  unsigned LabelID;
21104406604047423576e36657c7ede266ca42e79642Dan Gohman  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
21114406604047423576e36657c7ede266ca42e79642Dan Gohmanprotected:
21124406604047423576e36657c7ede266ca42e79642Dan Gohman  friend class SelectionDAG;
2113475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id)
21144406604047423576e36657c7ede266ca42e79642Dan Gohman    : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) {
21154406604047423576e36657c7ede266ca42e79642Dan Gohman    Chain = ch;
21164406604047423576e36657c7ede266ca42e79642Dan Gohman    InitOperands(&Chain, 1);
21174406604047423576e36657c7ede266ca42e79642Dan Gohman  }
21184406604047423576e36657c7ede266ca42e79642Dan Gohmanpublic:
21194406604047423576e36657c7ede266ca42e79642Dan Gohman  unsigned getLabelID() const { return LabelID; }
21204406604047423576e36657c7ede266ca42e79642Dan Gohman
21214406604047423576e36657c7ede266ca42e79642Dan Gohman  static bool classof(const LabelSDNode *) { return true; }
21224406604047423576e36657c7ede266ca42e79642Dan Gohman  static bool classof(const SDNode *N) {
21234406604047423576e36657c7ede266ca42e79642Dan Gohman    return N->getOpcode() == ISD::DBG_LABEL ||
21244406604047423576e36657c7ede266ca42e79642Dan Gohman           N->getOpcode() == ISD::EH_LABEL;
21254406604047423576e36657c7ede266ca42e79642Dan Gohman  }
21264406604047423576e36657c7ede266ca42e79642Dan Gohman};
21274406604047423576e36657c7ede266ca42e79642Dan Gohman
2128056292fd738924f3f7703725d8f630983794b5a5Bill Wendlingclass ExternalSymbolSDNode : public SDNode {
212963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *Symbol;
2130c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
213163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
213263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
2133056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
2134056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
2135056292fd738924f3f7703725d8f630983794b5a5Bill Wendling             getSDVTList(VT)), Symbol(Sym) {
2136056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  }
213763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
2138056292fd738924f3f7703725d8f630983794b5a5Bill Wendling
213963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *getSymbol() const { return Symbol; }
214063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
2141056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  static bool classof(const ExternalSymbolSDNode *) { return true; }
214263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
2143056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    return N->getOpcode() == ISD::ExternalSymbol ||
2144056292fd738924f3f7703725d8f630983794b5a5Bill Wendling           N->getOpcode() == ISD::TargetExternalSymbol;
214563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
214663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
214763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
21487cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode {
214963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ISD::CondCode Condition;
2150c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
215163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
215263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
2153423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit CondCodeSDNode(ISD::CondCode Cond)
2154bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
215563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
215663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
215763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
21587cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  ISD::CondCode get() const { return Condition; }
215963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
21607cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  static bool classof(const CondCodeSDNode *) { return true; }
216163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
21627cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    return N->getOpcode() == ISD::CONDCODE;
216363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
216463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
216563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
216677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the
216777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// future and most targets don't support it.
216877cdf30742284a173fe818417eb482224cdee8d4Mon P Wangclass CvtRndSatSDNode : public SDNode {
216977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  ISD::CvtCode CvtCode;
217077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
217177cdf30742284a173fe818417eb482224cdee8d4Mon P Wangprotected:
217277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  friend class SelectionDAG;
217377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  explicit CvtRndSatSDNode(MVT VT, const SDValue *Ops, unsigned NumOps,
217477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang                           ISD::CvtCode Code)
217577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    : SDNode(ISD::CONVERT_RNDSAT, getSDVTList(VT), Ops, NumOps), CvtCode(Code) {
217677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    assert(NumOps == 5 && "wrong number of operations");
217777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  }
217877cdf30742284a173fe818417eb482224cdee8d4Mon P Wangpublic:
217977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  ISD::CvtCode getCvtCode() const { return CvtCode; }
218077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
218177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  static bool classof(const CvtRndSatSDNode *) { return true; }
218277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  static bool classof(const SDNode *N) {
218377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    return N->getOpcode() == ISD::CONVERT_RNDSAT;
218477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  }
218577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang};
218677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
2187276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsnamespace ISD {
2188276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  struct ArgFlagsTy {
2189276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  private:
2190276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t NoFlagSet      = 0ULL;
2191276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ZExt           = 1ULL<<0;  ///< Zero extended
2192276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ZExtOffs       = 0;
2193276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SExt           = 1ULL<<1;  ///< Sign extended
2194276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SExtOffs       = 1;
2195276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t InReg          = 1ULL<<2;  ///< Passed in register
2196276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t InRegOffs      = 2;
2197276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SRet           = 1ULL<<3;  ///< Hidden struct-ret ptr
2198276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SRetOffs       = 3;
2199276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByVal          = 1ULL<<4;  ///< Struct passed by value
2200276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValOffs      = 4;
2201276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t Nest           = 1ULL<<5;  ///< Nested fn static chain
2202276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t NestOffs       = 5;
2203276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValAlign     = 0xFULL << 6; //< Struct alignment
2204276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValAlignOffs = 6;
22056ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    static const uint64_t Split          = 1ULL << 10;
22066ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    static const uint64_t SplitOffs      = 10;
2207276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t OrigAlign      = 0x1FULL<<27;
2208276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t OrigAlignOffs  = 27;
2209276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValSize      = 0xffffffffULL << 32; //< Struct size
2210276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValSizeOffs  = 32;
2211276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2212276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t One            = 1ULL; //< 1 of this type, for shifts
2213276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2214276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    uint64_t Flags;
2215276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  public:
2216276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    ArgFlagsTy() : Flags(0) { }
2217276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2218276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isZExt()   const { return Flags & ZExt; }
2219276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setZExt()  { Flags |= One << ZExtOffs; }
2220276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2221276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isSExt()   const { return Flags & SExt; }
2222276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setSExt()  { Flags |= One << SExtOffs; }
2223276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2224276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isInReg()  const { return Flags & InReg; }
2225276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setInReg() { Flags |= One << InRegOffs; }
2226276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2227276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isSRet()   const { return Flags & SRet; }
2228276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setSRet()  { Flags |= One << SRetOffs; }
2229276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2230276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isByVal()  const { return Flags & ByVal; }
2231276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByVal() { Flags |= One << ByValOffs; }
2232276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2233276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isNest()   const { return Flags & Nest; }
2234276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setNest()  { Flags |= One << NestOffs; }
2235276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2236276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getByValAlign() const {
223794bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)
223894bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen        ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
2239276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2240276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByValAlign(unsigned A) {
2241276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~ByValAlign) |
2242276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands        (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
2243276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2244c0cb28fd3abee9a8b40856990e04f1af2f9bd7b8Nicolas Geoffray
22456ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    bool isSplit()   const { return Flags & Split; }
22466ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    void setSplit()  { Flags |= One << SplitOffs; }
2247276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2248276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getOrigAlign() const {
224994bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)
225094bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen        ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
2251276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2252276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setOrigAlign(unsigned A) {
2253276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~OrigAlign) |
2254276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands        (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
2255276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2256276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2257276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getByValSize() const {
225894bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
2259276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2260276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByValSize(unsigned S) {
2261276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
2262276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2263276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2264276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
2265276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    std::string getArgFlagsString();
2266276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2267276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    /// getRawBits - Represent the flags as a bunch of bits.
2268276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    uint64_t getRawBits() const { return Flags; }
2269276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  };
2270276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands}
2271276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2272276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands/// ARG_FLAGSSDNode - Leaf node holding parameter flags.
2273276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsclass ARG_FLAGSSDNode : public SDNode {
2274276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ISD::ArgFlagsTy TheFlags;
2275276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2276276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsprotected:
2277276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  friend class SelectionDAG;
2278276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags)
2279276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) {
2280276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  }
2281276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandspublic:
2282276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ISD::ArgFlagsTy getArgFlags() const { return TheFlags; }
2283276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2284276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  static bool classof(const ARG_FLAGSSDNode *) { return true; }
2285276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  static bool classof(const SDNode *N) {
2286276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    return N->getOpcode() == ISD::ARG_FLAGS;
2287276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  }
2288276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands};
2289276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2290095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman/// CallSDNode - Node for calls -- ISD::CALL.
2291095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanclass CallSDNode : public SDNode {
2292095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned CallingConv;
2293095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  bool IsVarArg;
2294095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  bool IsTailCall;
229586098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // We might eventually want a full-blown Attributes for the result; that
229686098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // will expand the size of the representation.  At the moment we only
229786098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // need Inreg.
229886098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  bool Inreg;
2299095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
2300095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanprotected:
2301095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  friend class SelectionDAG;
230286098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  CallSDNode(unsigned cc, bool isvararg, bool istailcall, bool isinreg,
2303095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman             SDVTList VTs, const SDValue *Operands, unsigned numOperands)
2304095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    : SDNode(ISD::CALL, VTs, Operands, numOperands),
230586098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen      CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall),
230686098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen      Inreg(isinreg) {}
2307095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanpublic:
2308095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getCallingConv() const { return CallingConv; }
2309095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned isVarArg() const { return IsVarArg; }
2310095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned isTailCall() const { return IsTailCall; }
231186098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  unsigned isInreg() const { return Inreg; }
2312095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2313095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  /// Set this call to not be marked as a tail call. Normally setter
2314095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  /// methods in SDNodes are unsafe because it breaks the CSE map,
23155eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman  /// but we don't include the tail call flag for calls so it's ok
23165eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman  /// in this case.
2317095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  void setNotTailCall() { IsTailCall = false; }
2318095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2319095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getChain() const { return getOperand(0); }
2320095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getCallee() const { return getOperand(1); }
2321095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2322095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getNumArgs() const { return (getNumOperands() - 2) / 2; }
2323095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getArg(unsigned i) const { return getOperand(2+2*i); }
2324095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getArgFlagsVal(unsigned i) const {
2325095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return getOperand(3+2*i);
2326095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2327095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  ISD::ArgFlagsTy getArgFlags(unsigned i) const {
2328095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return cast<ARG_FLAGSSDNode>(getArgFlagsVal(i).getNode())->getArgFlags();
2329095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2330095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2331095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getNumRetVals() const { return getNumValues() - 1; }
2332095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  MVT getRetValType(unsigned i) const { return getValueType(i); }
2333095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2334095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  static bool classof(const CallSDNode *) { return true; }
2335095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  static bool classof(const SDNode *N) {
2336095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return N->getOpcode() == ISD::CALL;
2337095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2338095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman};
2339095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
234083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands/// VTSDNode - This class is used to represent MVT's, which are used
234115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations.
234215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode {
234383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT ValueType;
2344c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
234515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected:
234615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  friend class SelectionDAG;
234783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  explicit VTSDNode(MVT VT)
2348bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
234963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
235015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic:
235115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
235283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT getVT() const { return ValueType; }
235315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
235415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const VTSDNode *) { return true; }
235515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const SDNode *N) {
235615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    return N->getOpcode() == ISD::VALUETYPE;
235715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  }
235815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner};
235915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
23609de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
23619de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel///
236228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass LSBaseSDNode : public MemSDNode {
23639de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprotected:
23649de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel  //! Operand array for load and store
23659de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel  /*!
23669de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    \note Moving this array to the base class captures more
23679de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    common functionality shared between LoadSDNode and
23689de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    StoreSDNode
23699de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel   */
23709cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[4];
23719de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic:
2372475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LSBaseSDNode(ISD::NodeType NodeTy, SDValue *Operands, unsigned numOperands,
237383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands               SDVTList VTs, ISD::MemIndexedMode AM, MVT VT,
2374b625f2f8960de32bc973092aaee8ac62863006feDan Gohman               const Value *SV, int SVO, unsigned Align, bool Vol)
2375ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol) {
2376ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    SubclassData = AM;
237713d57320bd212483463d4f8992d5787b29eda5dfBill Wendling    for (unsigned i = 0; i != numOperands; ++i)
2378b625f2f8960de32bc973092aaee8ac62863006feDan Gohman      Ops[i] = Operands[i];
237913d57320bd212483463d4f8992d5787b29eda5dfBill Wendling    InitOperands(Ops, numOperands);
2380b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    assert(Align != 0 && "Loads and stores should have non-zero aligment");
2381437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman    assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
2382437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman           "Only indexed loads and stores have a non-undef offset operand");
2383b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  }
23849de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
2385475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const {
238663602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner    return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
238763602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner  }
23889de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
2389ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// getAddressingMode - Return the addressing mode for this load or store:
2390ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2391ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  ISD::MemIndexedMode getAddressingMode() const {
2392ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    return ISD::MemIndexedMode(SubclassData & 7);
2393ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
2394b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
2395b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  /// isIndexed - Return true if this is a pre/post inc/dec load/store.
2396ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2397b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
2398b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
2399ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2400b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
240113d57320bd212483463d4f8992d5787b29eda5dfBill Wendling  static bool classof(const LSBaseSDNode *) { return true; }
2402b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  static bool classof(const SDNode *N) {
2403b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    return N->getOpcode() == ISD::LOAD ||
2404b625f2f8960de32bc973092aaee8ac62863006feDan Gohman           N->getOpcode() == ISD::STORE;
2405b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  }
24069de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel};
24079de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
240824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
240924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
24109de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode {
2411c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
241224446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
241324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
2414475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs,
241583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT,
241695c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb             const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2417b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
2418ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman                   VTs, AM, LVT, SV, O, Align, Vol) {
2419ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    SubclassData |= (unsigned short)ETy << 3;
2420ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
242124446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
242224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2423ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// getExtensionType - Return whether this is a plain node,
2424ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// or one of the varieties of value-extending loads.
2425ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  ISD::LoadExtType getExtensionType() const {
2426ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    return ISD::LoadExtType((SubclassData >> 3) & 3);
2427ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
2428ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
2429475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(1); }
2430475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const { return getOperand(2); }
243139354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner
243224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const LoadSDNode *) { return true; }
243324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
243424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD;
243524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
243624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
243724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
243824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes.
243924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
24409de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode {
2441c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
244224446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
244324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
2444475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs,
244583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands              ISD::MemIndexedMode AM, bool isTrunc, MVT SVT,
244624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2447b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
2448ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman                   VTs, AM, SVT, SV, O, Align, Vol) {
2449ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    SubclassData |= (unsigned short)isTrunc << 3;
2450ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
245124446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
245224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2453ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// isTruncatingStore - Return true if the op does a truncation before store.
2454ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// For integers this is the same as doing a TRUNCATE and storing the result.
2455ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// For floats, it is the same as doing an FP_ROUND and storing the result.
2456ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  bool isTruncatingStore() const { return (SubclassData >> 3) & 1; }
2457ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
2458475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getValue() const { return getOperand(1); }
2459475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(2); }
2460475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const { return getOperand(3); }
246139354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner
24626d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng  static bool classof(const StoreSDNode *) { return true; }
246324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
246424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::STORE;
246524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
246624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
246724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
246815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
24691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
24701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNode *Node;
24711080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned Operand;
2472ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
24731080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
24741080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic:
24751080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator==(const SDNodeIterator& x) const {
24761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return Operand == x.Operand;
24771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
24781080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
24791080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
24801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNodeIterator &operator=(const SDNodeIterator &I) {
24811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
24821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    Operand = I.Operand;
24831080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
24841080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
2485ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
24861080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator*() const {
2487ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node->getOperand(Operand).getNode();
24881080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
24891080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator->() const { return operator*(); }
2490ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
24911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator& operator++() {                // Preincrement
24921080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    ++Operand;
24931080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
24941080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
24951080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator operator++(int) { // Postincrement
2496ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SDNodeIterator tmp = *this; ++*this; return tmp;
24971080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
24981080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
24991080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
25001080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator end  (SDNode *N) {
25011080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator(N, N->getNumOperands());
25021080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
25031080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
25041080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned getOperand() const { return Operand; }
25051080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNode *getNode() const { return Node; }
25061080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
25071080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
25081080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> {
25091080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNode NodeType;
25101080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNodeIterator ChildIteratorType;
25111080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static inline NodeType *getEntryNode(SDNode *N) { return N; }
2512ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_begin(NodeType *N) {
25131080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::begin(N);
25141080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
2515ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_end(NodeType *N) {
25161080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::end(N);
25171080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
25181080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
25191080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
25200e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// LargestSDNode - The largest SDNode class.
25210e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman///
25220e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohmantypedef LoadSDNode LargestSDNode;
25230e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman
2524fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// MostAlignedSDNode - The SDNode class with the greatest alignment
2525fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// requirement.
2526fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman///
2527015b714f298ce3122302a4e996b81bd3e8c750cdDan Gohmantypedef ARG_FLAGSSDNode MostAlignedSDNode;
2528b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
2529c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD {
2530186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  /// isNormalLoad - Returns true if the specified node is a non-extending
2531186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  /// and unindexed load.
2532186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  inline bool isNormalLoad(const SDNode *N) {
2533c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
2534c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
2535186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng      Ld->getAddressingMode() == ISD::UNINDEXED;
2536186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  }
2537186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng
253824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// isNON_EXTLoad - Returns true if the specified node is a non-extending
253924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// load.
254024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  inline bool isNON_EXTLoad(const SDNode *N) {
2541c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
254224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
254324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
254424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2545c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
2546c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2547c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isEXTLoad(const SDNode *N) {
2548c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
254924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
2550c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
2551c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2552c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
2553c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2554c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isSEXTLoad(const SDNode *N) {
2555c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
255624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
2557c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
2558c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2559c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
2560c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2561c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isZEXTLoad(const SDNode *N) {
2562c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
256324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
2564c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
25658b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
2566c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
256702c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  ///
256802c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  inline bool isUNINDEXEDLoad(const SDNode *N) {
2569c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
257002c50e4891841c28b2a743731dfc60744bb78879Evan Cheng      cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
257102c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  }
257202c50e4891841c28b2a743731dfc60744bb78879Evan Cheng
2573c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isNormalStore - Returns true if the specified node is a non-truncating
2574c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// and unindexed store.
2575c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  inline bool isNormalStore(const SDNode *N) {
2576c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
2577c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return St && !St->isTruncatingStore() &&
2578c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands      St->getAddressingMode() == ISD::UNINDEXED;
2579c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  }
2580c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands
25818b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
25828b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
25838b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isNON_TRUNCStore(const SDNode *N) {
2584c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
25858b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
25868b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
25878b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isTRUNCStore - Returns true if the specified node is a truncating
25888b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
25898b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isTRUNCStore(const SDNode *N) {
2590c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
2591c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  }
2592c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands
2593c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isUNINDEXEDStore - Returns true if the specified node is an
2594c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// unindexed store.
2595c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  inline bool isUNINDEXEDStore(const SDNode *N) {
2596c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) &&
2597c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands      cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
25988b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
2599c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
2600c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2601c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
260263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace
260363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
260463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif
2605