SelectionDAGNodes.h revision e7852d014432a06c783de3c350eb96e686f10f92
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
224fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman#include "llvm/Constants.h"
23583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/ADT/FoldingSet.h"
241080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/GraphTraits.h"
2543d1fd449f1a0ac9d9dafa0b9569bb6b2e976198Anton Korobeynikov#include "llvm/ADT/iterator.h"
26fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/ilist_node.h"
27fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/STLExtras.h"
28d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h"
2936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman#include "llvm/CodeGen/MachineMemOperand.h"
300e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/Allocator.h"
310e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/RecyclingAllocator.h"
3239931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h"
3363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert>
3463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm {
3663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG;
3863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue;
3963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock;
40d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue;
4163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode;
4283489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patelclass Value;
4376c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate <typename T> struct DenseMapInfo;
4463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type;
458e4018e2de52c534405d7155c7009d0b35afb861Cedric Venettemplate <typename T> struct ilist_traits;
4663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
470b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by
480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG.  Instances of this simple value class are returned by
490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...).
500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner///
510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList {
5283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  const MVT *VTs;
530b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  unsigned short NumVTs;
540b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner};
550b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
5663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the
5763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types.
5863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
5963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD {
60d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov
6163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
6263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::NodeType enum - This enum defines all of the operators valid in a
6363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SelectionDAG.
6463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
6563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum NodeType {
663258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // DELETED_NODE - This is an illegal flag value that is used to catch
673258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // errors.  This opcode is not a legal opcode for any node.
683258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    DELETED_NODE,
693258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner
708a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // EntryToken - This is the marker used to indicate the start of the region.
718a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    EntryToken,
728a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner
73b2ab0e7471df7126a5b63fe8414b95c9584a0214Bill Wendling    // TokenFactor - This node takes multiple tokens as input and produces a
748a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // single token result.  This is used to represent the fact that the operand
758a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // operators are independent of each other.
768a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    TokenFactor,
77f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman
78f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // AssertSext, AssertZext - These nodes record if a register contains a
79f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // value that has already been zero or sign extended from a narrower type.
80f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // These nodes take two operands.  The first is the node that has already
81f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // been extended, and the second is a value type node indicating the width
82f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // of the extension
83f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    AssertSext, AssertZext,
84ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
858a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // Various leaf nodes.
867f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register,
871ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    Constant, ConstantFP,
88b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    GlobalAddress, GlobalTLSAddress, FrameIndex,
89056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    JumpTable, ConstantPool, ExternalSymbol,
901ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng
9182c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    // The address of the GOT
9282c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    GLOBAL_OFFSET_TABLE,
93bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman
94bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
95bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // llvm.returnaddress on the DAG.  These nodes take one operand, the index
96bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // of the frame or return address to return.  An index of zero corresponds
97bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // to the current function's frame or return address, an index of one to the
98bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // parent's frame or return address, and so on.
99bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    FRAMEADDR, RETURNADDR,
1002365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
1012365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
1022365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // first (possible) on-stack argument. This is needed for correct stack
1032365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // adjustment during unwind.
1042365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    FRAME_TO_ARGS_OFFSET,
105f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
106f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the
107f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // address of the exception block on entry to an landing pad block.
108f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    EXCEPTIONADDR,
109f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
110f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents
111f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // the selection index of the exception thrown.
112f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    EHSELECTION,
113beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth
1142365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
1152365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // 'eh_return' gcc dwarf builtin, which is used to return from
1162365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // exception. The general meaning is: adjust stack by OFFSET and pass
1172365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // execution to HANDLER. Many platform-related details also :)
1182365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    EH_RETURN,
1192365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
120ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // TargetConstant* - Like Constant*, but the DAG does not do any folding or
121ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // simplification of the constant.
122056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    TargetConstant,
123ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    TargetConstantFP,
124f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner
125f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
126f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // anything else with this node, and this is valid in the target-specific
127f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // dag, turning into a GlobalAddress operand.
128f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    TargetGlobalAddress,
129b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    TargetGlobalTLSAddress,
130afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    TargetFrameIndex,
13137efe6764568a3829fee26aba532283131d1a104Nate Begeman    TargetJumpTable,
132aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    TargetConstantPool,
133056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    TargetExternalSymbol,
13472601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner
135ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
136ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with no side effects.
137ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// The first operand is the ID number of the intrinsic from the
138ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// llvm::Intrinsic namespace.  The operands to the intrinsic follow.  The
139ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// node has returns the result of the intrinsic.
140ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_WO_CHAIN,
141ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
142ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
143ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
144ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// returns a result.  The first operand is a chain pointer.  The second is
145ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// the ID number of the intrinsic from the llvm::Intrinsic namespace.  The
146ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// operands to the intrinsic follow.  The node has two results, the result
147ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// of the intrinsic and an output chain.
148ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_W_CHAIN,
14963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
150ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
151ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
152ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// does not return a result.  The first operand is a chain pointer.  The
153ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// second is the ID number of the intrinsic from the llvm::Intrinsic
154ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// namespace.  The operands to the intrinsic follow.
155ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_VOID,
156ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
157d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // CopyToReg - This node has three operands: a chain, a register number to
158d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // set to this value, and a value.
15963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyToReg,
16063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
16163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // CopyFromReg - This node indicates that the input value is a virtual or
16263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // physical register that is defined outside of the scope of this
163ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman    // SelectionDAG.  The register is available from the RegisterSDNode object.
16463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyFromReg,
16563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
166fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    // UNDEF - An undefined node
167fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    UNDEF,
168681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner
169b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
170b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// represents the formal arguments for a function.  CC# is a Constant value
171b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// indicating the calling convention of the function, and ISVARARG is a
172b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// flag that indicates whether the function is varargs or not. This node
173b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// has one result value for each incoming argument, plus one for the output
174b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// chain. It must be custom legalized. See description of CALL node for
175b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FLAG argument contents explanation.
176c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner    ///
177681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner    FORMAL_ARGUMENTS,
1786c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner
179095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CALLEE,
180b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    ///                              ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn)
1816c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    /// This node represents a fully general function call, before the legalizer
182b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// runs.  This has one result value for each argument / flag pair, plus
183b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// a chain result. It must be custom legalized. Flag argument indicates
184b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// misc. argument attributes. Currently:
185b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 0 - signness
186b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 1 - 'inreg' attribute
187b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 2 - 'sret' attribute
188594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 4 - 'byval' attribute
189594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 5 - 'nest' attribute
190594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 6-9 - alignment of byval structures
191594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 10-26 - size of byval structures
19213a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio    /// Bits 31:27 - argument ABI alignment in the first argument piece and
19313a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio    /// alignment '1' in other argument pieces.
194095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    ///
195095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// CALL nodes use the CallSDNode subclass of SDNode, which
196095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// additionally carries information about the calling convention,
197095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// whether the call is varargs, and if it's marked as a tail call.
198095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    ///
1996c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    CALL,
200fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman
20125eb043759c23b61769108f78382eb9701c41db2Duncan Sands    // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by
202041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // a Constant, which is required to be operand #1) half of the integer or
203041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // float value specified as operand #0.  This is only for use before
204041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // legalization, for values that will be broken into multiple registers.
20563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    EXTRACT_ELEMENT,
20663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
20763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.  Given
20863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // two values of the same integer value type, this produces a value twice as
20963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // big.  Like EXTRACT_ELEMENT, this can only be used before legalization.
21063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BUILD_PAIR,
211041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands
212006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // MERGE_VALUES - This node takes multiple discrete operands and returns
213006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // them all as its individual results.  This nodes has exactly the same
214006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // number of inputs and outputs, and is only valid before legalization.
215006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // This node is useful for some pieces of the code generator that want to
216006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // think about a single node with multiple results, not multiple nodes.
217006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    MERGE_VALUES,
21863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
219615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple integer binary arithmetic operators.
220bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
221fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman
222fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing
223b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands    // a signed/unsigned value of type i[2*N], and return the full value as
224fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // two results, each of type iN.
225fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    SMUL_LOHI, UMUL_LOHI,
226fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman
227fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and
228fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // remainder result.
229fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    SDIVREM, UDIVREM,
230615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner
23155e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    // CARRY_FALSE - This node is used when folding other nodes,
23255e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    // like ADDC/SUBC, which indicate the carry result is always false.
23355e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    CARRY_FALSE,
23455e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner
235551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-setting nodes for multiple precision addition and subtraction.
236551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // These nodes take two operands of the same value type, and produce two
237551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // results.  The first result is the normal add or sub result, the second
238551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // result is the carry flag result.
239551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDC, SUBC,
240551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman
241551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-using nodes for multiple precision addition and subtraction.  These
242551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // nodes take three operands: The first two are the normal lhs and rhs to
243551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // the add or sub, and the third is the input carry flag.  These nodes
244551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // produce two results; the normal result of the add or sub, and the output
245551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // carry flag.  These nodes both read and write a carry flag to allow them
246551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // to them to be chained together for add and sub of arbitrarily large
247551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // values.
248551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDE, SUBE,
249ea7b527aa56ad0fe547d3d99b21e845a49a031cbBill Wendling
250253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
251253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // These nodes take two operands: the normal LHS and RHS to the add. They
252253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // produce two results: the normal result of the add, and a boolean that
253253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // indicates if an overflow occured (*not* a flag, because it may be stored
254253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // to memory, etc.).  If the type of the boolean is not i1 then the high
25503228089d5235f8c90477f88809139464e9c6ea5Duncan Sands    // bits conform to getBooleanContents.
256253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // These nodes are generated from the llvm.[su]add.with.overflow intrinsics.
2571c55a9c0cc355ad72c55ae7665143b9a992d223bBill Wendling    SADDO, UADDO,
258ea7b527aa56ad0fe547d3d99b21e845a49a031cbBill Wendling
25974c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    // Same for subtraction
26074c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    SSUBO, USUBO,
26174c376529101acbe141a256d0bf23a44eb454c84Bill Wendling
26274c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    // Same for multiplication
26374c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    SMULO, UMULO,
26474c376529101acbe141a256d0bf23a44eb454c84Bill Wendling
265615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple binary floating point operators.
266615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    FADD, FSUB, FMUL, FDIV, FREM,
26738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
26838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.  NOTE: This
26938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // DAG node does not require that X and Y have the same type, just that they
27038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // are both floating point.  X and the result must have the same type.
27138bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(f32, f64) is allowed.
27238bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    FCOPYSIGN,
273fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner
2741a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point
2751a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    // value as an integer 0/1 value.
2761a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    FGETSIGN,
2771a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner
278664e9546d674096c5a012536f1a424b1681ece51Dan Gohman    /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector
27922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// with the specified, possibly variable, elements.  The number of elements
28022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// is required to be a power of two.
28122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    BUILD_VECTOR,
28222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
2837f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
2844f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands    /// at IDX replaced with VAL.  If the type of VAL is larger than the vector
2854f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands    /// element type then VAL is truncated before replacement.
28622232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    INSERT_VECTOR_ELT,
2874b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner
2884b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
2897f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// identified by the (potentially variable) element number IDX.
2904b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    EXTRACT_VECTOR_ELT,
29122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
2927f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
2937f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// vector type with the same length and element type, this produces a
2947f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// concatenated vector result value, with length equal to the sum of the
295b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman    /// lengths of the input vectors.
2967f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    CONCAT_VECTORS,
2976595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman
2987f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
2997f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// vector value) starting with the (potentially variable) element number
3007f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// IDX, which must be a multiple of the result vector length.
3017f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    EXTRACT_SUBVECTOR,
30259c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands
30349c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
30449c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// type as VEC1/VEC2.  SHUFFLEVEC is a BUILD_VECTOR of constant int values
30559c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// (maybe of an illegal datatype) or undef that indicate which value each
30659c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// result element will get.  The elements of VEC1/VEC2 are enumerated in
30759c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// order.  This is quite similar to the Altivec 'vperm' instruction, except
30859c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// that the indices must be constants and are in terms of the element size
30959c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// of VEC1/VEC2, not in terms of bytes.
31049c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    VECTOR_SHUFFLE,
31159c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands
312210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
313a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman    /// scalar value into element 0 of the resultant vector type.  The top
314a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman    /// elements 1 to N-1 of the N-element vector are undefined.
315210721aecc0916315f61660dc387a96b89ec423bChris Lattner    SCALAR_TO_VECTOR,
316210721aecc0916315f61660dc387a96b89ec423bChris Lattner
317557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // EXTRACT_SUBREG - This node is used to extract a sub-register value.
318557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // This node takes a superreg and a constant sub-register index as operands.
319709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // Note sub-register indices must be increasing. That is, if the
320709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // sub-register index of a 8-bit sub-register is N, then the index for a
321709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // 16-bit sub-register must be at least N+1.
322557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    EXTRACT_SUBREG,
323557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb
3244499e495eabe8de7d595416a03c56af4688df507Evan Cheng    // INSERT_SUBREG - This node is used to insert a sub-register value.
325557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // This node takes a superreg, a subreg value, and a constant sub-register
3264499e495eabe8de7d595416a03c56af4688df507Evan Cheng    // index as operands.
327557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    INSERT_SUBREG,
328557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb
329bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
330b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands    // an unsigned/signed value of type i[2*N], then return the top part.
331bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    MULHU, MULHS,
33263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
33335ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // Bitwise operators - logical and, logical or, logical xor, shift left,
33435ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // shift right algebraic (shift in sign bits), shift right logical (shift in
33535ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // zeroes), rotate left, rotate right, and byteswap.
33635ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
33763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
338691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    // Counting operators
339691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    CTTZ, CTLZ, CTPOP,
340691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth
3413b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // Select(COND, TRUEVAL, FALSEVAL).  If the type of the boolean COND is not
34203228089d5235f8c90477f88809139464e9c6ea5Duncan Sands    // i1 then the high bits must conform to getBooleanContents.
3433b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    SELECT,
3443b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands
3459373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // Select with condition operator - This selects between a true value and
3469373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // a false value (ops #2 and #3) based on the boolean result of comparing
3479373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // the lhs and rhs (ops #0 and #1) of a conditional expression with the
3489373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // condition code in op #4, a CondCodeSDNode.
3499373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    SELECT_CC,
35063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3513b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // SetCC operator - This evaluates to a true value iff the condition is
3523b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // true.  If the result value type is not i1 then the high bits conform
35303228089d5235f8c90477f88809139464e9c6ea5Duncan Sands    // to getBooleanContents.  The operands to this are the left and right
3543b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // operands to compare (ops #0, and #1) and the condition code to compare
3553b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // them with (op #2) as a CondCodeSDNode.
35663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETCC,
35763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
358b43e9c196542acc80c9e4643809661065710848fNate Begeman    // Vector SetCC operator - This evaluates to a vector of integer elements
359b43e9c196542acc80c9e4643809661065710848fNate Begeman    // with the high bit in each element set to true if the comparison is true
360b43e9c196542acc80c9e4643809661065710848fNate Begeman    // and false if the comparison is false.  All other bits in each element
361b43e9c196542acc80c9e4643809661065710848fNate Begeman    // are undefined.  The operands to this are the left and right operands
362b43e9c196542acc80c9e4643809661065710848fNate Begeman    // to compare (ops #0, and #1) and the condition code to compare them with
363b43e9c196542acc80c9e4643809661065710848fNate Begeman    // (op #2) as a CondCodeSDNode.
364b43e9c196542acc80c9e4643809661065710848fNate Begeman    VSETCC,
365b43e9c196542acc80c9e4643809661065710848fNate Begeman
36614c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
36714c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // integer shift operations, just like ADD/SUB_PARTS.  The operation
36814c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // ordering is:
3696b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner    //       [Lo,Hi] = op [LoLHS,HiLHS], Amt
37014c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    SHL_PARTS, SRA_PARTS, SRL_PARTS,
37114c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner
37263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Conversion operators.  These are all single input single output
37363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operations.  For all of these, the result type must be strictly
37463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // wider or narrower (depending on the operation) than the source
37563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // type.
37663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
37763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // SIGN_EXTEND - Used for integer types, replicating the sign bit
37863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // into new bits.
37963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SIGN_EXTEND,
38063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
38163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // ZERO_EXTEND - Used for integer types, zeroing the new bits.
38263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    ZERO_EXTEND,
38363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3847e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    // ANY_EXTEND - Used for integer types.  The high bits are undefined.
3857e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    ANY_EXTEND,
3867e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner
38763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // TRUNCATE - Completely drop the high bits.
38863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    TRUNCATE,
38963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3901645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
3911645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // depends on the first letter) to floating point.
3921645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    SINT_TO_FP,
3931645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    UINT_TO_FP,
3941645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
395ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
396ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // sign extend a small value in a large integer register (e.g. sign
397ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // extending the low 8 bits of a 32-bit register to fill the top 24 bits
39815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // with the 7th bit).  The size of the smaller type is indicated by the 1th
39915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // operand, a ValueType node.
400859157daee6a4b49e99921832e1dde065167b317Chris Lattner    SIGN_EXTEND_INREG,
401859157daee6a4b49e99921832e1dde065167b317Chris Lattner
4020bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
4030bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// integer.
4041645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_SINT,
4051645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_UINT,
4061645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
4070bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type
4080bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// down to the precision of the destination VT.  TRUNC is a flag, which is
4090bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// always an integer that is zero or one.  If TRUNC is 0, this is a
4100bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// normal rounding, if it is 1, this FP_ROUND is known to not change the
4110bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// value of Y.
4120bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    ///
4130bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// The TRUNC = 1 case is used in cases where we know that the value will
4140bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// not be modified by the node, because Y is not using any of the extra
4150bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// precision of source type.  This allows certain transformations like
4160bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for
4170bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed.
41863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_ROUND,
4190bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner
4201a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman    // FLT_ROUNDS_ - Returns current rounding mode:
421917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    // -1 Undefined
422917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  0 Round to 0
423917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  1 Round to nearest
424917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  2 Round to +inf
425917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  3 Round to -inf
4261a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman    FLT_ROUNDS_,
427917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov
4280bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and
4290bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// rounds it to a floating point value.  It then promotes it and returns it
4300bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// in a register of the same size.  This operation effectively just
4310bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// discards excess precision.  The type to round down to is specified by
4320bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// the VT operand, a VTSDNode.
433859157daee6a4b49e99921832e1dde065167b317Chris Lattner    FP_ROUND_INREG,
434859157daee6a4b49e99921832e1dde065167b317Chris Lattner
4350bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
43663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_EXTEND,
43763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4381ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // BIT_CONVERT - Theis operator converts between integer and FP values, as
4391ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // if one was stored to memory as integer and the other was loaded from the
44080f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // same address (or equivalently for vector format conversions, etc).  The
44180f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // source and result are required to have the same bit size (e.g.
44280f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // f32 <-> i32).  This can also be used for int-to-int or fp-to-fp
44380f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // conversions, but that is a noop, deleted by getNode().
4441ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    BIT_CONVERT,
4451ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner
44677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    // CONVERT_RNDSAT - This operator is used to support various conversions
44700ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // between various types (float, signed, unsigned and vectors of those
44800ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // types) with rounding and saturation. NOTE: Avoid using this operator as
44900ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // most target don't support it and the operator might be removed in the
45000ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // future. It takes the following arguments:
45177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   0) value
45277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   1) dest type (type to convert to)
45377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   2) src type (type to convert from)
45477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   3) rounding imm
45577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   4) saturation imm
45677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   5) ISD::CvtCode indicating the type of conversion to do
45777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CONVERT_RNDSAT,
45877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
459509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
4607794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen    // FLOG, FLOG2, FLOG10, FEXP, FEXP2,
4618471ef5f4e79fbe4d7021e91d45e39fdbf8783fcDan Gohman    // FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR - Perform various unary floating
462509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    // point operations. These are inspired by libm.
46307f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman    FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
4647794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen    FLOG, FLOG2, FLOG10, FEXP, FEXP2,
465509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR,
46638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
4678862ef148100070b7bf28beead3951464250c926Evan Cheng    // LOAD and STORE have token chains as their first operand, then the same
4688862ef148100070b7bf28beead3951464250c926Evan Cheng    // operands as an LLVM load/store instruction, then an offset node that
4698862ef148100070b7bf28beead3951464250c926Evan Cheng    // is added / subtracted from the base pointer to form the address (for
4708862ef148100070b7bf28beead3951464250c926Evan Cheng    // indexed memory ops).
47163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    LOAD, STORE,
472ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
47363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
47457fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // to a specified boundary.  This node always has two return values: a new
47557fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // stack pointer value and a chain. The first operand is the token chain,
47657fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // the second is the number of bytes to allocate, and the third is the
47757fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // alignment boundary.  The size is guaranteed to be a multiple of the stack
47857fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // alignment, and the alignment is guaranteed to be bigger than the stack
47974fe063e90045931eefaba561730e6a9175ced78Chris Lattner    // alignment (if required) or 0 to get standard stack alignment.
48063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    DYNAMIC_STACKALLOC,
48163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
48263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Control flow instructions.  These all have token chains.
483ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
48463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BR - Unconditional branch.  The first operand is the chain
48563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operand, the second is the MBB to branch to.
48663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BR,
48763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
48837efe6764568a3829fee26aba532283131d1a104Nate Begeman    // BRIND - Indirect branch.  The first operand is the chain, the second
48937efe6764568a3829fee26aba532283131d1a104Nate Begeman    // is the value to branch to, which must be of the same type as the target's
49037efe6764568a3829fee26aba532283131d1a104Nate Begeman    // pointer type.
49137efe6764568a3829fee26aba532283131d1a104Nate Begeman    BRIND,
492c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng
493c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // BR_JT - Jumptable branch. The first operand is the chain, the second
494c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // is the jumptable index, the last one is the jumptable entry index.
495c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    BR_JT,
49647b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands
49747b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // BRCOND - Conditional branch.  The first operand is the chain, the
49847b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // second is the condition, the third is the block to branch to if the
49947b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // condition is true.  If the type of the condition is not i1, then the
50003228089d5235f8c90477f88809139464e9c6ea5Duncan Sands    // high bits must conform to getBooleanContents.
50163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BRCOND,
50263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
5037cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // BR_CC - Conditional branch.  The behavior is like that of SELECT_CC, in
5047cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // that the condition is represented as condition code, and two nodes to
5057cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // compare, rather than as a combined SetCC node.  The operands in order are
5067cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // chain, cc, lhs, rhs, block to branch to if condition is true.
5077cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    BR_CC,
5087cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman
50963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // RET - Return from function.  The first operand is the chain,
5108e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // and any subsequent operands are pairs of return value and return value
511c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen    // attributes (see CALL for description of attributes) for the function.
512c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen    // This operation can have variable number of operands.
51363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    RET,
51463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
5157572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // INLINEASM - Represents an inline asm block.  This node always has two
5167572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // return values: a chain and a flag result.  The inputs are as follows:
5177572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #0   : Input chain.
518056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    //   Operand #1   : a ExternalSymbolSDNode with a pointer to the asm string.
5197572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+2: A RegisterNode.
5207572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
5217572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #last: Optional, an incoming flag.
5227572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    INLINEASM,
5231ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey
5244406604047423576e36657c7ede266ca42e79642Dan Gohman    // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track
5254406604047423576e36657c7ede266ca42e79642Dan Gohman    // locations needed for debug and exception handling tables.  These nodes
5264406604047423576e36657c7ede266ca42e79642Dan Gohman    // take a chain as input and return a chain.
5274406604047423576e36657c7ede266ca42e79642Dan Gohman    DBG_LABEL,
5284406604047423576e36657c7ede266ca42e79642Dan Gohman    EH_LABEL,
529a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng
530a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track
531a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // local variable declarations for debugging information. First operand is
532a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // a chain, while the next two operands are first two arguments (address
533a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // and variable) of a llvm.dbg.declare instruction.
534a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    DECLARE,
535f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
5365a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKSAVE - STACKSAVE has one operand, an input chain.  It produces a
5375a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // value, the same type as the pointer type for the system, and an output
5385a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // chain.
5395a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKSAVE,
5405a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
5415a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKRESTORE has two operands, an input chain and a pointer to restore to
5425a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // it returns an output chain.
5435a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKRESTORE,
5445a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
54516cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
54616cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // a call sequence, and carry arbitrary information that target might want
54716cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // to know.  The first operand is a chain, the rest are specified by the
54816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // target and not touched by the DAG optimizers.
5490ea0356dff38dfd0420b8c0a2fdf2fae7898c024Dale Johannesen    // CALLSEQ_START..CALLSEQ_END pairs may not be nested.
55016cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_START,  // Beginning of a call sequence
55116cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_END,    // End of a call sequence
552acc398c195a697795bff3245943d104eb19192b9Nate Begeman
553acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAARG - VAARG has three operands: an input chain, a pointer, and a
554acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // SRCVALUE.  It returns a pair of values: the vaarg value and a new chain.
555acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAARG,
556acc398c195a697795bff3245943d104eb19192b9Nate Begeman
557acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
558acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
559acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // source.
560acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VACOPY,
561acc398c195a697795bff3245943d104eb19192b9Nate Begeman
562acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
563acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // pointer, and a SRCVALUE.
564acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAEND, VASTART,
56563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
56669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    // SRCVALUE - This is a node type that holds a Value* that is used to
56769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    // make reference to a value in the LLVM IR.
56821074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    SRCVALUE,
56921074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner
57036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // MEMOPERAND - This is a node that contains a MachineMemOperand which
57136b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // records information about a memory reference. This is used to make
57236b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // AliasAnalysis queries from the backend.
57369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    MEMOPERAND,
57469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
575e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman    // PCMARKER - This corresponds to the pcmarker intrinsic.
57695762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth    PCMARKER,
57763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
578aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
5798b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // The only operand is a chain and a value and a chain are produced.  The
5808b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // value is the contents of the architecture specific cycle counter like
5818b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // register (or other high accuracy low latency clock source)
582aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    READCYCLECOUNTER,
583aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth
584d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    // HANDLENODE node - Used as a handle for various purposes.
585d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    HANDLENODE,
5862d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
5877f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // DBG_STOPPOINT - This node is used to represent a source location for
5887f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // debug info.  It takes token chain as input, and carries a line number,
58983489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel    // column number, and a pointer to a CompileUnit object identifying
5907f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // the containing compilation unit.  It produces a token chain as output.
5917f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    DBG_STOPPOINT,
59247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner
593f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    // DEBUG_LOC - This node is used to represent source line information
594abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // embedded in the code.  It takes a token chain as input, then a line
59544c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey    // number, then a column then a file id (provided by MachineModuleInfo.) It
596abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // produces a token chain as output.
597f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    DEBUG_LOC,
59836397f50343639ce9a25996f2d790c656791ab92Duncan Sands
59936397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
60036397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // It takes as input a token chain, the pointer to the trampoline,
60136397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // the pointer to the nested function, the pointer to pass for the
60236397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // 'nest' parameter, a SRCVALUE for the trampoline and another for
60336397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // the nested function (allowing targets to access the original
604f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands    // Function*).  It produces the result of the intrinsic and a token
605f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands    // chain as output.
60636397f50343639ce9a25996f2d790c656791ab92Duncan Sands    TRAMPOLINE,
60736397f50343639ce9a25996f2d790c656791ab92Duncan Sands
60866fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov    // TRAP - Trapping instruction
60966fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov    TRAP,
61066fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov
61127b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are
61227b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // their first operand. The other operands are the address to prefetch,
61327b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // read / write specifier, and locality specifier.
61427b7db549e4c5bff4579d209304de5628513edebEvan Cheng    PREFETCH,
61527b7db549e4c5bff4579d209304de5628513edebEvan Cheng
61622c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load,
61722c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    //                       store-store, device)
618ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // This corresponds to the memory.barrier intrinsic.
61922c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // it takes an input chain, 4 operands to specify the type of barrier, an
62022c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // operand specifying if the barrier applies to device and uncached memory
62122c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // and produces an output chain.
62222c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    MEMBARRIER,
62322c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth
62428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang    // Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)
625ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // this corresponds to the atomic.lcs intrinsic.
626ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // cmp is compared to *ptr, and if equal, swap is stored in *ptr.
627ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // the return is always the original value in *ptr
6280b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_CMP_SWAP,
629ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
630ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt)
631ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // this corresponds to the atomic.swap intrinsic.
632ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // amt is stored to *ptr atomically.
633ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // the return is always the original value in *ptr
6340b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_SWAP,
635ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
636a82a91850779f7c3a173a5828333dfd5162f855dDan Gohman    // Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt)
637a82a91850779f7c3a173a5828333dfd5162f855dDan Gohman    // this corresponds to the atomic.load.[OpName] intrinsic.
63863307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    // op(*ptr, amt) is stored to *ptr atomically.
63963307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    // the return is always the original value in *ptr
6400b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_ADD,
6410b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_SUB,
6420b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_AND,
6430b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_OR,
6440b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_XOR,
6450b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_NAND,
6460b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_MIN,
6470b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_MAX,
6480b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_UMIN,
6490b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_UMAX,
65063307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang
65163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILTIN_OP_END - This must be the last enum value in this list.
652410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    BUILTIN_OP_END
65363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
65463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
655322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// Node predicates
656322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
657a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  /// isBuildVectorAllOnes - Return true if the specified node is a
658322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// BUILD_VECTOR where all of the elements are ~0 or undef.
659a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  bool isBuildVectorAllOnes(const SDNode *N);
6604a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng
6614a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// isBuildVectorAllZeros - Return true if the specified node is a
6624a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// BUILD_VECTOR where all of the elements are 0 or undef.
6634a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  bool isBuildVectorAllZeros(const SDNode *N);
664bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng
665efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// isScalarToVector - Return true if the specified node is a
666efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
667efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// element is not an undef.
668efec751a1b786724862ceff52748df94873a807eEvan Cheng  bool isScalarToVector(const SDNode *N);
669efec751a1b786724862ceff52748df94873a807eEvan Cheng
670bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng  /// isDebugLabel - Return true if the specified node represents a debug
6714406604047423576e36657c7ede266ca42e79642Dan Gohman  /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node).
672bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng  bool isDebugLabel(const SDNode *N);
673322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
67463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
675144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// MemIndexedMode enum - This enum defines the load / store indexed
676144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// addressing modes.
67724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
67824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// UNINDEXED    "Normal" load / store. The effective address is already
67924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computed and is available in the base pointer. The offset
68081c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              operand is always undefined. In addition to producing a
68181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              chain, an unindexed load produces one value (result of the
682276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ///              load); an unindexed store does not produce a value.
68324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
68435acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// PRE_INC      Similar to the unindexed mode where the effective address is
6858862ef148100070b7bf28beead3951464250c926Evan Cheng  /// PRE_DEC      the value of the base pointer add / subtract the offset.
6868862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              It considers the computation as being folded into the load /
68724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              store operation (i.e. the load / store does the address
68824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computation as well as performing the memory transaction).
68981c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              The base operand is always undefined. In addition to
69081c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              producing a chain, pre-indexed load produces two values
69181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              (result of the load and the result of the address
69281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              computation); a pre-indexed store produces one value (result
69381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              of the address computation).
69424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
69535acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// POST_INC     The effective address is the value of the base pointer. The
6968862ef148100070b7bf28beead3951464250c926Evan Cheng  /// POST_DEC     value of the offset operand is then added to / subtracted
6978862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              from the base after memory transaction. In addition to
6988862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              producing a chain, post-indexed load produces two values
6998862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              (the result of the load and the result of the base +/- offset
7008862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              computation); a post-indexed store produces one value (the
7018862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              the result of the base +/- offset computation).
70224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
703144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  enum MemIndexedMode {
70424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    UNINDEXED = 0,
70535acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_INC,
70635acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_DEC,
70735acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    POST_INC,
708144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    POST_DEC,
709144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    LAST_INDEXED_MODE
71024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  };
71124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
71224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  //===--------------------------------------------------------------------===//
713c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// LoadExtType enum - This enum defines the three variants of LOADEXT
714c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// (load with extension).
715c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
71624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// SEXTLOAD loads the integer operand and sign extends it to a larger
71724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
71824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// ZEXTLOAD loads the integer operand and zero extends it to a larger
71924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
72024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// EXTLOAD  is used for three things: floating point extending loads,
72124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer extending loads [the top bits are undefined], and vector
72224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          extending loads [load into low elt].
72324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
724c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  enum LoadExtType {
72524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    NON_EXTLOAD = 0,
726c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    EXTLOAD,
727c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    SEXTLOAD,
728c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    ZEXTLOAD,
7290329466b6b4927f4e6f5d144891fef06a027fec5Evan Cheng    LAST_LOADEXT_TYPE
730c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  };
731c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
732c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  //===--------------------------------------------------------------------===//
73363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::CondCode enum - These are ordered carefully to make the bitfields
73463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// below work out, when considering SETFALSE (something that never exists
73563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// dynamically) as 0.  "U" -> Unsigned (for integer operands) or Unordered
73663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
73763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to.  If the "N" column is 1, the result of the comparison is undefined if
73863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the input is a NAN.
73963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
74063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// All of these (except for the 'always folded ops') should be handled for
74163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// floating point.  For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
74263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
74363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
74463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// Note that these are laid out in a specific order to allow bit-twiddling
74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to transform conditions.
74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum CondCode {
74763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Opcode          N U L G E       Intuitive operation
74863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE,      //    0 0 0 0       Always false (always folded)
74963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOEQ,        //    0 0 0 1       True if ordered and equal
75063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGT,        //    0 0 1 0       True if ordered and greater than
75163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGE,        //    0 0 1 1       True if ordered and greater than or equal
75263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLT,        //    0 1 0 0       True if ordered and less than
75363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLE,        //    0 1 0 1       True if ordered and less than or equal
75463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETONE,        //    0 1 1 0       True if ordered and operands are unequal
75563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETO,          //    0 1 1 1       True if ordered (no nans)
75663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUO,         //    1 0 0 0       True if unordered: isnan(X) | isnan(Y)
75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUEQ,        //    1 0 0 1       True if unordered or equal
75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGT,        //    1 0 1 0       True if unordered or greater than
75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGE,        //    1 0 1 1       True if unordered, greater than, or equal
76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETULT,        //    1 1 0 0       True if unordered or less than
761ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETULE,        //    1 1 0 1       True if unordered, less than, or equal
76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUNE,        //    1 1 1 0       True if unordered or not equal
76363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE,       //    1 1 1 1       Always true (always folded)
76463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Don't care operations: undefined if the input is a nan.
76563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE2,     //  1 X 0 0 0       Always false (always folded)
76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETEQ,         //  1 X 0 0 1       True if equal
76763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGT,         //  1 X 0 1 0       True if greater than
76863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGE,         //  1 X 0 1 1       True if greater than or equal
76963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETLT,         //  1 X 1 0 0       True if less than
770ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETLE,         //  1 X 1 0 1       True if less than or equal
77163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETNE,         //  1 X 1 1 0       True if not equal
77263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE2,      //  1 X 1 1 1       Always true (always folded)
77363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
774410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    SETCC_INVALID       // Marker value.
77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
77763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isSignedIntSetCC - Return true if this is a setcc instruction that
77863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs a signed comparison when used with integer operands.
77963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isSignedIntSetCC(CondCode Code) {
78063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
78263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
78363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
78463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs an unsigned comparison when used with integer operands.
78563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isUnsignedIntSetCC(CondCode Code) {
78663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isTrueWhenEqual - Return true if the specified condition returns true if
79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the two operands to the condition are equal.  Note that if one of the two
79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operands is a NaN, this value is meaningless.
79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isTrueWhenEqual(CondCode Cond) {
79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond & 1) != 0;
79463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
79563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getUnorderedFlavor - This function returns 0 if the condition is always
79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// false if an operand is a NaN, 1 if the condition is always true if the
79863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operand is a NaN, and 2 if the condition is undefined if the operand is a
79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// NaN.
80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getUnorderedFlavor(CondCode Cond) {
80163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond >> 3) & 3;
80263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
80463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
80563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// 'op' is a valid SetCC operation.
80663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCInverse(CondCode Operation, bool isInteger);
80763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
80863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
80963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// when given the operation for (X op Y).
81063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCSwappedOperands(CondCode Operation);
81163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
81263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCOrOperation - Return the result of a logical OR between different
81363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// comparisons of identical values: ((X op1 Y) | (X op2 Y)).  This
81463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
81563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
81663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
81763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
81863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCAndOperation - Return the result of a logical AND between
81963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)).  This
82063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
82163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
82263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
82377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
82477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  //===--------------------------------------------------------------------===//
82577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  /// CvtCode enum - This enum defines the various converts CONVERT_RNDSAT
82677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  /// supports.
82777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  enum CvtCode {
82877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FF,     // Float from Float
82977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FS,     // Float from Signed
83077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FU,     // Float from Unsigned
83177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SF,     // Signed from Float
83277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_UF,     // Unsigned from Float
83377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SS,     // Signed from Signed
83477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SU,     // Signed from Unsigned
83577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_US,     // Unsigned from Signed
83677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_UU,     // Unsigned from Unsigned
83777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_INVALID // Marker - Invalid opcode
83877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  };
83963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}  // end llvm::ISD namespace
84063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
84163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
84263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
843475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple
84463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation.  Many nodes return multiple values,
84563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns
84663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number
84763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values).
84863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
84963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that
85063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node.  This pair
851475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// of information is represented with the SDValue value type.
85263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
853475871a144eb604ddaf37503397ba0941442e5fbDan Gohmanclass SDValue {
854ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDNode *Node;       // The node defining the value we are using.
85563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned ResNo;     // Which return value of the node we are using.
85699a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greifpublic:
857ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDValue() : Node(0), ResNo(0) {}
858ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {}
85963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
86099a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif  /// get the index which selects a specific result in the SDNode
86199a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif  unsigned getResNo() const { return ResNo; }
86299a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif
863ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// get the SDNode which holds the desired result
864ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDNode *getNode() const { return Node; }
865ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif
866ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// set the SDNode
867ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  void setNode(SDNode *N) { Node = N; }
868ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif
869475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator==(const SDValue &O) const {
870ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node == O.Node && ResNo == O.ResNo;
87163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
872475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator!=(const SDValue &O) const {
87363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return !operator==(O);
87463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
875475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator<(const SDValue &O) const {
876ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node < O.Node || (Node == O.Node && ResNo < O.ResNo);
87763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
87863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
879475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDValue getValue(unsigned R) const {
880ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return SDValue(Node, R);
88163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
88263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
883917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  // isOperandOf - Return true if this node is an operand of N.
884917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isOperandOf(SDNode *N) const;
885bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng
88663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the ValueType of the referenced return value.
88763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
88883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  inline MVT getValueType() const;
889ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
89083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  /// getValueSizeInBits - Returns the size of the value in bits.
8914fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  ///
8924fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  unsigned getValueSizeInBits() const {
89383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands    return getValueType().getSizeInBits();
8944fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  }
8954fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman
89663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  // Forwarding methods - These forward to the corresponding methods in SDNode.
89763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getOpcode() const;
89863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getNumOperands() const;
899475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  inline const SDValue &getOperand(unsigned i) const;
900c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline uint64_t getConstantOperandVal(unsigned i) const;
9010f66a9172175aa7c3055333358170581c999219bNate Begeman  inline bool isTargetOpcode() const;
902e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  inline bool isMachineOpcode() const;
903e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  inline unsigned getMachineOpcode() const;
904a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner
905572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner
906572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// reachesChainWithoutSideEffects - Return true if this operand (which must
907572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// be a chain) reaches the specified operand without crossing any
908572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// side-effecting instructions.  In practice, this looks through token
909572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// factors and non-volatile loads.  In order to remain efficient, this only
910572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// looks a couple of nodes in, it does not do an exhaustive search.
911475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool reachesChainWithoutSideEffects(SDValue Dest,
912dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein                                      unsigned Depth = 2) const;
913572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner
9147a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  /// use_empty - Return true if there are no nodes using value ResNo
915ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// of Node.
9167a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
917e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman  inline bool use_empty() const;
9187a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
919231fe7054160d2953e0cc6635f9a171a4b311af2Gabor Greif  /// hasOneUse - Return true if there is exactly one node using value
920ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// ResNo of Node.
9217a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
9227a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  inline bool hasOneUse() const;
92363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
92463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
92563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
926475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct DenseMapInfo<SDValue> {
927475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static inline SDValue getEmptyKey() {
928475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return SDValue((SDNode*)-1, -1U);
929dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
930475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static inline SDValue getTombstoneKey() {
931475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return SDValue((SDNode*)-1, 0);
932dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
933475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static unsigned getHashValue(const SDValue &Val) {
934ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
935ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif            (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
936c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  }
937475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
93876c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner    return LHS == RHS;
93976c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner  }
940c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  static bool isPod() { return true; }
941c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng};
942c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng
94363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on
944475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s.
945475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<SDValue> {
946dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  typedef SDNode* SimpleType;
947475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static SimpleType getSimplifiedValue(const SDValue &Val) {
948ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return static_cast<SimpleType>(Val.getNode());
949dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
950dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
951475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<const SDValue> {
952dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  typedef SDNode* SimpleType;
953475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static SimpleType getSimplifiedValue(const SDValue &Val) {
954ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return static_cast<SimpleType>(Val.getNode());
955dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
956dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
957dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
958e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// SDUse - Represents a use of a SDNode. This class holds an SDValue,
959e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// which records the SDNode being used and the result number, a
960e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// pointer to the SDNode using the value, and Next and Prev pointers,
961e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// which link together all the uses of an SDNode.
962e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman///
9639cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDUse {
964e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// Val - The value being used.
965e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDValue Val;
966e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// User - The user of this value.
967e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDNode *User;
968e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// Prev, Next - Pointers to the uses list of the SDNode referred by
969dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// this operand.
9709cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse **Prev, *Next;
971dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
972e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDUse(const SDUse &U);          // Do not implement
973e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void operator=(const SDUse &U); // Do not implement
974dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
975e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanpublic:
976e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDUse() : Val(), User(NULL), Prev(NULL), Next(NULL) {}
977dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
978e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// Normally SDUse will just implicitly convert to an SDValue that it holds.
979e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  operator const SDValue&() const { return Val; }
980dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
981e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// If implicit conversion to SDValue doesn't work, the get() method returns
982e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// the SDValue.
983e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  const SDValue &get() const { return Val; }
984e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
985e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getUser - This returns the SDNode that contains this Use.
98602819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein  SDNode *getUser() { return User; }
9879cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
988e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getNext - Get the next SDUse in the use list.
989e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDUse *getNext() const { return Next; }
9909cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
991e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getNode - Convenience function for get().getNode().
992e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDNode *getNode() const { return Val.getNode(); }
993e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getResNo - Convenience function for get().getResNo().
994e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  unsigned getResNo() const { return Val.getResNo(); }
995e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getValueType - Convenience function for get().getValueType().
996e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  MVT getValueType() const { return Val.getValueType(); }
9979cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
998e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// operator== - Convenience function for get().operator==
999e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  bool operator==(const SDValue &V) const {
1000e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return Val == V;
10019cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
1002e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1003e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// operator!= - Convenience function for get().operator!=
1004e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  bool operator!=(const SDValue &V) const {
1005e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return Val != V;
10069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10079cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1008e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// operator< - Convenience function for get().operator<
1009e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  bool operator<(const SDValue &V) const {
1010e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return Val < V;
10119cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10129cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1013e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanprivate:
1014e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  friend class SelectionDAG;
1015e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  friend class SDNode;
1016e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1017e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void setUser(SDNode *p) { User = p; }
1018e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1019e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// set - Remove this use from its existing use list, assign it the
1020e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// given value, and add it to the new value's node's use list.
1021e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  inline void set(const SDValue &V);
1022e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// setInitial - like set, but only supports initializing a newly-allocated
1023e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// SDUse with a non-null value.
1024e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  inline void setInitial(const SDValue &V);
1025e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// setNode - like set, but only sets the Node portion of the value,
1026e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// leaving the ResNo portion unmodified.
1027e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  inline void setNode(SDNode *N);
1028e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
10299cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  void addToList(SDUse **List) {
1030dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    Next = *List;
1031dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    if (Next) Next->Prev = &Next;
1032dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    Prev = List;
1033dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    *List = this;
1034dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1035dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1036dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  void removeFromList() {
1037dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    *Prev = Next;
1038dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    if (Next) Next->Prev = Prev;
1039dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1040dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
1041dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1042dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein/// simplify_type specializations - Allow casting operators to work directly on
1043475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s.
10449cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<SDUse> {
104563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
10469cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  static SimpleType getSimplifiedValue(const SDUse &Val) {
1047e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return static_cast<SimpleType>(Val.getNode());
104863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
104963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
10509cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<const SDUse> {
105163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
10529cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  static SimpleType getSimplifiedValue(const SDUse &Val) {
1053e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return static_cast<SimpleType>(Val.getNode());
105463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
105563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
105663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
105763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
105863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG.
105963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
1060fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass SDNode : public FoldingSetNode, public ilist_node<SDNode> {
1061dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprivate:
10620442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  /// NodeType - The operation that this node performs.
10630442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
1064e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  short NodeType;
106563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
106663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// OperandsNeedDelete - This is true if OperandList was new[]'d.  If true,
106763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// then they will be delete[]'d when the node is destroyed.
1068ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  unsigned short OperandsNeedDelete : 1;
10690442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
1070ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprotected:
1071ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// SubclassData - This member is defined by this class, but is not used for
1072ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// anything.  Subclasses can use it to hold whatever state they find useful.
1073ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// This field is initialized to zero by the ctor.
1074ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  unsigned short SubclassData : 15;
1075ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
1076ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprivate:
1077b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// NodeId - Unique id per SDNode in the DAG.
1078b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int NodeId;
10790442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
1080f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// OperandList - The values that are used by this operation.
10810442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
10829cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse *OperandList;
1083f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner
1084f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// ValueList - The types of the values this node defines.  SDNode's may
1085f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// define multiple values simultaneously.
108683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  const MVT *ValueList;
108763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1088f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// NumOperands/NumValues - The number of entries in the Operand/Value list.
1089f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned short NumOperands, NumValues;
1090b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1091e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// UseList - List of uses for this SDNode.
1092e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDUse *UseList;
1093dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1094e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getValueTypeList - Return a pointer to the specified value type.
1095e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  static const MVT *getValueTypeList(MVT VT);
1096e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1097e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  friend class SelectionDAG;
1098e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  friend struct ilist_traits<SDNode>;
1099dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
110063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
110163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
110263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //  Accessors
110363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //
1104e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1105e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// getOpcode - Return the SelectionDAG opcode value for this node. For
1106e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// pre-isel nodes (those for which isMachineOpcode returns false), these
1107e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// are the opcode values in the ISD and <target>ISD namespaces. For
1108e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// post-isel opcodes, see getMachineOpcode.
1109e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  unsigned getOpcode()  const { return (unsigned short)NodeType; }
1110e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1111e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// isTargetOpcode - Test if this node has a target-specific opcode (in the
1112e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// <target>ISD namespace).
11130f66a9172175aa7c3055333358170581c999219bNate Begeman  bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
1114e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1115e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// isMachineOpcode - Test if this node has a post-isel opcode, directly
1116e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// corresponding to a MachineInstr opcode.
1117e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  bool isMachineOpcode() const { return NodeType < 0; }
1118e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1119e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// getMachineOpcode - This may only be called if isMachineOpcode returns
1120e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// true. It returns the MachineInstr opcode value that the node's opcode
1121e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// corresponds to.
1122e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  unsigned getMachineOpcode() const {
1123ec89a364b86ccd943fc6cf3ad8f84825ba1550fdDan Gohman    assert(isMachineOpcode() && "Not a MachineInstr opcode!");
1124e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman    return ~NodeType;
11250f66a9172175aa7c3055333358170581c999219bNate Begeman  }
112663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
11276da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// use_empty - Return true if there are no uses of this node.
11287a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
1129e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  bool use_empty() const { return UseList == NULL; }
11307a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
11316da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// hasOneUse - Return true if there is exactly one use of this node.
11327a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
1133b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman  bool hasOneUse() const {
1134b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman    return !use_empty() && next(use_begin()) == use_end();
1135b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman  }
113663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
11376da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// use_size - Return the number of uses of this node. This method takes
11387a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  /// time proportional to the number of uses.
11397a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
11407a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  size_t use_size() const { return std::distance(use_begin(), use_end()); }
11417a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
1142b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// getNodeId - Return the unique node id.
1143b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  ///
1144b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int getNodeId() const { return NodeId; }
11450442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
11462e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng  /// setNodeId - Set unique node id.
11472e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng  void setNodeId(int Id) { NodeId = Id; }
11482e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng
11499cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  /// use_iterator - This class provides iterator support for SDUse
1150dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// operands that use a specific SDNode.
1151dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  class use_iterator
11529cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : public forward_iterator<SDUse, ptrdiff_t> {
11539cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    SDUse *Op;
11549cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    explicit use_iterator(SDUse *op) : Op(op) {
1155dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1156dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    friend class SDNode;
1157dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  public:
11589cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    typedef forward_iterator<SDUse, ptrdiff_t>::reference reference;
11599cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer;
1160dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1161dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator(const use_iterator &I) : Op(I.Op) {}
1162dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator() : Op(0) {}
1163dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1164dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool operator==(const use_iterator &x) const {
1165dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return Op == x.Op;
1166dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1167dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool operator!=(const use_iterator &x) const {
1168dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return !operator==(x);
1169dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1170dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1171dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    /// atEnd - return true if this iterator is at the end of uses list.
1172dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool atEnd() const { return Op == 0; }
1173dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1174dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    // Iterator traversal: forward iteration only.
1175dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator &operator++() {          // Preincrement
1176dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot increment end iterator!");
1177dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      Op = Op->getNext();
1178dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return *this;
1179dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1180dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1181dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator operator++(int) {        // Postincrement
1182dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      use_iterator tmp = *this; ++*this; return tmp;
1183dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1184dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
11858968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    /// Retrieve a pointer to the current user node.
11868968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDNode *operator*() const {
1187dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot dereference end iterator!");
11888968450305c28444edc3c272d8752a8db0c2f34aDan Gohman      return Op->getUser();
1189dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1190dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
11918968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDNode *operator->() const { return operator*(); }
11928968450305c28444edc3c272d8752a8db0c2f34aDan Gohman
11938968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDUse &getUse() const { return *Op; }
1194dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1195174f938bd042a19d1a840eef6ed162fc938e2fd9Duncan Sands    /// getOperandNo - Retrieve the operand # of this use in its user.
11968968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    ///
11978968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    unsigned getOperandNo() const {
1198dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot dereference end iterator!");
11998968450305c28444edc3c272d8752a8db0c2f34aDan Gohman      return (unsigned)(Op - Op->getUser()->OperandList);
1200dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1201dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  };
1202dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1203dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// use_begin/use_end - Provide iteration support to walk over all uses
1204dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// of an SDNode.
1205dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1206dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  use_iterator use_begin() const {
1207e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return use_iterator(UseList);
1208dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1209dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1210dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  static use_iterator use_end() { return use_iterator(0); }
1211dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
12127ece380440238ad0630a225b85a09a2dbed1165aChris Lattner
1213b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
1214b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// indicated value.  This method ignores uses of other values defined by this
1215b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// operation.
12164ee621125876cc954cba5280dd9395552755a871Evan Cheng  bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
12174ee621125876cc954cba5280dd9395552755a871Evan Cheng
121833d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  /// hasAnyUseOfValue - Return true if there are any use of the indicated
121933d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  /// value. This method ignores uses of other values defined by this operation.
122033d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  bool hasAnyUseOfValue(unsigned Value) const;
122133d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng
12222a6299543fa22f389158409e897fe7099fda3812Dan Gohman  /// isOnlyUserOf - Return true if this node is the only use of N.
1223e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
12242a6299543fa22f389158409e897fe7099fda3812Dan Gohman  bool isOnlyUserOf(SDNode *N) const;
1225b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner
1226917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// isOperandOf - Return true if this node is an operand of N.
1227e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
1228917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isOperandOf(SDNode *N) const;
122980d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng
1230917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// isPredecessorOf - Return true if this node is a predecessor of N. This
1231917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// node is either an operand of N or it can be reached by recursively
1232917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// traversing up the operands.
1233e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// NOTE: this is an expensive method. Use it carefully.
1234917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isPredecessorOf(SDNode *N) const;
12357ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng
123663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumOperands - Return the number of values used by this operation.
123763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
1238f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumOperands() const { return NumOperands; }
123963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1240c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// getConstantOperandVal - Helper method returns the integer value of a
1241c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// ConstantSDNode operand.
1242c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  uint64_t getConstantOperandVal(unsigned Num) const;
1243c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1244475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOperand(unsigned Num) const {
1245f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(Num < NumOperands && "Invalid child # of SDNode!");
1246e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return OperandList[Num];
124763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
1248c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
12499cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  typedef SDUse* op_iterator;
1250f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_begin() const { return OperandList; }
1251f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_end() const { return OperandList+NumOperands; }
125250f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner
12530b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  SDVTList getVTList() const {
12540b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    SDVTList X = { ValueList, NumValues };
12550b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    return X;
12560b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  };
1257d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman
1258d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  /// getFlaggedNode - If this node has a flag operand, return the node
1259d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  /// to which the flag operand points. Otherwise return NULL.
1260d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  SDNode *getFlaggedNode() const {
1261d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman    if (getNumOperands() != 0 &&
1262d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman        getOperand(getNumOperands()-1).getValueType() == MVT::Flag)
1263d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman      return getOperand(getNumOperands()-1).getNode();
1264d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman    return 0;
1265d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  }
1266fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman
1267fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman  // If this is a pseudo op, like copyfromreg, look to see if there is a
1268fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman  // real target node flagged to it.  If so, return the target node.
1269fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman  const SDNode *getFlaggedMachineNode() const {
1270fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    const SDNode *FoundNode = this;
1271fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman
1272fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    // Climb up flag edges until a machine-opcode node is found, or the
1273fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    // end of the chain is reached.
1274fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    while (!FoundNode->isMachineOpcode()) {
1275fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman      const SDNode *N = FoundNode->getFlaggedNode();
1276fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman      if (!N) break;
1277fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman      FoundNode = N;
1278fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    }
1279fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman
1280fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    return FoundNode;
1281fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman  }
1282fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman
128363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumValues - Return the number of values defined/returned by this
128463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operator.
128563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
1286f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumValues() const { return NumValues; }
128763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
128863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the type of a specified result.
128963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
129083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT getValueType(unsigned ResNo) const {
1291f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(ResNo < NumValues && "Illegal result number!");
1292f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    return ValueList[ResNo];
129363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
12949eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen
12954fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
12964fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  ///
12974fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  unsigned getValueSizeInBits(unsigned ResNo) const {
129883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands    return getValueType(ResNo).getSizeInBits();
12994fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  }
13004fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman
130183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  typedef const MVT* value_iterator;
1302f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_begin() const { return ValueList; }
1303f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_end() const { return ValueList+NumValues; }
130463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
13056e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  /// getOperationName - Return the opcode of this operation for printing.
13066e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  ///
1307ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer  std::string getOperationName(const SelectionDAG *G = 0) const;
1308144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  static const char* getIndexedModeName(ISD::MemIndexedMode AM);
1309944fac71e082cc2664cc71b4d3f6c72bab7143fbChris Lattner  void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
131063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  void dump() const;
1311efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner  void dump(const SelectionDAG *G) const;
131263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
131363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *) { return true; }
131463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1315583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  /// Profile - Gather unique data for the node.
1316583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  ///
1317b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  void Profile(FoldingSetNodeID &ID) const;
1318583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey
1319e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// addUse - This method should only be used by the SDUse class.
1320109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  ///
1321e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void addUse(SDUse &U) { U.addToList(&UseList); }
1322e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1323e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanprotected:
132483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  static SDVTList getSDVTList(MVT VT) {
132563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    SDVTList Ret = { getValueTypeList(VT), 1 };
132663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    return Ret;
13272d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
132863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
1329475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
1330ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
1331e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      NodeId(-1),
1332e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      OperandList(NumOps ? new SDUse[NumOps] : 0),
1333e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      ValueList(VTs.VTs),
1334e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      NumOperands(NumOps), NumValues(VTs.NumVTs),
1335e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      UseList(NULL) {
13369cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    for (unsigned i = 0; i != NumOps; ++i) {
13379cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein      OperandList[i].setUser(this);
1338e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      OperandList[i].setInitial(Ops[i]);
13399cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    }
1340f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  }
1341dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1342ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// This constructor adds no operands itself; operands can be
1343ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// set later with InitOperands.
1344dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  SDNode(unsigned Opc, SDVTList VTs)
1345ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
1346e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      NodeId(-1), OperandList(0), ValueList(VTs.VTs),
1347e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      NumOperands(0), NumValues(VTs.NumVTs),
1348e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      UseList(NULL) {}
1349bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
1350e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with 1 operand.
1351e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue &Op0) {
1352e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setUser(this);
1353e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setInitial(Op0);
1354e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = 1;
1355bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    OperandList = Ops;
1356e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  }
1357e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1358e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with 2 operands.
1359e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) {
1360e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setUser(this);
1361e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setInitial(Op0);
1362e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setUser(this);
1363e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setInitial(Op1);
1364e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = 2;
1365e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    OperandList = Ops;
1366e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  }
1367e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1368e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with 3 operands.
1369e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
1370e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman                    const SDValue &Op2) {
1371e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setUser(this);
1372e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setInitial(Op0);
1373e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setUser(this);
1374e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setInitial(Op1);
1375e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[2].setUser(this);
1376e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[2].setInitial(Op2);
1377e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = 3;
1378e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    OperandList = Ops;
1379e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  }
1380e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1381e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with 4 operands.
1382e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
1383e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman                    const SDValue &Op2, const SDValue &Op3) {
1384e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setUser(this);
1385e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setInitial(Op0);
1386e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setUser(this);
1387e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setInitial(Op1);
1388e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[2].setUser(this);
1389e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[2].setInitial(Op2);
1390e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[3].setUser(this);
1391e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[3].setInitial(Op3);
1392e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = 4;
1393e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    OperandList = Ops;
1394e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  }
1395e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1396e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with N operands.
1397e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) {
1398e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    for (unsigned i = 0; i != N; ++i) {
1399e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      Ops[i].setUser(this);
1400e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      Ops[i].setInitial(Vals[i]);
1401dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1402e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = N;
1403e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    OperandList = Ops;
1404bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
14050fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman
14060fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman  /// DropOperands - Release the operands and set this node to have
1407e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// zero operands.
14080fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman  void DropOperands();
140963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
141063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
141163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1412475871a144eb604ddaf37503397ba0941442e5fbDan Gohman// Define inline functions from the SDValue class.
141363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1414475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getOpcode() const {
1415ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getOpcode();
141663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1417475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline MVT SDValue::getValueType() const {
1418ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getValueType(ResNo);
141963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1420475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getNumOperands() const {
1421ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getNumOperands();
142263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1423475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline const SDValue &SDValue::getOperand(unsigned i) const {
1424ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getOperand(i);
142563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1426475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
1427ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getConstantOperandVal(i);
1428c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
1429475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isTargetOpcode() const {
1430ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->isTargetOpcode();
14310f66a9172175aa7c3055333358170581c999219bNate Begeman}
1432475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isMachineOpcode() const {
1433ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->isMachineOpcode();
1434e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman}
1435475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getMachineOpcode() const {
1436ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getMachineOpcode();
14370f66a9172175aa7c3055333358170581c999219bNate Begeman}
1438475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::use_empty() const {
1439ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return !Node->hasAnyUseOfValue(ResNo);
1440e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman}
1441475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::hasOneUse() const {
1442ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->hasNUsesOfValue(1, ResNo);
14437a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman}
144463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1445e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman// Define inline functions from the SDUse class.
1446e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1447e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::set(const SDValue &V) {
1448e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  if (Val.getNode()) removeFromList();
1449e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  Val = V;
1450e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  if (V.getNode()) V.getNode()->addUse(*this);
1451e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman}
1452e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1453e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::setInitial(const SDValue &V) {
1454e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  Val = V;
1455e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  V.getNode()->addUse(*this);
1456e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman}
1457e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1458e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::setNode(SDNode *N) {
1459e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  if (Val.getNode()) removeFromList();
1460e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  Val.setNode(N);
1461e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  if (N) N->addUse(*this);
1462e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman}
1463e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
14643f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes.  This is solely
14653f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
14663f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode {
14679cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Op;
14683f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1469475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X)
14709cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : SDNode(Opc, VTs) {
1471e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(&Op, X);
14723f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
14733f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
14743f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
14753f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes.  This is solely
14763f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
14773f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode {
14789cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[2];
14793f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1480475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y)
14813f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs) {
1482e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, X, Y);
14833f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
14843f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
14853f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
14863f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely
14873f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
14883f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode {
14899cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[3];
14903f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1491475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y,
1492475871a144eb604ddaf37503397ba0941442e5fbDan Gohman                SDValue Z)
14933f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs) {
1494e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, X, Y, Z);
14953f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
14963f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
14973f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
14983f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
1499d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that
1500d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its
1501d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand.  This node should be directly created by end-users and not added to
1502d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list.
1503d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode {
15049cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Op;
1505d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic:
1506ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling  // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is
1507ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling  // fixed.
150869cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#ifdef __GNUC__
1509475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  explicit __attribute__((__noinline__)) HandleSDNode(SDValue X)
151069cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#else
1511475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  explicit HandleSDNode(SDValue X)
151269cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#endif
15139cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) {
1514e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(&Op, X);
1515bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
151648b85926524f9d29ae600123c90194cd73fd629eChris Lattner  ~HandleSDNode();
1517e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  const SDValue &getValue() const { return Op; }
1518d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner};
1519d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner
152028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang/// Abstact virtual class for operations for memory operations
152128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass MemSDNode : public SDNode {
152228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangprivate:
15231ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  // MemoryVT - VT of in-memory value.
15241ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MVT MemoryVT;
15251ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
152628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  //! SrcValue - Memory location for alias analysis.
152728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  const Value *SrcValue;
152828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1529492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  //! SVOffset - Memory location offset. Note that base is defined in MemSDNode
1530492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  int SVOffset;
1531492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman
1532492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  /// Flags - the low bit indicates whether this is a volatile reference;
1533492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  /// the remainder is a log2 encoding of the alignment in bytes.
1534492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  unsigned Flags;
153528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
153628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangpublic:
15371ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT,
1538492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman            const Value *srcValue, int SVOff,
1539492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman            unsigned alignment, bool isvolatile);
154028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1541c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  MemSDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps,
1542c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang            MVT MemoryVT, const Value *srcValue, int SVOff,
1543c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang            unsigned alignment, bool isvolatile);
1544c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
154528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// Returns alignment and volatility of the memory access
1546492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  unsigned getAlignment() const { return (1u << (Flags >> 1)) >> 1; }
1547492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  bool isVolatile() const { return Flags & 1; }
154828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
154928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// Returns the SrcValue and offset that describes the location of the access
155028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  const Value *getSrcValue() const { return SrcValue; }
1551492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  int getSrcValueOffset() const { return SVOffset; }
155228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
15531ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  /// getMemoryVT - Return the type of the in-memory value.
15541ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MVT getMemoryVT() const { return MemoryVT; }
15551ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
155628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// getMemOperand - Return a MachineMemOperand object describing the memory
155728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// reference performed by operation.
15581ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MachineMemOperand getMemOperand() const;
15591ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
1560475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getChain() const { return getOperand(0); }
1561475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const {
15621ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman    return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
15631ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  }
156428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1565b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  /// getRawFlags - Represent the flags as a bunch of bits.
1566b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  ///
1567b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  unsigned getRawFlags() const { return Flags; }
1568b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman
156928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Methods to support isa and dyn_cast
157028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const MemSDNode *) { return true; }
157128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const SDNode *N) {
1572c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // For some targets, we lower some target intrinsics to a MemIntrinsicNode
1573c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // with either an intrinsic or a target opcode.
1574e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    return N->getOpcode() == ISD::LOAD                ||
1575e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::STORE               ||
15760b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_CMP_SWAP     ||
15770b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_SWAP         ||
15780b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_ADD     ||
15790b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_SUB     ||
15800b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_AND     ||
15810b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_OR      ||
15820b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_XOR     ||
15830b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_NAND    ||
15840b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_MIN     ||
15850b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_MAX     ||
15860b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN    ||
15870b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX    ||
1588c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_W_CHAIN   ||
1589c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_VOID      ||
1590c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->isTargetOpcode();
159128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  }
159228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang};
159328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1594c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// AtomicSDNode - A SDNode reprenting atomic operations.
1595c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang///
159628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass AtomicSDNode : public MemSDNode {
15979cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[4];
159828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1599c53361294957b63a9c1e405256c6f0a81db1685cDan Gohmanpublic:
160028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Opc:   opcode for atomic
160128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // VTL:    value type list
160228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Chain:  memory chain for operaand
1603475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  // Ptr:    address to update as a SDValue
160428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Cmp:    compare value
160528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Swp:    swap value
160628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // SrcVal: address to update as a Value (used for MemOperand)
160728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Align:  alignment of memory
16080b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman  AtomicSDNode(unsigned Opc, SDVTList VTL, MVT MemVT,
16090b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman               SDValue Chain, SDValue Ptr,
1610475871a144eb604ddaf37503397ba0941442e5fbDan Gohman               SDValue Cmp, SDValue Swp, const Value* SrcVal,
161128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang               unsigned Align=0)
16120b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    : MemSDNode(Opc, VTL, MemVT, SrcVal, /*SVOffset=*/0,
1613492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman                Align, /*isVolatile=*/true) {
1614e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, Chain, Ptr, Cmp, Swp);
1615ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth  }
16160b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman  AtomicSDNode(unsigned Opc, SDVTList VTL, MVT MemVT,
16170b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman               SDValue Chain, SDValue Ptr,
1618475871a144eb604ddaf37503397ba0941442e5fbDan Gohman               SDValue Val, const Value* SrcVal, unsigned Align=0)
16190b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    : MemSDNode(Opc, VTL, MemVT, SrcVal, /*SVOffset=*/0,
1620492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman                Align, /*isVolatile=*/true) {
1621e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, Chain, Ptr, Val);
1622ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth  }
162328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1624475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(1); }
1625475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getVal() const { return getOperand(2); }
162628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1627e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen  bool isCompareAndSwap() const {
1628e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    unsigned Op = getOpcode();
16290b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    return Op == ISD::ATOMIC_CMP_SWAP;
1630e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen  }
163128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
163228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Methods to support isa and dyn_cast
163328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const AtomicSDNode *) { return true; }
163428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const SDNode *N) {
16350b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    return N->getOpcode() == ISD::ATOMIC_CMP_SWAP     ||
16360b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_SWAP         ||
16370b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_ADD     ||
16380b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_SUB     ||
16390b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_AND     ||
16400b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_OR      ||
16410b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_XOR     ||
16420b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_NAND    ||
16430b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_MIN     ||
16440b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_MAX     ||
16450b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN    ||
16460b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX;
164728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  }
1648ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth};
1649ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
1650c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// MemIntrinsicSDNode - This SDNode is used for target intrinsic that touches
1651c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// memory and need an associated memory operand.
1652c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang///
1653c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wangclass MemIntrinsicSDNode : public MemSDNode {
1654c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool ReadMem;  // Intrinsic reads memory
1655c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool WriteMem; // Intrinsic writes memory
16563dbc4e350216e197e3014452400f43899f7ad620Dan Gohmanpublic:
1657c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  MemIntrinsicSDNode(unsigned Opc, SDVTList VTs,
1658c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     const SDValue *Ops, unsigned NumOps,
1659c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     MVT MemoryVT, const Value *srcValue, int SVO,
1660c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     unsigned Align, bool Vol, bool ReadMem, bool WriteMem)
1661c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    : MemSDNode(Opc, VTs, Ops, NumOps, MemoryVT, srcValue, SVO, Align, Vol),
1662c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang      ReadMem(ReadMem), WriteMem(WriteMem) {
1663c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  }
1664c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
1665c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool readMem() const { return ReadMem; }
1666c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool writeMem() const { return WriteMem; }
1667c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
1668c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  // Methods to support isa and dyn_cast
1669c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  static bool classof(const MemIntrinsicSDNode *) { return true; }
1670c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  static bool classof(const SDNode *N) {
1671c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // We lower some target intrinsics to their target opcode
1672c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // early a node with a target opcode can be of this class
1673c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    return N->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1674c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_VOID ||
1675c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->isTargetOpcode();
1676c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  }
1677c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang};
1678c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
167963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode {
16804fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantInt *Value;
168163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
168263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
16834fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT)
1684bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1685bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      Value(val) {
168663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
168763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
168863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
16894fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantInt *getConstantIntValue() const { return Value; }
16904fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const APInt &getAPIntValue() const { return Value->getValue(); }
16914fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  uint64_t getZExtValue() const { return Value->getZExtValue(); }
16927810bfed5570c192e0714a8fd0e5130a0c38dd2eDan Gohman  int64_t getSExtValue() const { return Value->getSExtValue(); }
169363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
16944fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  bool isNullValue() const { return Value->isNullValue(); }
16954fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  bool isAllOnesValue() const { return Value->isAllOnesValue(); }
169663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
169763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantSDNode *) { return true; }
169863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1699056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    return N->getOpcode() == ISD::Constant ||
1700056f9f61d071c6c583951678f2bf543a1316efccChris Lattner           N->getOpcode() == ISD::TargetConstant;
170163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
170263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
170363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
170463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode {
17054fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantFP *Value;
170663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
170763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
17084fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT)
170987503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
171087503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen             getSDVTList(VT)), Value(val) {
171163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
171263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
171363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
17144fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const APFloat& getValueAPF() const { return Value->getValueAPF(); }
17154fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantFP *getConstantFPValue() const { return Value; }
171663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
171763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isExactlyValue - We don't rely on operator== working on double values, as
171863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
171963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// As such, this method can be used to do an exact bit-for-bit comparison of
172063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// two floating point values.
1721c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen
1722c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// We leave the version with the double argument here because it's just so
1723c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// convenient to write "2.0" and the like.  Without this function we'd
1724c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// have to duplicate its logic everywhere it's called.
17259dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen  bool isExactlyValue(double V) const {
172623a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen    bool ignored;
17279dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen    // convert is not supported on this type
17284fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman    if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble)
17299dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen      return false;
173084cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner    APFloat Tmp(V);
17314fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman    Tmp.convert(Value->getValueAPF().getSemantics(),
173223a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen                APFloat::rmNearestTiesToEven, &ignored);
173384cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner    return isExactlyValue(Tmp);
173487503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen  }
1735e6c1742914149d44360fbf05a653041a672282afDale Johannesen  bool isExactlyValue(const APFloat& V) const;
173663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
173783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  bool isValueValidForType(MVT VT, const APFloat& Val);
1738f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen
173963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantFPSDNode *) { return true; }
174063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1741ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    return N->getOpcode() == ISD::ConstantFP ||
1742ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner           N->getOpcode() == ISD::TargetConstantFP;
174363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
174463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
174563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
174663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode {
174763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *TheGlobal;
17486520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  int64_t Offset;
174963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
175063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
17516520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT,
17526520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman                      int64_t o = 0);
175363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
175463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
175563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *getGlobal() const { return TheGlobal; }
17566520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  int64_t getOffset() const { return Offset; }
175763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
175863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const GlobalAddressSDNode *) { return true; }
175963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1760f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    return N->getOpcode() == ISD::GlobalAddress ||
1761b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::TargetGlobalAddress ||
1762b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::GlobalTLSAddress ||
1763b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::TargetGlobalTLSAddress;
176463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
176563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
176663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
176763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode {
176863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int FI;
176963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
177063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
177183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  FrameIndexSDNode(int fi, MVT VT, bool isTarg)
1772bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1773bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      FI(fi) {
177463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
177563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
177663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
177763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int getIndex() const { return FI; }
177863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
177963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const FrameIndexSDNode *) { return true; }
178063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1781afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    return N->getOpcode() == ISD::FrameIndex ||
1782afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner           N->getOpcode() == ISD::TargetFrameIndex;
178363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
178463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
178563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
178637efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode {
178737efe6764568a3829fee26aba532283131d1a104Nate Begeman  int JTI;
178837efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected:
178937efe6764568a3829fee26aba532283131d1a104Nate Begeman  friend class SelectionDAG;
179083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  JumpTableSDNode(int jti, MVT VT, bool isTarg)
1791bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1792bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      JTI(jti) {
179363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
179437efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic:
179537efe6764568a3829fee26aba532283131d1a104Nate Begeman
179659a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner  int getIndex() const { return JTI; }
179737efe6764568a3829fee26aba532283131d1a104Nate Begeman
179837efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const JumpTableSDNode *) { return true; }
179937efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const SDNode *N) {
180037efe6764568a3829fee26aba532283131d1a104Nate Begeman    return N->getOpcode() == ISD::JumpTable ||
180137efe6764568a3829fee26aba532283131d1a104Nate Begeman           N->getOpcode() == ISD::TargetJumpTable;
180237efe6764568a3829fee26aba532283131d1a104Nate Begeman  }
180337efe6764568a3829fee26aba532283131d1a104Nate Begeman};
180437efe6764568a3829fee26aba532283131d1a104Nate Begeman
180563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode {
1806d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  union {
1807d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Constant *ConstVal;
1808d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    MachineConstantPoolValue *MachineCPVal;
1809d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  } Val;
1810baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1811b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned Alignment;
181263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
181363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
181483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0)
1815ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1816bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(0) {
1817d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1818d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1819d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
182083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align)
1821ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1822bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(Align) {
1823d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1824d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1825d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1826d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
182783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands                     MVT VT, int o=0)
1828ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1829bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(0) {
1830d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1831d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1832d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1833d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1834d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
183583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands                     MVT VT, int o, unsigned Align)
1836ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1837bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(Align) {
1838d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1839d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1840d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1841d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
184263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
184363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1844d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  bool isMachineConstantPoolEntry() const {
1845d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return (int)Offset < 0;
1846d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1847d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1848d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  Constant *getConstVal() const {
1849d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1850d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.ConstVal;
1851d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1852d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1853d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  MachineConstantPoolValue *getMachineCPVal() const {
1854d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1855d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.MachineCPVal;
1856d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1857d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1858baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int getOffset() const {
1859baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng    return Offset & ~(1 << (sizeof(unsigned)*8-1));
1860baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  }
1861ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner
1862ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // Return the alignment of this constant pool object, which is either 0 (for
1863ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // default alignment) or log2 of the desired value.
1864b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned getAlignment() const { return Alignment; }
186563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1866d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  const Type *getType() const;
1867d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
186863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantPoolSDNode *) { return true; }
186963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1870aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    return N->getOpcode() == ISD::ConstantPool ||
1871aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner           N->getOpcode() == ISD::TargetConstantPool;
187263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
187363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
187463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
187563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode {
187663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *MBB;
187763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
187863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1879423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1880bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
188163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
188263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
188363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
188463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *getBasicBlock() const { return MBB; }
188563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
188663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const BasicBlockSDNode *) { return true; }
188763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
188863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return N->getOpcode() == ISD::BasicBlock;
188963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
189063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
189163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
189214471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
189314471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// used when the SelectionDAG needs to make a simple reference to something
189414471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// in the LLVM IR representation.
189514471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman///
189614471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// Note that this is not used for carrying alias information; that is done
189714471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// with MemOperandSDNode, which includes a Value which is required to be a
189814471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// pointer, and several other fields specific to memory references.
189914471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman///
19002d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode {
19012d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *V;
19022d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected:
19032d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  friend class SelectionDAG;
190469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  /// Create a SrcValue for a general value.
190569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  explicit SrcValueSDNode(const Value *v)
190669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {}
19072d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
19082d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic:
190969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  /// getValue - return the contained Value.
19102d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *getValue() const { return V; }
19112d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
19122d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SrcValueSDNode *) { return true; }
19132d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SDNode *N) {
19142d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth    return N->getOpcode() == ISD::SRCVALUE;
19152d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
19162d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth};
19172d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
191863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
191936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is
192069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// used to represent a reference to memory after ISD::LOAD
192169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// and ISD::STORE have been lowered.
192269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman///
192369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanclass MemOperandSDNode : public SDNode {
192469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanprotected:
192569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  friend class SelectionDAG;
192636b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  /// Create a MachineMemOperand node
192736b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  explicit MemOperandSDNode(const MachineMemOperand &mo)
192869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {}
192969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
193069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanpublic:
193136b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  /// MO - The contained MachineMemOperand.
193236b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  const MachineMemOperand MO;
193369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
193469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  static bool classof(const MemOperandSDNode *) { return true; }
193569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  static bool classof(const SDNode *N) {
193669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    return N->getOpcode() == ISD::MEMOPERAND;
193769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  }
193869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman};
193969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
194069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
1941d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode {
194263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned Reg;
194363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
194463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
194583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  RegisterSDNode(unsigned reg, MVT VT)
1946bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
194763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
194863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
194963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
195063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned getReg() const { return Reg; }
195163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1952d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner  static bool classof(const RegisterSDNode *) { return true; }
195363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1954d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    return N->getOpcode() == ISD::Register;
195563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
195663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
195763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
19587f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanclass DbgStopPointSDNode : public SDNode {
19597f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  SDUse Chain;
19607f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned Line;
19617f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned Column;
196283489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel  Value *CU;
19637f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanprotected:
19647f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  friend class SelectionDAG;
1965475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
196683489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel                     Value *cu)
19677f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)),
19687f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman      Line(l), Column(c), CU(cu) {
1969e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(&Chain, ch);
19707f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  }
19717f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanpublic:
19727f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned getLine() const { return Line; }
19737f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned getColumn() const { return Column; }
197483489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel  Value *getCompileUnit() const { return CU; }
19757f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman
19767f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  static bool classof(const DbgStopPointSDNode *) { return true; }
19777f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  static bool classof(const SDNode *N) {
19787f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    return N->getOpcode() == ISD::DBG_STOPPOINT;
19797f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  }
19807f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman};
19817f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman
19824406604047423576e36657c7ede266ca42e79642Dan Gohmanclass LabelSDNode : public SDNode {
19834406604047423576e36657c7ede266ca42e79642Dan Gohman  SDUse Chain;
19844406604047423576e36657c7ede266ca42e79642Dan Gohman  unsigned LabelID;
19854406604047423576e36657c7ede266ca42e79642Dan Gohmanprotected:
19864406604047423576e36657c7ede266ca42e79642Dan Gohman  friend class SelectionDAG;
1987475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id)
19884406604047423576e36657c7ede266ca42e79642Dan Gohman    : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) {
1989e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(&Chain, ch);
19904406604047423576e36657c7ede266ca42e79642Dan Gohman  }
19914406604047423576e36657c7ede266ca42e79642Dan Gohmanpublic:
19924406604047423576e36657c7ede266ca42e79642Dan Gohman  unsigned getLabelID() const { return LabelID; }
19934406604047423576e36657c7ede266ca42e79642Dan Gohman
19944406604047423576e36657c7ede266ca42e79642Dan Gohman  static bool classof(const LabelSDNode *) { return true; }
19954406604047423576e36657c7ede266ca42e79642Dan Gohman  static bool classof(const SDNode *N) {
19964406604047423576e36657c7ede266ca42e79642Dan Gohman    return N->getOpcode() == ISD::DBG_LABEL ||
19974406604047423576e36657c7ede266ca42e79642Dan Gohman           N->getOpcode() == ISD::EH_LABEL;
19984406604047423576e36657c7ede266ca42e79642Dan Gohman  }
19994406604047423576e36657c7ede266ca42e79642Dan Gohman};
20004406604047423576e36657c7ede266ca42e79642Dan Gohman
2001056292fd738924f3f7703725d8f630983794b5a5Bill Wendlingclass ExternalSymbolSDNode : public SDNode {
200263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *Symbol;
200363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
200463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
2005056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
2006056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
2007056292fd738924f3f7703725d8f630983794b5a5Bill Wendling             getSDVTList(VT)), Symbol(Sym) {
2008056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  }
200963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
2010056292fd738924f3f7703725d8f630983794b5a5Bill Wendling
201163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *getSymbol() const { return Symbol; }
201263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
2013056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  static bool classof(const ExternalSymbolSDNode *) { return true; }
201463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
2015056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    return N->getOpcode() == ISD::ExternalSymbol ||
2016056292fd738924f3f7703725d8f630983794b5a5Bill Wendling           N->getOpcode() == ISD::TargetExternalSymbol;
201763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
201863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
201963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
20207cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode {
202163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ISD::CondCode Condition;
202263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
202363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
2024423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit CondCodeSDNode(ISD::CondCode Cond)
2025bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
202663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
202763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
202863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
20297cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  ISD::CondCode get() const { return Condition; }
203063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
20317cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  static bool classof(const CondCodeSDNode *) { return true; }
203263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
20337cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    return N->getOpcode() == ISD::CONDCODE;
203463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
203563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
203663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
203777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the
203877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// future and most targets don't support it.
203977cdf30742284a173fe818417eb482224cdee8d4Mon P Wangclass CvtRndSatSDNode : public SDNode {
204077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  ISD::CvtCode CvtCode;
204177cdf30742284a173fe818417eb482224cdee8d4Mon P Wangprotected:
204277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  friend class SelectionDAG;
204377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  explicit CvtRndSatSDNode(MVT VT, const SDValue *Ops, unsigned NumOps,
204477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang                           ISD::CvtCode Code)
204577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    : SDNode(ISD::CONVERT_RNDSAT, getSDVTList(VT), Ops, NumOps), CvtCode(Code) {
204677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    assert(NumOps == 5 && "wrong number of operations");
204777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  }
204877cdf30742284a173fe818417eb482224cdee8d4Mon P Wangpublic:
204977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  ISD::CvtCode getCvtCode() const { return CvtCode; }
205077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
205177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  static bool classof(const CvtRndSatSDNode *) { return true; }
205277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  static bool classof(const SDNode *N) {
205377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    return N->getOpcode() == ISD::CONVERT_RNDSAT;
205477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  }
205577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang};
205677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
2057276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsnamespace ISD {
2058276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  struct ArgFlagsTy {
2059276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  private:
2060276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t NoFlagSet      = 0ULL;
2061276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ZExt           = 1ULL<<0;  ///< Zero extended
2062276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ZExtOffs       = 0;
2063276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SExt           = 1ULL<<1;  ///< Sign extended
2064276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SExtOffs       = 1;
2065276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t InReg          = 1ULL<<2;  ///< Passed in register
2066276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t InRegOffs      = 2;
2067276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SRet           = 1ULL<<3;  ///< Hidden struct-ret ptr
2068276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SRetOffs       = 3;
2069276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByVal          = 1ULL<<4;  ///< Struct passed by value
2070276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValOffs      = 4;
2071276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t Nest           = 1ULL<<5;  ///< Nested fn static chain
2072276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t NestOffs       = 5;
2073276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValAlign     = 0xFULL << 6; //< Struct alignment
2074276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValAlignOffs = 6;
20756ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    static const uint64_t Split          = 1ULL << 10;
20766ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    static const uint64_t SplitOffs      = 10;
2077276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t OrigAlign      = 0x1FULL<<27;
2078276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t OrigAlignOffs  = 27;
2079276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValSize      = 0xffffffffULL << 32; //< Struct size
2080276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValSizeOffs  = 32;
2081276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2082276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t One            = 1ULL; //< 1 of this type, for shifts
2083276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2084276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    uint64_t Flags;
2085276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  public:
2086276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    ArgFlagsTy() : Flags(0) { }
2087276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2088276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isZExt()   const { return Flags & ZExt; }
2089276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setZExt()  { Flags |= One << ZExtOffs; }
2090276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2091276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isSExt()   const { return Flags & SExt; }
2092276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setSExt()  { Flags |= One << SExtOffs; }
2093276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2094276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isInReg()  const { return Flags & InReg; }
2095276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setInReg() { Flags |= One << InRegOffs; }
2096276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2097276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isSRet()   const { return Flags & SRet; }
2098276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setSRet()  { Flags |= One << SRetOffs; }
2099276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2100276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isByVal()  const { return Flags & ByVal; }
2101276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByVal() { Flags |= One << ByValOffs; }
2102276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2103276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isNest()   const { return Flags & Nest; }
2104276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setNest()  { Flags |= One << NestOffs; }
2105276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2106276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getByValAlign() const {
210794bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)
210894bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen        ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
2109276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2110276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByValAlign(unsigned A) {
2111276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~ByValAlign) |
2112276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands        (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
2113276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2114c0cb28fd3abee9a8b40856990e04f1af2f9bd7b8Nicolas Geoffray
21156ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    bool isSplit()   const { return Flags & Split; }
21166ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    void setSplit()  { Flags |= One << SplitOffs; }
2117276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2118276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getOrigAlign() const {
211994bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)
212094bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen        ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
2121276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2122276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setOrigAlign(unsigned A) {
2123276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~OrigAlign) |
2124276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands        (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
2125276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2126276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2127276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getByValSize() const {
212894bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
2129276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2130276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByValSize(unsigned S) {
2131276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
2132276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2133276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2134276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
2135276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    std::string getArgFlagsString();
2136276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2137276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    /// getRawBits - Represent the flags as a bunch of bits.
2138276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    uint64_t getRawBits() const { return Flags; }
2139276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  };
2140276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands}
2141276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2142276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands/// ARG_FLAGSSDNode - Leaf node holding parameter flags.
2143276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsclass ARG_FLAGSSDNode : public SDNode {
2144276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ISD::ArgFlagsTy TheFlags;
2145276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsprotected:
2146276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  friend class SelectionDAG;
2147276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags)
2148276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) {
2149276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  }
2150276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandspublic:
2151276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ISD::ArgFlagsTy getArgFlags() const { return TheFlags; }
2152276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2153276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  static bool classof(const ARG_FLAGSSDNode *) { return true; }
2154276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  static bool classof(const SDNode *N) {
2155276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    return N->getOpcode() == ISD::ARG_FLAGS;
2156276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  }
2157276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands};
2158276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2159095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman/// CallSDNode - Node for calls -- ISD::CALL.
2160095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanclass CallSDNode : public SDNode {
2161095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned CallingConv;
2162095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  bool IsVarArg;
2163095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  bool IsTailCall;
216486098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // We might eventually want a full-blown Attributes for the result; that
216586098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // will expand the size of the representation.  At the moment we only
216686098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // need Inreg.
216786098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  bool Inreg;
2168095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanprotected:
2169095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  friend class SelectionDAG;
217086098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  CallSDNode(unsigned cc, bool isvararg, bool istailcall, bool isinreg,
2171095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman             SDVTList VTs, const SDValue *Operands, unsigned numOperands)
2172095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    : SDNode(ISD::CALL, VTs, Operands, numOperands),
217386098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen      CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall),
217486098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen      Inreg(isinreg) {}
2175095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanpublic:
2176095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getCallingConv() const { return CallingConv; }
2177095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned isVarArg() const { return IsVarArg; }
2178095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned isTailCall() const { return IsTailCall; }
217986098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  unsigned isInreg() const { return Inreg; }
2180095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2181095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  /// Set this call to not be marked as a tail call. Normally setter
2182095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  /// methods in SDNodes are unsafe because it breaks the CSE map,
21835eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman  /// but we don't include the tail call flag for calls so it's ok
21845eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman  /// in this case.
2185095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  void setNotTailCall() { IsTailCall = false; }
2186095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2187095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getChain() const { return getOperand(0); }
2188095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getCallee() const { return getOperand(1); }
2189095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2190095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getNumArgs() const { return (getNumOperands() - 2) / 2; }
2191095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getArg(unsigned i) const { return getOperand(2+2*i); }
2192095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getArgFlagsVal(unsigned i) const {
2193095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return getOperand(3+2*i);
2194095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2195095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  ISD::ArgFlagsTy getArgFlags(unsigned i) const {
2196095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return cast<ARG_FLAGSSDNode>(getArgFlagsVal(i).getNode())->getArgFlags();
2197095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2198095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2199095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getNumRetVals() const { return getNumValues() - 1; }
2200095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  MVT getRetValType(unsigned i) const { return getValueType(i); }
2201095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2202095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  static bool classof(const CallSDNode *) { return true; }
2203095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  static bool classof(const SDNode *N) {
2204095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return N->getOpcode() == ISD::CALL;
2205095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2206095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman};
2207095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
220883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands/// VTSDNode - This class is used to represent MVT's, which are used
220915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations.
221015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode {
221183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT ValueType;
221215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected:
221315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  friend class SelectionDAG;
221483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  explicit VTSDNode(MVT VT)
2215bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
221663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
221715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic:
221815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
221983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT getVT() const { return ValueType; }
222015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
222115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const VTSDNode *) { return true; }
222215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const SDNode *N) {
222315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    return N->getOpcode() == ISD::VALUETYPE;
222415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  }
222515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner};
222615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
22279de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
22289de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel///
222928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass LSBaseSDNode : public MemSDNode {
22309de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprotected:
22319de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel  //! Operand array for load and store
22329de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel  /*!
22339de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    \note Moving this array to the base class captures more
22349de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    common functionality shared between LoadSDNode and
22359de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    StoreSDNode
22369de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel   */
22379cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[4];
22389de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic:
2239475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LSBaseSDNode(ISD::NodeType NodeTy, SDValue *Operands, unsigned numOperands,
224083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands               SDVTList VTs, ISD::MemIndexedMode AM, MVT VT,
2241b625f2f8960de32bc973092aaee8ac62863006feDan Gohman               const Value *SV, int SVO, unsigned Align, bool Vol)
2242ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol) {
2243ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    SubclassData = AM;
2244e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, Operands, numOperands);
2245b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    assert(Align != 0 && "Loads and stores should have non-zero aligment");
2246437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman    assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
2247437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman           "Only indexed loads and stores have a non-undef offset operand");
2248b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  }
22499de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
2250475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const {
225163602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner    return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
225263602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner  }
22539de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
2254ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// getAddressingMode - Return the addressing mode for this load or store:
2255ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2256ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  ISD::MemIndexedMode getAddressingMode() const {
2257ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    return ISD::MemIndexedMode(SubclassData & 7);
2258ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
2259b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
2260b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  /// isIndexed - Return true if this is a pre/post inc/dec load/store.
2261ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2262b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
2263b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
2264ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2265b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
226613d57320bd212483463d4f8992d5787b29eda5dfBill Wendling  static bool classof(const LSBaseSDNode *) { return true; }
2267b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  static bool classof(const SDNode *N) {
2268b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    return N->getOpcode() == ISD::LOAD ||
2269b625f2f8960de32bc973092aaee8ac62863006feDan Gohman           N->getOpcode() == ISD::STORE;
2270b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  }
22719de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel};
22729de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
227324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
227424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
22759de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode {
227624446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
227724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
2278475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs,
227983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT,
228095c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb             const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2281b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
2282ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman                   VTs, AM, LVT, SV, O, Align, Vol) {
2283ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    SubclassData |= (unsigned short)ETy << 3;
2284ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
228524446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
228624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2287ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// getExtensionType - Return whether this is a plain node,
2288ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// or one of the varieties of value-extending loads.
2289ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  ISD::LoadExtType getExtensionType() const {
2290ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    return ISD::LoadExtType((SubclassData >> 3) & 3);
2291ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
2292ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
2293475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(1); }
2294475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const { return getOperand(2); }
229539354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner
229624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const LoadSDNode *) { return true; }
229724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
229824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD;
229924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
230024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
230124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
230224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes.
230324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
23049de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode {
230524446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
230624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
2307475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs,
230883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands              ISD::MemIndexedMode AM, bool isTrunc, MVT SVT,
230924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2310b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
2311ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman                   VTs, AM, SVT, SV, O, Align, Vol) {
2312ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    SubclassData |= (unsigned short)isTrunc << 3;
2313ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
231424446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
231524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2316ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// isTruncatingStore - Return true if the op does a truncation before store.
2317ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// For integers this is the same as doing a TRUNCATE and storing the result.
2318ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// For floats, it is the same as doing an FP_ROUND and storing the result.
2319ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  bool isTruncatingStore() const { return (SubclassData >> 3) & 1; }
2320ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
2321475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getValue() const { return getOperand(1); }
2322475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(2); }
2323475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const { return getOperand(3); }
232439354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner
23256d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng  static bool classof(const StoreSDNode *) { return true; }
232624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
232724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::STORE;
232824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
232924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
233024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
233115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
23321080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
23331080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNode *Node;
23341080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned Operand;
2335ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
23361080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
23371080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic:
23381080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator==(const SDNodeIterator& x) const {
23391080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return Operand == x.Operand;
23401080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
23411080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
23421080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
23431080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNodeIterator &operator=(const SDNodeIterator &I) {
23441080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
23451080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    Operand = I.Operand;
23461080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
23471080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
2348ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
23491080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator*() const {
2350ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node->getOperand(Operand).getNode();
23511080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
23521080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator->() const { return operator*(); }
2353ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
23541080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator& operator++() {                // Preincrement
23551080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    ++Operand;
23561080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
23571080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
23581080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator operator++(int) { // Postincrement
2359ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SDNodeIterator tmp = *this; ++*this; return tmp;
23601080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
23611080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
23621080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
23631080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator end  (SDNode *N) {
23641080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator(N, N->getNumOperands());
23651080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
23661080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
23671080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned getOperand() const { return Operand; }
23681080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNode *getNode() const { return Node; }
23691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
23701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
23711080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> {
23721080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNode NodeType;
23731080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNodeIterator ChildIteratorType;
23741080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static inline NodeType *getEntryNode(SDNode *N) { return N; }
2375ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_begin(NodeType *N) {
23761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::begin(N);
23771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
2378ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_end(NodeType *N) {
23791080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::end(N);
23801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
23811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
23821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
23830e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// LargestSDNode - The largest SDNode class.
23840e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman///
23850e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohmantypedef LoadSDNode LargestSDNode;
23860e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman
2387fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// MostAlignedSDNode - The SDNode class with the greatest alignment
2388fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// requirement.
2389fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman///
2390015b714f298ce3122302a4e996b81bd3e8c750cdDan Gohmantypedef ARG_FLAGSSDNode MostAlignedSDNode;
2391b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
2392c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD {
2393186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  /// isNormalLoad - Returns true if the specified node is a non-extending
2394186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  /// and unindexed load.
2395186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  inline bool isNormalLoad(const SDNode *N) {
2396c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
2397c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
2398186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng      Ld->getAddressingMode() == ISD::UNINDEXED;
2399186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  }
2400186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng
240124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// isNON_EXTLoad - Returns true if the specified node is a non-extending
240224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// load.
240324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  inline bool isNON_EXTLoad(const SDNode *N) {
2404c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
240524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
240624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
240724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2408c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
2409c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2410c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isEXTLoad(const SDNode *N) {
2411c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
241224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
2413c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
2414c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2415c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
2416c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2417c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isSEXTLoad(const SDNode *N) {
2418c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
241924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
2420c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
2421c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2422c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
2423c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2424c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isZEXTLoad(const SDNode *N) {
2425c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
242624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
2427c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
24288b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
2429c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
243002c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  ///
243102c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  inline bool isUNINDEXEDLoad(const SDNode *N) {
2432c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
243302c50e4891841c28b2a743731dfc60744bb78879Evan Cheng      cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
243402c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  }
243502c50e4891841c28b2a743731dfc60744bb78879Evan Cheng
2436c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isNormalStore - Returns true if the specified node is a non-truncating
2437c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// and unindexed store.
2438c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  inline bool isNormalStore(const SDNode *N) {
2439c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
2440c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return St && !St->isTruncatingStore() &&
2441c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands      St->getAddressingMode() == ISD::UNINDEXED;
2442c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  }
2443c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands
24448b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
24458b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
24468b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isNON_TRUNCStore(const SDNode *N) {
2447c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
24488b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
24498b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
24508b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isTRUNCStore - Returns true if the specified node is a truncating
24518b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
24528b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isTRUNCStore(const SDNode *N) {
2453c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
2454c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  }
2455c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands
2456c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isUNINDEXEDStore - Returns true if the specified node is an
2457c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// unindexed store.
2458c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  inline bool isUNINDEXEDStore(const SDNode *N) {
2459c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) &&
2460c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands      cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
24618b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
2462c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
2463c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2464c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
246563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace
246663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
246763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif
2468