SelectionDAGNodes.h revision a7ce741ff0ab02510833854bfa6a1c8c265faee3
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"
333b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen#include "llvm/CodeGen/DebugLoc.h"
3463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert>
3563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm {
3763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG;
3963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue;
4063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock;
41d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue;
4263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode;
4383489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patelclass Value;
4476c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate <typename T> struct DenseMapInfo;
4563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type;
468e4018e2de52c534405d7155c7009d0b35afb861Cedric Venettemplate <typename T> struct ilist_traits;
4763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by
490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG.  Instances of this simple value class are returned by
500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...).
510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner///
520b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList {
5383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  const MVT *VTs;
540b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  unsigned short NumVTs;
550b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner};
560b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
5763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the
5863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types.
5963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
6063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD {
61d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov
6263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
634f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// ISD::NodeType enum - This enum defines the target-independent operators
644f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// for a SelectionDAG.
6563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
664f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// Targets may also define target-dependent operator codes for SDNodes. For
674f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// example, on x86, these are the enum values in the X86ISD namespace.
684f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// Targets should aim to use target-independent operators to model their
694f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// instruction sets as much as possible, and only use target-dependent
704f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// operators when they have special requirements.
714f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  ///
724f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// Finally, during and after selection proper, SNodes may use special
734f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// operator codes that correspond directly with MachineInstr opcodes. These
744f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// are used to represent selected instructions. See the isMachineOpcode()
754f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman  /// and getMachineOpcode() member functions of SDNode.
76f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman  ///
7763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum NodeType {
783258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // DELETED_NODE - This is an illegal flag value that is used to catch
793258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // errors.  This opcode is not a legal opcode for any node.
803258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    DELETED_NODE,
813258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner
828a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // EntryToken - This is the marker used to indicate the start of the region.
838a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    EntryToken,
848a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner
85b2ab0e7471df7126a5b63fe8414b95c9584a0214Bill Wendling    // TokenFactor - This node takes multiple tokens as input and produces a
868a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // single token result.  This is used to represent the fact that the operand
878a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // operators are independent of each other.
888a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    TokenFactor,
89f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman
90f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // AssertSext, AssertZext - These nodes record if a register contains a
91f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // value that has already been zero or sign extended from a narrower type.
92f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // These nodes take two operands.  The first is the node that has already
93f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // been extended, and the second is a value type node indicating the width
94f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // of the extension
95f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    AssertSext, AssertZext,
96ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
978a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // Various leaf nodes.
987f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register,
991ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    Constant, ConstantFP,
100b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    GlobalAddress, GlobalTLSAddress, FrameIndex,
101056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    JumpTable, ConstantPool, ExternalSymbol,
1021ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng
10382c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    // The address of the GOT
10482c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    GLOBAL_OFFSET_TABLE,
105bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman
106bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
107bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // llvm.returnaddress on the DAG.  These nodes take one operand, the index
108bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // of the frame or return address to return.  An index of zero corresponds
109bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // to the current function's frame or return address, an index of one to the
110bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // parent's frame or return address, and so on.
111bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    FRAMEADDR, RETURNADDR,
1122365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
1132365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to
1142365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // first (possible) on-stack argument. This is needed for correct stack
1152365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // adjustment during unwind.
1162365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    FRAME_TO_ARGS_OFFSET,
117f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
118f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the
119f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // address of the exception block on entry to an landing pad block.
120f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    EXCEPTIONADDR,
121f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
122f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents
123f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    // the selection index of the exception thrown.
124f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey    EHSELECTION,
125beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth
1262365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents
1272365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // 'eh_return' gcc dwarf builtin, which is used to return from
1282365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // exception. The general meaning is: adjust stack by OFFSET and pass
1292365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    // execution to HANDLER. Many platform-related details also :)
1302365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov    EH_RETURN,
1312365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov
132ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // TargetConstant* - Like Constant*, but the DAG does not do any folding or
133ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // simplification of the constant.
134056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    TargetConstant,
135ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    TargetConstantFP,
136f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner
137f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
138f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // anything else with this node, and this is valid in the target-specific
139f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // dag, turning into a GlobalAddress operand.
140f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    TargetGlobalAddress,
141b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio    TargetGlobalTLSAddress,
142afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    TargetFrameIndex,
14337efe6764568a3829fee26aba532283131d1a104Nate Begeman    TargetJumpTable,
144aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    TargetConstantPool,
145056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    TargetExternalSymbol,
14672601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner
147ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
148ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with no side effects.
149ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// The first operand is the ID number of the intrinsic from the
150ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// llvm::Intrinsic namespace.  The operands to the intrinsic follow.  The
151ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// node has returns the result of the intrinsic.
152ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_WO_CHAIN,
153ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
154ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
155ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
156ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// returns a result.  The first operand is a chain pointer.  The second is
157ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// the ID number of the intrinsic from the llvm::Intrinsic namespace.  The
158ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// operands to the intrinsic follow.  The node has two results, the result
159ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// of the intrinsic and an output chain.
160ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_W_CHAIN,
16163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
162ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
163ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
164ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// does not return a result.  The first operand is a chain pointer.  The
165ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// second is the ID number of the intrinsic from the llvm::Intrinsic
166ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// namespace.  The operands to the intrinsic follow.
167ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_VOID,
168ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
169d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // CopyToReg - This node has three operands: a chain, a register number to
170d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // set to this value, and a value.
17163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyToReg,
17263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
17363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // CopyFromReg - This node indicates that the input value is a virtual or
17463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // physical register that is defined outside of the scope of this
175ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman    // SelectionDAG.  The register is available from the RegisterSDNode object.
17663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyFromReg,
17763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
178fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    // UNDEF - An undefined node
179fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    UNDEF,
180681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner
181b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
182b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// represents the formal arguments for a function.  CC# is a Constant value
183b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// indicating the calling convention of the function, and ISVARARG is a
184b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// flag that indicates whether the function is varargs or not. This node
185b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// has one result value for each incoming argument, plus one for the output
186b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// chain. It must be custom legalized. See description of CALL node for
187b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FLAG argument contents explanation.
188c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner    ///
189681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner    FORMAL_ARGUMENTS,
1906c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner
191095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CALLEE,
192b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    ///                              ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn)
1936c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    /// This node represents a fully general function call, before the legalizer
194b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// runs.  This has one result value for each argument / flag pair, plus
195b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// a chain result. It must be custom legalized. Flag argument indicates
196b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// misc. argument attributes. Currently:
197b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 0 - signness
198b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 1 - 'inreg' attribute
199b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 2 - 'sret' attribute
200594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 4 - 'byval' attribute
201594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 5 - 'nest' attribute
202594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 6-9 - alignment of byval structures
203594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola    /// Bit 10-26 - size of byval structures
20413a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio    /// Bits 31:27 - argument ABI alignment in the first argument piece and
20513a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio    /// alignment '1' in other argument pieces.
206095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    ///
207095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// CALL nodes use the CallSDNode subclass of SDNode, which
208095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// additionally carries information about the calling convention,
209095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    /// whether the call is varargs, and if it's marked as a tail call.
210095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    ///
2116c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    CALL,
212fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman
21325eb043759c23b61769108f78382eb9701c41db2Duncan Sands    // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by
214041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // a Constant, which is required to be operand #1) half of the integer or
215041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // float value specified as operand #0.  This is only for use before
216041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands    // legalization, for values that will be broken into multiple registers.
21763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    EXTRACT_ELEMENT,
21863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
21963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.  Given
22063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // two values of the same integer value type, this produces a value twice as
22163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // big.  Like EXTRACT_ELEMENT, this can only be used before legalization.
22263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BUILD_PAIR,
223041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands
224006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // MERGE_VALUES - This node takes multiple discrete operands and returns
225006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // them all as its individual results.  This nodes has exactly the same
226006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // number of inputs and outputs, and is only valid before legalization.
227006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // This node is useful for some pieces of the code generator that want to
228006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // think about a single node with multiple results, not multiple nodes.
229006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    MERGE_VALUES,
23063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
231615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple integer binary arithmetic operators.
232bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
233fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman
234fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing
235b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands    // a signed/unsigned value of type i[2*N], and return the full value as
236fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // two results, each of type iN.
237fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    SMUL_LOHI, UMUL_LOHI,
238fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman
239fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and
240fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    // remainder result.
241fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman    SDIVREM, UDIVREM,
242615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner
24355e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    // CARRY_FALSE - This node is used when folding other nodes,
24455e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    // like ADDC/SUBC, which indicate the carry result is always false.
24555e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner    CARRY_FALSE,
24655e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner
247551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-setting nodes for multiple precision addition and subtraction.
248551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // These nodes take two operands of the same value type, and produce two
249551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // results.  The first result is the normal add or sub result, the second
250551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // result is the carry flag result.
251551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDC, SUBC,
252551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman
253551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-using nodes for multiple precision addition and subtraction.  These
254551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // nodes take three operands: The first two are the normal lhs and rhs to
255551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // the add or sub, and the third is the input carry flag.  These nodes
256551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // produce two results; the normal result of the add or sub, and the output
257551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // carry flag.  These nodes both read and write a carry flag to allow them
258551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // to them to be chained together for add and sub of arbitrarily large
259551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // values.
260551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDE, SUBE,
261ea7b527aa56ad0fe547d3d99b21e845a49a031cbBill Wendling
262253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
263253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // These nodes take two operands: the normal LHS and RHS to the add. They
264253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // produce two results: the normal result of the add, and a boolean that
265253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // indicates if an overflow occured (*not* a flag, because it may be stored
266253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // to memory, etc.).  If the type of the boolean is not i1 then the high
26703228089d5235f8c90477f88809139464e9c6ea5Duncan Sands    // bits conform to getBooleanContents.
268253174bf50c932abaa680f465e2888c0e5272267Bill Wendling    // These nodes are generated from the llvm.[su]add.with.overflow intrinsics.
2691c55a9c0cc355ad72c55ae7665143b9a992d223bBill Wendling    SADDO, UADDO,
270ea7b527aa56ad0fe547d3d99b21e845a49a031cbBill Wendling
27174c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    // Same for subtraction
27274c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    SSUBO, USUBO,
27374c376529101acbe141a256d0bf23a44eb454c84Bill Wendling
27474c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    // Same for multiplication
27574c376529101acbe141a256d0bf23a44eb454c84Bill Wendling    SMULO, UMULO,
27674c376529101acbe141a256d0bf23a44eb454c84Bill Wendling
277615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple binary floating point operators.
278615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    FADD, FSUB, FMUL, FDIV, FREM,
27938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
28038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.  NOTE: This
28138bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // DAG node does not require that X and Y have the same type, just that they
28238bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // are both floating point.  X and the result must have the same type.
28338bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(f32, f64) is allowed.
28438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    FCOPYSIGN,
285fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner
2861a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point
2871a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    // value as an integer 0/1 value.
2881a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner    FGETSIGN,
2891a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner
290664e9546d674096c5a012536f1a424b1681ece51Dan Gohman    /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector
29122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// with the specified, possibly variable, elements.  The number of elements
29222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// is required to be a power of two.
29322232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    BUILD_VECTOR,
29422232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
2957f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element
2964f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands    /// at IDX replaced with VAL.  If the type of VAL is larger than the vector
2974f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands    /// element type then VAL is truncated before replacement.
29822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    INSERT_VECTOR_ELT,
2994b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner
3004b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
3017f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// identified by the (potentially variable) element number IDX.
3024b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    EXTRACT_VECTOR_ELT,
30322232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
3047f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of
3057f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// vector type with the same length and element type, this produces a
3067f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// concatenated vector result value, with length equal to the sum of the
307b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman    /// lengths of the input vectors.
3087f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    CONCAT_VECTORS,
3096595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman
3107f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
3117f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// vector value) starting with the (potentially variable) element number
3127f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    /// IDX, which must be a multiple of the result vector length.
3137f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman    EXTRACT_SUBVECTOR,
31459c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands
31549c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
31649c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// type as VEC1/VEC2.  SHUFFLEVEC is a BUILD_VECTOR of constant int values
31759c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// (maybe of an illegal datatype) or undef that indicate which value each
31859c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// result element will get.  The elements of VEC1/VEC2 are enumerated in
31959c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// order.  This is quite similar to the Altivec 'vperm' instruction, except
32059c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// that the indices must be constants and are in terms of the element size
32159c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands    /// of VEC1/VEC2, not in terms of bytes.
32249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    VECTOR_SHUFFLE,
32359c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands
324210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
325a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman    /// scalar value into element 0 of the resultant vector type.  The top
326a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman    /// elements 1 to N-1 of the N-element vector are undefined.
327210721aecc0916315f61660dc387a96b89ec423bChris Lattner    SCALAR_TO_VECTOR,
328210721aecc0916315f61660dc387a96b89ec423bChris Lattner
329557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // EXTRACT_SUBREG - This node is used to extract a sub-register value.
330557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // This node takes a superreg and a constant sub-register index as operands.
331709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // Note sub-register indices must be increasing. That is, if the
332709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // sub-register index of a 8-bit sub-register is N, then the index for a
333709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng    // 16-bit sub-register must be at least N+1.
334557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    EXTRACT_SUBREG,
335557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb
3364499e495eabe8de7d595416a03c56af4688df507Evan Cheng    // INSERT_SUBREG - This node is used to insert a sub-register value.
337557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    // This node takes a superreg, a subreg value, and a constant sub-register
3384499e495eabe8de7d595416a03c56af4688df507Evan Cheng    // index as operands.
339557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb    INSERT_SUBREG,
340557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb
341bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
342b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands    // an unsigned/signed value of type i[2*N], then return the top part.
343bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    MULHU, MULHS,
34463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
34535ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // Bitwise operators - logical and, logical or, logical xor, shift left,
34635ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // shift right algebraic (shift in sign bits), shift right logical (shift in
34735ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // zeroes), rotate left, rotate right, and byteswap.
34835ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
34963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
350691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    // Counting operators
351691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    CTTZ, CTLZ, CTPOP,
352691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth
3533b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // Select(COND, TRUEVAL, FALSEVAL).  If the type of the boolean COND is not
35403228089d5235f8c90477f88809139464e9c6ea5Duncan Sands    // i1 then the high bits must conform to getBooleanContents.
3553b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    SELECT,
3563b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands
3579373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // Select with condition operator - This selects between a true value and
3589373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // a false value (ops #2 and #3) based on the boolean result of comparing
3599373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // the lhs and rhs (ops #0 and #1) of a conditional expression with the
3609373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // condition code in op #4, a CondCodeSDNode.
3619373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    SELECT_CC,
36263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3633b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // SetCC operator - This evaluates to a true value iff the condition is
3643b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // true.  If the result value type is not i1 then the high bits conform
36503228089d5235f8c90477f88809139464e9c6ea5Duncan Sands    // to getBooleanContents.  The operands to this are the left and right
3663b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // operands to compare (ops #0, and #1) and the condition code to compare
3673b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands    // them with (op #2) as a CondCodeSDNode.
36863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETCC,
36963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
370b43e9c196542acc80c9e4643809661065710848fNate Begeman    // Vector SetCC operator - This evaluates to a vector of integer elements
371b43e9c196542acc80c9e4643809661065710848fNate Begeman    // with the high bit in each element set to true if the comparison is true
372b43e9c196542acc80c9e4643809661065710848fNate Begeman    // and false if the comparison is false.  All other bits in each element
373b43e9c196542acc80c9e4643809661065710848fNate Begeman    // are undefined.  The operands to this are the left and right operands
374b43e9c196542acc80c9e4643809661065710848fNate Begeman    // to compare (ops #0, and #1) and the condition code to compare them with
375b43e9c196542acc80c9e4643809661065710848fNate Begeman    // (op #2) as a CondCodeSDNode.
376b43e9c196542acc80c9e4643809661065710848fNate Begeman    VSETCC,
377b43e9c196542acc80c9e4643809661065710848fNate Begeman
37814c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
37914c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // integer shift operations, just like ADD/SUB_PARTS.  The operation
38014c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // ordering is:
3816b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner    //       [Lo,Hi] = op [LoLHS,HiLHS], Amt
38214c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    SHL_PARTS, SRA_PARTS, SRL_PARTS,
38314c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner
38463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Conversion operators.  These are all single input single output
38563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operations.  For all of these, the result type must be strictly
38663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // wider or narrower (depending on the operation) than the source
38763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // type.
38863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
38963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // SIGN_EXTEND - Used for integer types, replicating the sign bit
39063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // into new bits.
39163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SIGN_EXTEND,
39263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
39363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // ZERO_EXTEND - Used for integer types, zeroing the new bits.
39463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    ZERO_EXTEND,
39563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3967e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    // ANY_EXTEND - Used for integer types.  The high bits are undefined.
3977e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    ANY_EXTEND,
3987e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner
39963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // TRUNCATE - Completely drop the high bits.
40063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    TRUNCATE,
40163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4021645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
4031645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // depends on the first letter) to floating point.
4041645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    SINT_TO_FP,
4051645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    UINT_TO_FP,
4061645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
407ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
408ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // sign extend a small value in a large integer register (e.g. sign
409ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // extending the low 8 bits of a 32-bit register to fill the top 24 bits
41015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // with the 7th bit).  The size of the smaller type is indicated by the 1th
41115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // operand, a ValueType node.
412859157daee6a4b49e99921832e1dde065167b317Chris Lattner    SIGN_EXTEND_INREG,
413859157daee6a4b49e99921832e1dde065167b317Chris Lattner
4140bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
4150bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// integer.
4161645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_SINT,
4171645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_UINT,
4181645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
4190bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type
4200bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// down to the precision of the destination VT.  TRUNC is a flag, which is
4210bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// always an integer that is zero or one.  If TRUNC is 0, this is a
4220bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// normal rounding, if it is 1, this FP_ROUND is known to not change the
4230bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// value of Y.
4240bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    ///
4250bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// The TRUNC = 1 case is used in cases where we know that the value will
4260bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// not be modified by the node, because Y is not using any of the extra
4270bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// precision of source type.  This allows certain transformations like
4280bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for
4290bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed.
43063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_ROUND,
4310bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner
4321a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman    // FLT_ROUNDS_ - Returns current rounding mode:
433917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    // -1 Undefined
434917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  0 Round to 0
435917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  1 Round to nearest
436917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  2 Round to +inf
437917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov    //  3 Round to -inf
4381a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman    FLT_ROUNDS_,
439917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov
4400bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and
4410bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// rounds it to a floating point value.  It then promotes it and returns it
4420bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// in a register of the same size.  This operation effectively just
4430bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// discards excess precision.  The type to round down to is specified by
4440bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// the VT operand, a VTSDNode.
445859157daee6a4b49e99921832e1dde065167b317Chris Lattner    FP_ROUND_INREG,
446859157daee6a4b49e99921832e1dde065167b317Chris Lattner
4470bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner    /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
44863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_EXTEND,
44963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4501ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // BIT_CONVERT - Theis operator converts between integer and FP values, as
4511ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // if one was stored to memory as integer and the other was loaded from the
45280f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // same address (or equivalently for vector format conversions, etc).  The
45380f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // source and result are required to have the same bit size (e.g.
45480f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // f32 <-> i32).  This can also be used for int-to-int or fp-to-fp
45580f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // conversions, but that is a noop, deleted by getNode().
4561ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    BIT_CONVERT,
4571ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner
45877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    // CONVERT_RNDSAT - This operator is used to support various conversions
45900ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // between various types (float, signed, unsigned and vectors of those
46000ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // types) with rounding and saturation. NOTE: Avoid using this operator as
46100ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // most target don't support it and the operator might be removed in the
46200ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang    // future. It takes the following arguments:
46377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   0) value
46477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   1) dest type (type to convert to)
46577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   2) src type (type to convert from)
46677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   3) rounding imm
46777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   4) saturation imm
46877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    //   5) ISD::CvtCode indicating the type of conversion to do
46977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CONVERT_RNDSAT,
47077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
471509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
4727794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen    // FLOG, FLOG2, FLOG10, FEXP, FEXP2,
4738471ef5f4e79fbe4d7021e91d45e39fdbf8783fcDan Gohman    // FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR - Perform various unary floating
474509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    // point operations. These are inspired by libm.
47507f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman    FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW,
4767794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen    FLOG, FLOG2, FLOG10, FEXP, FEXP2,
477509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman    FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR,
47838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
4798862ef148100070b7bf28beead3951464250c926Evan Cheng    // LOAD and STORE have token chains as their first operand, then the same
4808862ef148100070b7bf28beead3951464250c926Evan Cheng    // operands as an LLVM load/store instruction, then an offset node that
4818862ef148100070b7bf28beead3951464250c926Evan Cheng    // is added / subtracted from the base pointer to form the address (for
4828862ef148100070b7bf28beead3951464250c926Evan Cheng    // indexed memory ops).
48363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    LOAD, STORE,
484ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
48563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
48657fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // to a specified boundary.  This node always has two return values: a new
48757fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // stack pointer value and a chain. The first operand is the token chain,
48857fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // the second is the number of bytes to allocate, and the third is the
48957fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // alignment boundary.  The size is guaranteed to be a multiple of the stack
49057fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov    // alignment, and the alignment is guaranteed to be bigger than the stack
49174fe063e90045931eefaba561730e6a9175ced78Chris Lattner    // alignment (if required) or 0 to get standard stack alignment.
49263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    DYNAMIC_STACKALLOC,
49363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
49463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Control flow instructions.  These all have token chains.
495ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
49663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BR - Unconditional branch.  The first operand is the chain
49763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operand, the second is the MBB to branch to.
49863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BR,
49963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
50037efe6764568a3829fee26aba532283131d1a104Nate Begeman    // BRIND - Indirect branch.  The first operand is the chain, the second
50137efe6764568a3829fee26aba532283131d1a104Nate Begeman    // is the value to branch to, which must be of the same type as the target's
50237efe6764568a3829fee26aba532283131d1a104Nate Begeman    // pointer type.
50337efe6764568a3829fee26aba532283131d1a104Nate Begeman    BRIND,
504c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng
505c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // BR_JT - Jumptable branch. The first operand is the chain, the second
506c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // is the jumptable index, the last one is the jumptable entry index.
507c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    BR_JT,
50847b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands
50947b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // BRCOND - Conditional branch.  The first operand is the chain, the
51047b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // second is the condition, the third is the block to branch to if the
51147b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands    // condition is true.  If the type of the condition is not i1, then the
51203228089d5235f8c90477f88809139464e9c6ea5Duncan Sands    // high bits must conform to getBooleanContents.
51363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BRCOND,
51463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
5157cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // BR_CC - Conditional branch.  The behavior is like that of SELECT_CC, in
5167cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // that the condition is represented as condition code, and two nodes to
5177cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // compare, rather than as a combined SetCC node.  The operands in order are
5187cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // chain, cc, lhs, rhs, block to branch to if condition is true.
5197cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    BR_CC,
5207cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman
52163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // RET - Return from function.  The first operand is the chain,
5228e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // and any subsequent operands are pairs of return value and return value
523c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen    // attributes (see CALL for description of attributes) for the function.
524c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen    // This operation can have variable number of operands.
52563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    RET,
52663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
5277572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // INLINEASM - Represents an inline asm block.  This node always has two
5287572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // return values: a chain and a flag result.  The inputs are as follows:
5297572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #0   : Input chain.
530056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    //   Operand #1   : a ExternalSymbolSDNode with a pointer to the asm string.
5317572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+2: A RegisterNode.
5327572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
5337572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #last: Optional, an incoming flag.
5347572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    INLINEASM,
5351ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey
5364406604047423576e36657c7ede266ca42e79642Dan Gohman    // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track
5374406604047423576e36657c7ede266ca42e79642Dan Gohman    // locations needed for debug and exception handling tables.  These nodes
5384406604047423576e36657c7ede266ca42e79642Dan Gohman    // take a chain as input and return a chain.
5394406604047423576e36657c7ede266ca42e79642Dan Gohman    DBG_LABEL,
5404406604047423576e36657c7ede266ca42e79642Dan Gohman    EH_LABEL,
541a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng
542a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track
543a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // local variable declarations for debugging information. First operand is
544a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // a chain, while the next two operands are first two arguments (address
545a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    // and variable) of a llvm.dbg.declare instruction.
546a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng    DECLARE,
547f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey
5485a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKSAVE - STACKSAVE has one operand, an input chain.  It produces a
5495a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // value, the same type as the pointer type for the system, and an output
5505a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // chain.
5515a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKSAVE,
5525a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
5535a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKRESTORE has two operands, an input chain and a pointer to restore to
5545a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // it returns an output chain.
5555a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKRESTORE,
5565a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
55716cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
55816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // a call sequence, and carry arbitrary information that target might want
55916cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // to know.  The first operand is a chain, the rest are specified by the
56016cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // target and not touched by the DAG optimizers.
5610ea0356dff38dfd0420b8c0a2fdf2fae7898c024Dale Johannesen    // CALLSEQ_START..CALLSEQ_END pairs may not be nested.
56216cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_START,  // Beginning of a call sequence
56316cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_END,    // End of a call sequence
564acc398c195a697795bff3245943d104eb19192b9Nate Begeman
565acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAARG - VAARG has three operands: an input chain, a pointer, and a
566acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // SRCVALUE.  It returns a pair of values: the vaarg value and a new chain.
567acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAARG,
568acc398c195a697795bff3245943d104eb19192b9Nate Begeman
569acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
570acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
571acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // source.
572acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VACOPY,
573acc398c195a697795bff3245943d104eb19192b9Nate Begeman
574acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
575acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // pointer, and a SRCVALUE.
576acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAEND, VASTART,
57763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
57869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    // SRCVALUE - This is a node type that holds a Value* that is used to
57969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    // make reference to a value in the LLVM IR.
58021074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    SRCVALUE,
58121074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner
58236b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // MEMOPERAND - This is a node that contains a MachineMemOperand which
58336b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // records information about a memory reference. This is used to make
58436b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman    // AliasAnalysis queries from the backend.
58569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    MEMOPERAND,
58669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
587e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman    // PCMARKER - This corresponds to the pcmarker intrinsic.
58895762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth    PCMARKER,
58963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
590aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
5918b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // The only operand is a chain and a value and a chain are produced.  The
5928b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // value is the contents of the architecture specific cycle counter like
5938b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // register (or other high accuracy low latency clock source)
594aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    READCYCLECOUNTER,
595aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth
596d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    // HANDLENODE node - Used as a handle for various purposes.
597d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    HANDLENODE,
5982d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
5997f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // DBG_STOPPOINT - This node is used to represent a source location for
6007f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // debug info.  It takes token chain as input, and carries a line number,
60183489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel    // column number, and a pointer to a CompileUnit object identifying
6027f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    // the containing compilation unit.  It produces a token chain as output.
6037f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    DBG_STOPPOINT,
60447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner
605f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    // DEBUG_LOC - This node is used to represent source line information
606abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // embedded in the code.  It takes a token chain as input, then a line
60744c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey    // number, then a column then a file id (provided by MachineModuleInfo.) It
608abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // produces a token chain as output.
609f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    DEBUG_LOC,
61036397f50343639ce9a25996f2d790c656791ab92Duncan Sands
61136397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // TRAMPOLINE - This corresponds to the init_trampoline intrinsic.
61236397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // It takes as input a token chain, the pointer to the trampoline,
61336397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // the pointer to the nested function, the pointer to pass for the
61436397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // 'nest' parameter, a SRCVALUE for the trampoline and another for
61536397f50343639ce9a25996f2d790c656791ab92Duncan Sands    // the nested function (allowing targets to access the original
616f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands    // Function*).  It produces the result of the intrinsic and a token
617f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands    // chain as output.
61836397f50343639ce9a25996f2d790c656791ab92Duncan Sands    TRAMPOLINE,
61936397f50343639ce9a25996f2d790c656791ab92Duncan Sands
62066fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov    // TRAP - Trapping instruction
62166fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov    TRAP,
62266fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov
62327b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are
62427b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // their first operand. The other operands are the address to prefetch,
62527b7db549e4c5bff4579d209304de5628513edebEvan Cheng    // read / write specifier, and locality specifier.
62627b7db549e4c5bff4579d209304de5628513edebEvan Cheng    PREFETCH,
62727b7db549e4c5bff4579d209304de5628513edebEvan Cheng
62822c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load,
62922c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    //                       store-store, device)
630ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // This corresponds to the memory.barrier intrinsic.
63122c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // it takes an input chain, 4 operands to specify the type of barrier, an
63222c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // operand specifying if the barrier applies to device and uncached memory
63322c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    // and produces an output chain.
63422c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth    MEMBARRIER,
63522c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth
63628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang    // Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap)
637ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // this corresponds to the atomic.lcs intrinsic.
638ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // cmp is compared to *ptr, and if equal, swap is stored in *ptr.
639ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // the return is always the original value in *ptr
6400b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_CMP_SWAP,
641ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
642ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt)
643ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // this corresponds to the atomic.swap intrinsic.
644ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // amt is stored to *ptr atomically.
645ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth    // the return is always the original value in *ptr
6460b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_SWAP,
647ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
648a82a91850779f7c3a173a5828333dfd5162f855dDan Gohman    // Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt)
649a82a91850779f7c3a173a5828333dfd5162f855dDan Gohman    // this corresponds to the atomic.load.[OpName] intrinsic.
65063307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    // op(*ptr, amt) is stored to *ptr atomically.
65163307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang    // the return is always the original value in *ptr
6520b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_ADD,
6530b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_SUB,
6540b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_AND,
6550b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_OR,
6560b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_XOR,
6570b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_NAND,
6580b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_MIN,
6590b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_MAX,
6600b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_UMIN,
6610b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    ATOMIC_LOAD_UMAX,
66263307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang
66363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILTIN_OP_END - This must be the last enum value in this list.
664410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    BUILTIN_OP_END
66563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
66663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
667322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// Node predicates
668322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
669a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  /// isBuildVectorAllOnes - Return true if the specified node is a
670322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// BUILD_VECTOR where all of the elements are ~0 or undef.
671a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  bool isBuildVectorAllOnes(const SDNode *N);
6724a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng
6734a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// isBuildVectorAllZeros - Return true if the specified node is a
6744a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// BUILD_VECTOR where all of the elements are 0 or undef.
6754a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  bool isBuildVectorAllZeros(const SDNode *N);
676bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng
677efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// isScalarToVector - Return true if the specified node is a
678efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low
679efec751a1b786724862ceff52748df94873a807eEvan Cheng  /// element is not an undef.
680efec751a1b786724862ceff52748df94873a807eEvan Cheng  bool isScalarToVector(const SDNode *N);
681efec751a1b786724862ceff52748df94873a807eEvan Cheng
682bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng  /// isDebugLabel - Return true if the specified node represents a debug
6834406604047423576e36657c7ede266ca42e79642Dan Gohman  /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node).
684bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng  bool isDebugLabel(const SDNode *N);
685322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
68663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
687144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// MemIndexedMode enum - This enum defines the load / store indexed
688144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// addressing modes.
68924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
69024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// UNINDEXED    "Normal" load / store. The effective address is already
69124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computed and is available in the base pointer. The offset
69281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              operand is always undefined. In addition to producing a
69381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              chain, an unindexed load produces one value (result of the
694276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ///              load); an unindexed store does not produce a value.
69524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
69635acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// PRE_INC      Similar to the unindexed mode where the effective address is
6978862ef148100070b7bf28beead3951464250c926Evan Cheng  /// PRE_DEC      the value of the base pointer add / subtract the offset.
6988862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              It considers the computation as being folded into the load /
69924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              store operation (i.e. the load / store does the address
70024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computation as well as performing the memory transaction).
70181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              The base operand is always undefined. In addition to
70281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              producing a chain, pre-indexed load produces two values
70381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              (result of the load and the result of the address
70481c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              computation); a pre-indexed store produces one value (result
70581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              of the address computation).
70624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
70735acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// POST_INC     The effective address is the value of the base pointer. The
7088862ef148100070b7bf28beead3951464250c926Evan Cheng  /// POST_DEC     value of the offset operand is then added to / subtracted
7098862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              from the base after memory transaction. In addition to
7108862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              producing a chain, post-indexed load produces two values
7118862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              (the result of the load and the result of the base +/- offset
7128862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              computation); a post-indexed store produces one value (the
7138862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              the result of the base +/- offset computation).
71424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
715144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  enum MemIndexedMode {
71624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    UNINDEXED = 0,
71735acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_INC,
71835acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_DEC,
71935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    POST_INC,
720144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    POST_DEC,
721144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    LAST_INDEXED_MODE
72224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  };
72324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
72424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  //===--------------------------------------------------------------------===//
725c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// LoadExtType enum - This enum defines the three variants of LOADEXT
726c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// (load with extension).
727c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
72824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// SEXTLOAD loads the integer operand and sign extends it to a larger
72924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
73024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// ZEXTLOAD loads the integer operand and zero extends it to a larger
73124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
73224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// EXTLOAD  is used for three things: floating point extending loads,
73324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer extending loads [the top bits are undefined], and vector
73424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          extending loads [load into low elt].
73524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
736c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  enum LoadExtType {
73724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    NON_EXTLOAD = 0,
738c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    EXTLOAD,
739c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    SEXTLOAD,
740c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    ZEXTLOAD,
7410329466b6b4927f4e6f5d144891fef06a027fec5Evan Cheng    LAST_LOADEXT_TYPE
742c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  };
743c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
744c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  //===--------------------------------------------------------------------===//
74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::CondCode enum - These are ordered carefully to make the bitfields
74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// below work out, when considering SETFALSE (something that never exists
74763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// dynamically) as 0.  "U" -> Unsigned (for integer operands) or Unordered
74863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
74963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to.  If the "N" column is 1, the result of the comparison is undefined if
75063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the input is a NAN.
75163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
75263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// All of these (except for the 'always folded ops') should be handled for
75363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// floating point.  For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
75463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
75563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
75663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// Note that these are laid out in a specific order to allow bit-twiddling
75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to transform conditions.
75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum CondCode {
75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Opcode          N U L G E       Intuitive operation
76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE,      //    0 0 0 0       Always false (always folded)
76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOEQ,        //    0 0 0 1       True if ordered and equal
76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGT,        //    0 0 1 0       True if ordered and greater than
76363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGE,        //    0 0 1 1       True if ordered and greater than or equal
76463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLT,        //    0 1 0 0       True if ordered and less than
76563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLE,        //    0 1 0 1       True if ordered and less than or equal
76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETONE,        //    0 1 1 0       True if ordered and operands are unequal
76763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETO,          //    0 1 1 1       True if ordered (no nans)
76863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUO,         //    1 0 0 0       True if unordered: isnan(X) | isnan(Y)
76963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUEQ,        //    1 0 0 1       True if unordered or equal
77063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGT,        //    1 0 1 0       True if unordered or greater than
77163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGE,        //    1 0 1 1       True if unordered, greater than, or equal
77263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETULT,        //    1 1 0 0       True if unordered or less than
773ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETULE,        //    1 1 0 1       True if unordered, less than, or equal
77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUNE,        //    1 1 1 0       True if unordered or not equal
77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE,       //    1 1 1 1       Always true (always folded)
77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Don't care operations: undefined if the input is a nan.
77763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE2,     //  1 X 0 0 0       Always false (always folded)
77863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETEQ,         //  1 X 0 0 1       True if equal
77963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGT,         //  1 X 0 1 0       True if greater than
78063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGE,         //  1 X 0 1 1       True if greater than or equal
78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETLT,         //  1 X 1 0 0       True if less than
782ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETLE,         //  1 X 1 0 1       True if less than or equal
78363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETNE,         //  1 X 1 1 0       True if not equal
78463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE2,      //  1 X 1 1 1       Always true (always folded)
78563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
786410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    SETCC_INVALID       // Marker value.
78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isSignedIntSetCC - Return true if this is a setcc instruction that
79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs a signed comparison when used with integer operands.
79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isSignedIntSetCC(CondCode Code) {
79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
79463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
79563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs an unsigned comparison when used with integer operands.
79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isUnsignedIntSetCC(CondCode Code) {
79863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
80163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isTrueWhenEqual - Return true if the specified condition returns true if
80263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the two operands to the condition are equal.  Note that if one of the two
80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operands is a NaN, this value is meaningless.
80463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isTrueWhenEqual(CondCode Cond) {
80563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond & 1) != 0;
80663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
80763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
80863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getUnorderedFlavor - This function returns 0 if the condition is always
80963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// false if an operand is a NaN, 1 if the condition is always true if the
81063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operand is a NaN, and 2 if the condition is undefined if the operand is a
81163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// NaN.
81263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getUnorderedFlavor(CondCode Cond) {
81363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond >> 3) & 3;
81463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
81563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
81663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
81763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// 'op' is a valid SetCC operation.
81863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCInverse(CondCode Operation, bool isInteger);
81963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
82063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
82163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// when given the operation for (X op Y).
82263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCSwappedOperands(CondCode Operation);
82363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
82463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCOrOperation - Return the result of a logical OR between different
82563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// comparisons of identical values: ((X op1 Y) | (X op2 Y)).  This
82663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
82763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
82863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
82963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
83063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCAndOperation - Return the result of a logical AND between
83163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)).  This
83263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
83363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
83463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
83577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
83677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  //===--------------------------------------------------------------------===//
83777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  /// CvtCode enum - This enum defines the various converts CONVERT_RNDSAT
83877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  /// supports.
83977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  enum CvtCode {
84077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FF,     // Float from Float
84177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FS,     // Float from Signed
84277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_FU,     // Float from Unsigned
84377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SF,     // Signed from Float
84477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_UF,     // Unsigned from Float
84577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SS,     // Signed from Signed
84677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_SU,     // Signed from Unsigned
84777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_US,     // Unsigned from Signed
84877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_UU,     // Unsigned from Unsigned
84977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    CVT_INVALID // Marker - Invalid opcode
85077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  };
85163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}  // end llvm::ISD namespace
85263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
85363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
85463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
855475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple
85663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation.  Many nodes return multiple values,
85763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns
85863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number
85963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values).
86063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
86163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that
86263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node.  This pair
863475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// of information is represented with the SDValue value type.
86463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
865475871a144eb604ddaf37503397ba0941442e5fbDan Gohmanclass SDValue {
866ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDNode *Node;       // The node defining the value we are using.
86763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned ResNo;     // Which return value of the node we are using.
86899a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greifpublic:
869ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDValue() : Node(0), ResNo(0) {}
870ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {}
87163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
87299a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif  /// get the index which selects a specific result in the SDNode
87399a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif  unsigned getResNo() const { return ResNo; }
87499a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif
875ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// get the SDNode which holds the desired result
876ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  SDNode *getNode() const { return Node; }
877ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif
878ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// set the SDNode
879ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  void setNode(SDNode *N) { Node = N; }
880ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif
881475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator==(const SDValue &O) const {
882ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node == O.Node && ResNo == O.ResNo;
88363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
884475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator!=(const SDValue &O) const {
88563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return !operator==(O);
88663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
887475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool operator<(const SDValue &O) const {
888ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node < O.Node || (Node == O.Node && ResNo < O.ResNo);
88963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
89063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
891475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDValue getValue(unsigned R) const {
892ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return SDValue(Node, R);
89363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
89463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
895917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  // isOperandOf - Return true if this node is an operand of N.
896917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isOperandOf(SDNode *N) const;
897bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng
89863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the ValueType of the referenced return value.
89963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
90083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  inline MVT getValueType() const;
901ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
90283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  /// getValueSizeInBits - Returns the size of the value in bits.
9034fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  ///
9044fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  unsigned getValueSizeInBits() const {
90583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands    return getValueType().getSizeInBits();
9064fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  }
9074fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman
90863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  // Forwarding methods - These forward to the corresponding methods in SDNode.
90963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getOpcode() const;
91063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getNumOperands() const;
911475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  inline const SDValue &getOperand(unsigned i) const;
912c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline uint64_t getConstantOperandVal(unsigned i) const;
9130f66a9172175aa7c3055333358170581c999219bNate Begeman  inline bool isTargetOpcode() const;
914e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  inline bool isMachineOpcode() const;
915e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  inline unsigned getMachineOpcode() const;
916124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen  inline const DebugLoc getDebugLoc() const;
917a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner
918572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner
919572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// reachesChainWithoutSideEffects - Return true if this operand (which must
920572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// be a chain) reaches the specified operand without crossing any
921572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// side-effecting instructions.  In practice, this looks through token
922572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// factors and non-volatile loads.  In order to remain efficient, this only
923572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner  /// looks a couple of nodes in, it does not do an exhaustive search.
924475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  bool reachesChainWithoutSideEffects(SDValue Dest,
925dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein                                      unsigned Depth = 2) const;
926572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner
9277a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  /// use_empty - Return true if there are no nodes using value ResNo
928ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// of Node.
9297a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
930e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman  inline bool use_empty() const;
9317a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
932231fe7054160d2953e0cc6635f9a171a4b311af2Gabor Greif  /// hasOneUse - Return true if there is exactly one node using value
933ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  /// ResNo of Node.
9347a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
9357a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  inline bool hasOneUse() const;
93663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
93763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
93863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
939475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct DenseMapInfo<SDValue> {
940475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static inline SDValue getEmptyKey() {
941475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return SDValue((SDNode*)-1, -1U);
942dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
943475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static inline SDValue getTombstoneKey() {
944475871a144eb604ddaf37503397ba0941442e5fbDan Gohman    return SDValue((SDNode*)-1, 0);
945dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
946475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static unsigned getHashValue(const SDValue &Val) {
947ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
948ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif            (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
949c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  }
950475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
95176c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner    return LHS == RHS;
95276c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner  }
953c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng  static bool isPod() { return true; }
954c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng};
955c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng
95663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on
957475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s.
958475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<SDValue> {
959dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  typedef SDNode* SimpleType;
960475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static SimpleType getSimplifiedValue(const SDValue &Val) {
961ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return static_cast<SimpleType>(Val.getNode());
962dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
963dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
964475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<const SDValue> {
965dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  typedef SDNode* SimpleType;
966475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  static SimpleType getSimplifiedValue(const SDValue &Val) {
967ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return static_cast<SimpleType>(Val.getNode());
968dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
969dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
970dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
971e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// SDUse - Represents a use of a SDNode. This class holds an SDValue,
972e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// which records the SDNode being used and the result number, a
973e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// pointer to the SDNode using the value, and Next and Prev pointers,
974e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// which link together all the uses of an SDNode.
975e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman///
9769cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDUse {
977e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// Val - The value being used.
978e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDValue Val;
979e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// User - The user of this value.
980e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDNode *User;
981e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// Prev, Next - Pointers to the uses list of the SDNode referred by
982dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// this operand.
9839cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse **Prev, *Next;
984dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
985e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDUse(const SDUse &U);          // Do not implement
986e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void operator=(const SDUse &U); // Do not implement
987dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
988e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanpublic:
989e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDUse() : Val(), User(NULL), Prev(NULL), Next(NULL) {}
990dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
991e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// Normally SDUse will just implicitly convert to an SDValue that it holds.
992e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  operator const SDValue&() const { return Val; }
993dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
994e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// If implicit conversion to SDValue doesn't work, the get() method returns
995e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// the SDValue.
996e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  const SDValue &get() const { return Val; }
997e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
998e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getUser - This returns the SDNode that contains this Use.
99902819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein  SDNode *getUser() { return User; }
10009cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1001e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getNext - Get the next SDUse in the use list.
1002e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDUse *getNext() const { return Next; }
10039cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1004e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getNode - Convenience function for get().getNode().
1005e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDNode *getNode() const { return Val.getNode(); }
1006e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getResNo - Convenience function for get().getResNo().
1007e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  unsigned getResNo() const { return Val.getResNo(); }
1008e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getValueType - Convenience function for get().getValueType().
1009e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  MVT getValueType() const { return Val.getValueType(); }
10109cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1011e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// operator== - Convenience function for get().operator==
1012e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  bool operator==(const SDValue &V) const {
1013e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return Val == V;
10149cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
1015e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1016e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// operator!= - Convenience function for get().operator!=
1017e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  bool operator!=(const SDValue &V) const {
1018e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return Val != V;
10199cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10209cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1021e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// operator< - Convenience function for get().operator<
1022e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  bool operator<(const SDValue &V) const {
1023e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return Val < V;
10249cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  }
10259cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein
1026e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanprivate:
1027e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  friend class SelectionDAG;
1028e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  friend class SDNode;
1029e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1030e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void setUser(SDNode *p) { User = p; }
1031e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1032e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// set - Remove this use from its existing use list, assign it the
1033e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// given value, and add it to the new value's node's use list.
1034e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  inline void set(const SDValue &V);
1035e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// setInitial - like set, but only supports initializing a newly-allocated
1036e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// SDUse with a non-null value.
1037e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  inline void setInitial(const SDValue &V);
1038e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// setNode - like set, but only sets the Node portion of the value,
1039e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// leaving the ResNo portion unmodified.
1040e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  inline void setNode(SDNode *N);
1041e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
10429cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  void addToList(SDUse **List) {
1043dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    Next = *List;
1044dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    if (Next) Next->Prev = &Next;
1045dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    Prev = List;
1046dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    *List = this;
1047dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1048dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1049dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  void removeFromList() {
1050dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    *Prev = Next;
1051dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    if (Next) Next->Prev = Prev;
1052dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1053dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein};
1054dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1055dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein/// simplify_type specializations - Allow casting operators to work directly on
1056475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s.
10579cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<SDUse> {
105863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
10599cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  static SimpleType getSimplifiedValue(const SDUse &Val) {
1060e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return static_cast<SimpleType>(Val.getNode());
106163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
106263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
10639cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<const SDUse> {
106463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
10659cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  static SimpleType getSimplifiedValue(const SDUse &Val) {
1066e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return static_cast<SimpleType>(Val.getNode());
106763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
106863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
106963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
107063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
107163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG.
107263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
1073fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass SDNode : public FoldingSetNode, public ilist_node<SDNode> {
1074dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprivate:
10750442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  /// NodeType - The operation that this node performs.
10760442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
1077e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  short NodeType;
107863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
107963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// OperandsNeedDelete - This is true if OperandList was new[]'d.  If true,
108063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// then they will be delete[]'d when the node is destroyed.
1081ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  unsigned short OperandsNeedDelete : 1;
10820442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
1083ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprotected:
1084ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// SubclassData - This member is defined by this class, but is not used for
1085ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// anything.  Subclasses can use it to hold whatever state they find useful.
1086ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// This field is initialized to zero by the ctor.
1087ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  unsigned short SubclassData : 15;
1088ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
1089ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprivate:
1090b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// NodeId - Unique id per SDNode in the DAG.
1091b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int NodeId;
10920442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
1093f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// OperandList - The values that are used by this operation.
10940442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
10959cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse *OperandList;
1096f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner
1097f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// ValueList - The types of the values this node defines.  SDNode's may
1098f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// define multiple values simultaneously.
109983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  const MVT *ValueList;
110063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1101e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// UseList - List of uses for this SDNode.
1102e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  SDUse *UseList;
1103dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
11048f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman  /// NumOperands/NumValues - The number of entries in the Operand/Value list.
11058f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman  unsigned short NumOperands, NumValues;
11068f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman
11078f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman  /// debugLoc - source line information.
11088f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman  DebugLoc debugLoc;
11098f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman
1110e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// getValueTypeList - Return a pointer to the specified value type.
1111e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  static const MVT *getValueTypeList(MVT VT);
1112e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1113e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  friend class SelectionDAG;
1114e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  friend struct ilist_traits<SDNode>;
1115dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
111663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
111763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
111863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //  Accessors
111963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //
1120e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1121e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// getOpcode - Return the SelectionDAG opcode value for this node. For
1122e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// pre-isel nodes (those for which isMachineOpcode returns false), these
1123e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// are the opcode values in the ISD and <target>ISD namespaces. For
1124e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// post-isel opcodes, see getMachineOpcode.
1125e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  unsigned getOpcode()  const { return (unsigned short)NodeType; }
1126e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1127e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// isTargetOpcode - Test if this node has a target-specific opcode (in the
1128e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// <target>ISD namespace).
11290f66a9172175aa7c3055333358170581c999219bNate Begeman  bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
1130e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1131e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// isMachineOpcode - Test if this node has a post-isel opcode, directly
1132e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// corresponding to a MachineInstr opcode.
1133e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  bool isMachineOpcode() const { return NodeType < 0; }
1134e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman
1135e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// getMachineOpcode - This may only be called if isMachineOpcode returns
1136e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// true. It returns the MachineInstr opcode value that the node's opcode
1137e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// corresponds to.
1138e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  unsigned getMachineOpcode() const {
1139ec89a364b86ccd943fc6cf3ad8f84825ba1550fdDan Gohman    assert(isMachineOpcode() && "Not a MachineInstr opcode!");
1140e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman    return ~NodeType;
11410f66a9172175aa7c3055333358170581c999219bNate Begeman  }
114263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
11436da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// use_empty - Return true if there are no uses of this node.
11447a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
1145e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  bool use_empty() const { return UseList == NULL; }
11467a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
11476da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// hasOneUse - Return true if there is exactly one use of this node.
11487a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
1149b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman  bool hasOneUse() const {
1150b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman    return !use_empty() && next(use_begin()) == use_end();
1151b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman  }
115263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
11536da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman  /// use_size - Return the number of uses of this node. This method takes
11547a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  /// time proportional to the number of uses.
11557a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  ///
11567a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman  size_t use_size() const { return std::distance(use_begin(), use_end()); }
11577a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman
1158b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// getNodeId - Return the unique node id.
1159b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  ///
1160b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int getNodeId() const { return NodeId; }
11610442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
11622e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng  /// setNodeId - Set unique node id.
11632e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng  void setNodeId(int Id) { NodeId = Id; }
11642e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng
11653b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  /// getDebugLoc - Return the source location info.
1166124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen  const DebugLoc getDebugLoc() const { return debugLoc; }
11673b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen
1168ab160cf371d6148d49b5401a903dd4ce381b2f8cDale Johannesen  /// setDebugLoc - Set source location info.  Try to avoid this, putting
1169ab160cf371d6148d49b5401a903dd4ce381b2f8cDale Johannesen  /// it in the constructor is preferable.
1170124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen  void setDebugLoc(const DebugLoc dl) { debugLoc = dl; }
11713b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen
11729cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  /// use_iterator - This class provides iterator support for SDUse
1173dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// operands that use a specific SDNode.
1174dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  class use_iterator
11759cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : public forward_iterator<SDUse, ptrdiff_t> {
11769cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    SDUse *Op;
11779cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    explicit use_iterator(SDUse *op) : Op(op) {
1178dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1179dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    friend class SDNode;
1180dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  public:
11819cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    typedef forward_iterator<SDUse, ptrdiff_t>::reference reference;
11829cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer;
1183dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1184dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator(const use_iterator &I) : Op(I.Op) {}
1185dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator() : Op(0) {}
1186dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1187dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool operator==(const use_iterator &x) const {
1188dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return Op == x.Op;
1189dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1190dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool operator!=(const use_iterator &x) const {
1191dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return !operator==(x);
1192dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1193dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1194dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    /// atEnd - return true if this iterator is at the end of uses list.
1195dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    bool atEnd() const { return Op == 0; }
1196dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1197dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    // Iterator traversal: forward iteration only.
1198dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator &operator++() {          // Preincrement
1199dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot increment end iterator!");
1200dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      Op = Op->getNext();
1201dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      return *this;
1202dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1203dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1204dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    use_iterator operator++(int) {        // Postincrement
1205dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      use_iterator tmp = *this; ++*this; return tmp;
1206dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1207dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
12088968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    /// Retrieve a pointer to the current user node.
12098968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDNode *operator*() const {
1210dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot dereference end iterator!");
12118968450305c28444edc3c272d8752a8db0c2f34aDan Gohman      return Op->getUser();
1212dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1213dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
12148968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDNode *operator->() const { return operator*(); }
12158968450305c28444edc3c272d8752a8db0c2f34aDan Gohman
12168968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    SDUse &getUse() const { return *Op; }
1217dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1218174f938bd042a19d1a840eef6ed162fc938e2fd9Duncan Sands    /// getOperandNo - Retrieve the operand # of this use in its user.
12198968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    ///
12208968450305c28444edc3c272d8752a8db0c2f34aDan Gohman    unsigned getOperandNo() const {
1221dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein      assert(Op && "Cannot dereference end iterator!");
12228968450305c28444edc3c272d8752a8db0c2f34aDan Gohman      return (unsigned)(Op - Op->getUser()->OperandList);
1223dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1224dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  };
1225dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1226dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// use_begin/use_end - Provide iteration support to walk over all uses
1227dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  /// of an SDNode.
1228dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1229dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  use_iterator use_begin() const {
1230e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return use_iterator(UseList);
1231dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  }
1232dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1233dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  static use_iterator use_end() { return use_iterator(0); }
1234dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
12357ece380440238ad0630a225b85a09a2dbed1165aChris Lattner
1236b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
1237b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// indicated value.  This method ignores uses of other values defined by this
1238b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// operation.
12394ee621125876cc954cba5280dd9395552755a871Evan Cheng  bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
12404ee621125876cc954cba5280dd9395552755a871Evan Cheng
124133d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  /// hasAnyUseOfValue - Return true if there are any use of the indicated
124233d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  /// value. This method ignores uses of other values defined by this operation.
124333d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng  bool hasAnyUseOfValue(unsigned Value) const;
124433d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng
12452a6299543fa22f389158409e897fe7099fda3812Dan Gohman  /// isOnlyUserOf - Return true if this node is the only use of N.
1246e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
12472a6299543fa22f389158409e897fe7099fda3812Dan Gohman  bool isOnlyUserOf(SDNode *N) const;
1248b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner
1249917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// isOperandOf - Return true if this node is an operand of N.
1250e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
1251917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isOperandOf(SDNode *N) const;
125280d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng
1253917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// isPredecessorOf - Return true if this node is a predecessor of N. This
1254917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// node is either an operand of N or it can be reached by recursively
1255917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  /// traversing up the operands.
1256e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// NOTE: this is an expensive method. Use it carefully.
1257917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng  bool isPredecessorOf(SDNode *N) const;
12587ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng
125963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumOperands - Return the number of values used by this operation.
126063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
1261f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumOperands() const { return NumOperands; }
126263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1263c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// getConstantOperandVal - Helper method returns the integer value of a
1264c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// ConstantSDNode operand.
1265c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  uint64_t getConstantOperandVal(unsigned Num) const;
1266c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1267475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOperand(unsigned Num) const {
1268f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(Num < NumOperands && "Invalid child # of SDNode!");
1269e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    return OperandList[Num];
127063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
1271c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
12729cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  typedef SDUse* op_iterator;
1273f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_begin() const { return OperandList; }
1274f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_end() const { return OperandList+NumOperands; }
127550f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner
12760b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  SDVTList getVTList() const {
12770b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    SDVTList X = { ValueList, NumValues };
12780b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    return X;
12790b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  };
1280d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman
1281d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  /// getFlaggedNode - If this node has a flag operand, return the node
1282d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  /// to which the flag operand points. Otherwise return NULL.
1283d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  SDNode *getFlaggedNode() const {
1284d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman    if (getNumOperands() != 0 &&
1285d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman        getOperand(getNumOperands()-1).getValueType() == MVT::Flag)
1286d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman      return getOperand(getNumOperands()-1).getNode();
1287d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman    return 0;
1288d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman  }
1289fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman
1290fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman  // If this is a pseudo op, like copyfromreg, look to see if there is a
1291fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman  // real target node flagged to it.  If so, return the target node.
1292fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman  const SDNode *getFlaggedMachineNode() const {
1293fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    const SDNode *FoundNode = this;
1294fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman
1295fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    // Climb up flag edges until a machine-opcode node is found, or the
1296fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    // end of the chain is reached.
1297fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    while (!FoundNode->isMachineOpcode()) {
1298fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman      const SDNode *N = FoundNode->getFlaggedNode();
1299fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman      if (!N) break;
1300fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman      FoundNode = N;
1301fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    }
1302fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman
1303fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman    return FoundNode;
1304fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman  }
1305fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman
130663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumValues - Return the number of values defined/returned by this
130763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operator.
130863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
1309f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumValues() const { return NumValues; }
131063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
131163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the type of a specified result.
131263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
131383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT getValueType(unsigned ResNo) const {
1314f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(ResNo < NumValues && "Illegal result number!");
1315f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    return ValueList[ResNo];
131663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
13179eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen
13184fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)).
13194fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  ///
13204fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  unsigned getValueSizeInBits(unsigned ResNo) const {
132183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands    return getValueType(ResNo).getSizeInBits();
13224fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman  }
13234fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman
132483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  typedef const MVT* value_iterator;
1325f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_begin() const { return ValueList; }
1326f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_end() const { return ValueList+NumValues; }
132763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
13286e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  /// getOperationName - Return the opcode of this operation for printing.
13296e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  ///
1330ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer  std::string getOperationName(const SelectionDAG *G = 0) const;
1331144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  static const char* getIndexedModeName(ISD::MemIndexedMode AM);
1332944fac71e082cc2664cc71b4d3f6c72bab7143fbChris Lattner  void print(raw_ostream &OS, const SelectionDAG *G = 0) const;
133363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  void dump() const;
1334efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner  void dump(const SelectionDAG *G) const;
133563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
133663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *) { return true; }
133763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1338583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  /// Profile - Gather unique data for the node.
1339583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  ///
1340b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman  void Profile(FoldingSetNodeID &ID) const;
1341583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey
1342e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// addUse - This method should only be used by the SDUse class.
1343109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  ///
1344e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void addUse(SDUse &U) { U.addToList(&UseList); }
1345e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1346e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanprotected:
134783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  static SDVTList getSDVTList(MVT VT) {
134863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    SDVTList Ret = { getValueTypeList(VT), 1 };
134963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    return Ret;
13502d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
135163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
13523b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  /// The constructors that supply DebugLoc explicitly should be preferred
13533b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  /// for new code.
1354475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps)
1355ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
13568f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      NodeId(-1),
1357e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      OperandList(NumOps ? new SDUse[NumOps] : 0),
1358e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      ValueList(VTs.VTs),
13598f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      UseList(NULL),
1360e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      NumOperands(NumOps), NumValues(VTs.NumVTs),
13618f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      debugLoc(DebugLoc::getUnknownLoc()) {
13629cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    for (unsigned i = 0; i != NumOps; ++i) {
13639cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein      OperandList[i].setUser(this);
1364e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      OperandList[i].setInitial(Ops[i]);
13659cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    }
1366f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  }
1367dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein
1368ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// This constructor adds no operands itself; operands can be
1369ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// set later with InitOperands.
1370dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein  SDNode(unsigned Opc, SDVTList VTs)
1371ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
13728f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      NodeId(-1), OperandList(0), ValueList(VTs.VTs), UseList(NULL),
13738f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      NumOperands(0), NumValues(VTs.NumVTs),
13748f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      debugLoc(DebugLoc::getUnknownLoc()) {}
13753b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen
13763b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  /// The next two constructors specify DebugLoc explicitly; the intent
13773b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  /// is that they will replace the above two over time, and eventually
13783b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  /// the ones above can be removed.
1379124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen  SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs, const SDValue *Ops,
1380124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen         unsigned NumOps)
13813b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen    : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
13828f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      NodeId(-1),
13833b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen      OperandList(NumOps ? new SDUse[NumOps] : 0),
13848f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      ValueList(VTs.VTs), UseList(NULL),
13853b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen      NumOperands(NumOps), NumValues(VTs.NumVTs),
13868f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      debugLoc(dl) {
13873b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen    for (unsigned i = 0; i != NumOps; ++i) {
13883b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen      OperandList[i].setUser(this);
13893b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen      OperandList[i].setInitial(Ops[i]);
13903b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen    }
13913b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  }
13923b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen
13933b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  /// This constructor adds no operands itself; operands can be
13943b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  /// set later with InitOperands.
1395124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen  SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs)
13963b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen    : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0),
13978f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      NodeId(-1), OperandList(0), ValueList(VTs.VTs), UseList(NULL),
13988f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      NumOperands(0), NumValues(VTs.NumVTs),
13998f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman      debugLoc(dl) {}
1400bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner
1401e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with 1 operand.
1402e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue &Op0) {
1403e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setUser(this);
1404e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setInitial(Op0);
1405e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = 1;
1406bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    OperandList = Ops;
1407e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  }
1408e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1409e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with 2 operands.
1410e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) {
1411e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setUser(this);
1412e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setInitial(Op0);
1413e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setUser(this);
1414e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setInitial(Op1);
1415e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = 2;
1416e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    OperandList = Ops;
1417e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  }
1418e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1419e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with 3 operands.
1420e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
1421e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman                    const SDValue &Op2) {
1422e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setUser(this);
1423e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setInitial(Op0);
1424e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setUser(this);
1425e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setInitial(Op1);
1426e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[2].setUser(this);
1427e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[2].setInitial(Op2);
1428e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = 3;
1429e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    OperandList = Ops;
1430e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  }
1431e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1432e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with 4 operands.
1433e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1,
1434e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman                    const SDValue &Op2, const SDValue &Op3) {
1435e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setUser(this);
1436e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[0].setInitial(Op0);
1437e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setUser(this);
1438e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[1].setInitial(Op1);
1439e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[2].setUser(this);
1440e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[2].setInitial(Op2);
1441e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[3].setUser(this);
1442e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    Ops[3].setInitial(Op3);
1443e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = 4;
1444e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    OperandList = Ops;
1445e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  }
1446e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1447e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  /// InitOperands - Initialize the operands list of this with N operands.
1448e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) {
1449e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    for (unsigned i = 0; i != N; ++i) {
1450e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      Ops[i].setUser(this);
1451e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman      Ops[i].setInitial(Vals[i]);
1452dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein    }
1453e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    NumOperands = N;
1454e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    OperandList = Ops;
1455bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
14560fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman
14570fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman  /// DropOperands - Release the operands and set this node to have
1458e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman  /// zero operands.
14590fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman  void DropOperands();
146063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
146163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
146263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1463475871a144eb604ddaf37503397ba0941442e5fbDan Gohman// Define inline functions from the SDValue class.
146463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1465475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getOpcode() const {
1466ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getOpcode();
146763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1468475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline MVT SDValue::getValueType() const {
1469ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getValueType(ResNo);
147063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1471475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getNumOperands() const {
1472ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getNumOperands();
147363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1474475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline const SDValue &SDValue::getOperand(unsigned i) const {
1475ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getOperand(i);
147663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
1477475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline uint64_t SDValue::getConstantOperandVal(unsigned i) const {
1478ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getConstantOperandVal(i);
1479c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
1480475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isTargetOpcode() const {
1481ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->isTargetOpcode();
14820f66a9172175aa7c3055333358170581c999219bNate Begeman}
1483475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isMachineOpcode() const {
1484ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->isMachineOpcode();
1485e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman}
1486475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getMachineOpcode() const {
1487ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->getMachineOpcode();
14880f66a9172175aa7c3055333358170581c999219bNate Begeman}
1489475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::use_empty() const {
1490ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return !Node->hasAnyUseOfValue(ResNo);
1491e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman}
1492475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::hasOneUse() const {
1493ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif  return Node->hasNUsesOfValue(1, ResNo);
14947a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman}
1495124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johanneseninline const DebugLoc SDValue::getDebugLoc() const {
14963b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen  return Node->getDebugLoc();
14973b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen}
149863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1499e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman// Define inline functions from the SDUse class.
1500e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1501e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::set(const SDValue &V) {
1502e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  if (Val.getNode()) removeFromList();
1503e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  Val = V;
1504e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  if (V.getNode()) V.getNode()->addUse(*this);
1505e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman}
1506e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1507e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::setInitial(const SDValue &V) {
1508e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  Val = V;
1509e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  V.getNode()->addUse(*this);
1510e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman}
1511e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
1512e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::setNode(SDNode *N) {
1513e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  if (Val.getNode()) removeFromList();
1514e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  Val.setNode(N);
1515e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  if (N) N->addUse(*this);
1516e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman}
1517e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman
15183f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes.  This is solely
15193f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
15203f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode {
15219cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Op;
15223f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1523475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X)
15249cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : SDNode(Opc, VTs) {
1525e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(&Op, X);
15263f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
15273edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  UnarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X)
15283edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : SDNode(Opc, dl, VTs) {
15293edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    InitOperands(&Op, X);
15303edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
15313f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
15323f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
15333f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes.  This is solely
15343f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
15353f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode {
15369cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[2];
15373f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1538475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y)
15393f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs) {
1540e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, X, Y);
15413f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
15423edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  BinarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X, SDValue Y)
15433edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : SDNode(Opc, dl, VTs) {
15443edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    InitOperands(Ops, X, Y);
15453edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
15463f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
15473f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
15483f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely
15493f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself.
15503f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode {
15519cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[3];
15523f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic:
1553475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y,
1554475871a144eb604ddaf37503397ba0941442e5fbDan Gohman                SDValue Z)
15553f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner    : SDNode(Opc, VTs) {
1556e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, X, Y, Z);
15573f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner  }
15583edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  TernarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X, SDValue Y,
15593edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen                SDValue Z)
15603edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : SDNode(Opc, dl, VTs) {
15613edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    InitOperands(Ops, X, Y, Z);
15623edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
15633f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner};
15643f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
15653f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner
1566d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that
1567d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its
1568d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand.  This node should be directly created by end-users and not added to
1569d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list.
1570d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode {
15719cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Op;
1572d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic:
1573ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling  // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is
1574ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling  // fixed.
157569cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#ifdef __GNUC__
1576475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  explicit __attribute__((__noinline__)) HandleSDNode(SDValue X)
157769cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#else
1578475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  explicit HandleSDNode(SDValue X)
157969cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#endif
15809cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein    : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) {
1581e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(&Op, X);
1582bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner  }
158348b85926524f9d29ae600123c90194cd73fd629eChris Lattner  ~HandleSDNode();
1584e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman  const SDValue &getValue() const { return Op; }
1585d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner};
1586d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner
158728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang/// Abstact virtual class for operations for memory operations
158828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass MemSDNode : public SDNode {
158928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangprivate:
15901ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  // MemoryVT - VT of in-memory value.
15911ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MVT MemoryVT;
15921ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
159328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  //! SrcValue - Memory location for alias analysis.
159428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  const Value *SrcValue;
159528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1596492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  //! SVOffset - Memory location offset. Note that base is defined in MemSDNode
1597492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  int SVOffset;
1598492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman
159928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangpublic:
16001ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT,
1601492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman            const Value *srcValue, int SVOff,
1602492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman            unsigned alignment, bool isvolatile);
160328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1604c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  MemSDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps,
1605c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang            MVT MemoryVT, const Value *srcValue, int SVOff,
1606c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang            unsigned alignment, bool isvolatile);
1607c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
16083edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  MemSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, MVT MemoryVT,
16093edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen            const Value *srcValue, int SVOff,
16103edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen            unsigned alignment, bool isvolatile);
16113edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen
16123edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  MemSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, const SDValue *Ops,
16133edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen            unsigned NumOps, MVT MemoryVT, const Value *srcValue, int SVOff,
16143edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen            unsigned alignment, bool isvolatile);
16153edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen
161628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// Returns alignment and volatility of the memory access
1617a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  unsigned getAlignment() const { return (1u << (SubclassData >> 6)) >> 1; }
1618a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  bool isVolatile() const { return (SubclassData >> 5) & 1; }
161928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1620a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  /// getRawSubclassData - Return the SubclassData value, which contains an
1621a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  /// encoding of the alignment and volatile information, as well as bits
1622a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  /// used by subclasses. This function should only be used to compute a
1623a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  /// FoldingSetNodeID value.
1624a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  unsigned getRawSubclassData() const {
1625a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    return SubclassData;
1626a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  }
1627a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman
162828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// Returns the SrcValue and offset that describes the location of the access
162928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  const Value *getSrcValue() const { return SrcValue; }
1630492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman  int getSrcValueOffset() const { return SVOffset; }
163128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
16321ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  /// getMemoryVT - Return the type of the in-memory value.
16331ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MVT getMemoryVT() const { return MemoryVT; }
16341ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
163528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// getMemOperand - Return a MachineMemOperand object describing the memory
163628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  /// reference performed by operation.
16371ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  MachineMemOperand getMemOperand() const;
16381ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman
1639475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getChain() const { return getOperand(0); }
1640475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const {
16411ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman    return getOperand(getOpcode() == ISD::STORE ? 2 : 1);
16421ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman  }
164328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
164428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Methods to support isa and dyn_cast
164528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const MemSDNode *) { return true; }
164628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const SDNode *N) {
1647c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // For some targets, we lower some target intrinsics to a MemIntrinsicNode
1648c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // with either an intrinsic or a target opcode.
1649e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    return N->getOpcode() == ISD::LOAD                ||
1650e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen           N->getOpcode() == ISD::STORE               ||
16510b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_CMP_SWAP     ||
16520b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_SWAP         ||
16530b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_ADD     ||
16540b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_SUB     ||
16550b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_AND     ||
16560b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_OR      ||
16570b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_XOR     ||
16580b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_NAND    ||
16590b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_MIN     ||
16600b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_MAX     ||
16610b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN    ||
16620b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX    ||
1663c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_W_CHAIN   ||
1664c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_VOID      ||
1665c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->isTargetOpcode();
166628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  }
166728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang};
166828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1669c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// AtomicSDNode - A SDNode reprenting atomic operations.
1670c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang///
167128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass AtomicSDNode : public MemSDNode {
16729cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[4];
167328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1674c53361294957b63a9c1e405256c6f0a81db1685cDan Gohmanpublic:
167528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Opc:   opcode for atomic
167628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // VTL:    value type list
167728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Chain:  memory chain for operaand
1678475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  // Ptr:    address to update as a SDValue
167928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Cmp:    compare value
168028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Swp:    swap value
168128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // SrcVal: address to update as a Value (used for MemOperand)
168228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Align:  alignment of memory
16830b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman  AtomicSDNode(unsigned Opc, SDVTList VTL, MVT MemVT,
16840b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman               SDValue Chain, SDValue Ptr,
1685475871a144eb604ddaf37503397ba0941442e5fbDan Gohman               SDValue Cmp, SDValue Swp, const Value* SrcVal,
168628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang               unsigned Align=0)
16870b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    : MemSDNode(Opc, VTL, MemVT, SrcVal, /*SVOffset=*/0,
1688492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman                Align, /*isVolatile=*/true) {
1689e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, Chain, Ptr, Cmp, Swp);
1690ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth  }
16910b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman  AtomicSDNode(unsigned Opc, SDVTList VTL, MVT MemVT,
16920b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman               SDValue Chain, SDValue Ptr,
1693475871a144eb604ddaf37503397ba0941442e5fbDan Gohman               SDValue Val, const Value* SrcVal, unsigned Align=0)
16940b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    : MemSDNode(Opc, VTL, MemVT, SrcVal, /*SVOffset=*/0,
1695492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman                Align, /*isVolatile=*/true) {
1696e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(Ops, Chain, Ptr, Val);
1697ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth  }
16983edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  AtomicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTL, MVT MemVT,
16993edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen               SDValue Chain, SDValue Ptr,
17003edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen               SDValue Cmp, SDValue Swp, const Value* SrcVal,
17013edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen               unsigned Align=0)
17023edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : MemSDNode(Opc, dl, VTL, MemVT, SrcVal, /*SVOffset=*/0,
17033edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen                Align, /*isVolatile=*/true) {
17043edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    InitOperands(Ops, Chain, Ptr, Cmp, Swp);
17053edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
17063edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  AtomicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTL, MVT MemVT,
17073edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen               SDValue Chain, SDValue Ptr,
17083edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen               SDValue Val, const Value* SrcVal, unsigned Align=0)
17093edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : MemSDNode(Opc, dl, VTL, MemVT, SrcVal, /*SVOffset=*/0,
17103edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen                Align, /*isVolatile=*/true) {
17113edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    InitOperands(Ops, Chain, Ptr, Val);
17123edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
171328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1714475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(1); }
1715475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getVal() const { return getOperand(2); }
171628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
1717e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen  bool isCompareAndSwap() const {
1718e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen    unsigned Op = getOpcode();
17190b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    return Op == ISD::ATOMIC_CMP_SWAP;
1720e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen  }
172128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang
172228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  // Methods to support isa and dyn_cast
172328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const AtomicSDNode *) { return true; }
172428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  static bool classof(const SDNode *N) {
17250b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman    return N->getOpcode() == ISD::ATOMIC_CMP_SWAP     ||
17260b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_SWAP         ||
17270b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_ADD     ||
17280b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_SUB     ||
17290b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_AND     ||
17300b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_OR      ||
17310b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_XOR     ||
17320b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_NAND    ||
17330b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_MIN     ||
17340b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_MAX     ||
17350b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_UMIN    ||
17360b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman           N->getOpcode() == ISD::ATOMIC_LOAD_UMAX;
173728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang  }
1738ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth};
1739ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth
1740c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// MemIntrinsicSDNode - This SDNode is used for target intrinsic that touches
1741c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// memory and need an associated memory operand.
1742c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang///
1743c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wangclass MemIntrinsicSDNode : public MemSDNode {
1744c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool ReadMem;  // Intrinsic reads memory
1745c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool WriteMem; // Intrinsic writes memory
17463dbc4e350216e197e3014452400f43899f7ad620Dan Gohmanpublic:
1747c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  MemIntrinsicSDNode(unsigned Opc, SDVTList VTs,
1748c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     const SDValue *Ops, unsigned NumOps,
1749c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     MVT MemoryVT, const Value *srcValue, int SVO,
1750c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang                     unsigned Align, bool Vol, bool ReadMem, bool WriteMem)
1751c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    : MemSDNode(Opc, VTs, Ops, NumOps, MemoryVT, srcValue, SVO, Align, Vol),
1752c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang      ReadMem(ReadMem), WriteMem(WriteMem) {
1753c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  }
17543edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  MemIntrinsicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs,
17553edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen                     const SDValue *Ops, unsigned NumOps,
17563edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen                     MVT MemoryVT, const Value *srcValue, int SVO,
17573edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen                     unsigned Align, bool Vol, bool ReadMem, bool WriteMem)
17583edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : MemSDNode(Opc, dl, VTs, Ops, NumOps, MemoryVT, srcValue, SVO, Align, Vol),
17593edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen      ReadMem(ReadMem), WriteMem(WriteMem) {
17603edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
1761c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
1762c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool readMem() const { return ReadMem; }
1763c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  bool writeMem() const { return WriteMem; }
1764c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
1765c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  // Methods to support isa and dyn_cast
1766c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  static bool classof(const MemIntrinsicSDNode *) { return true; }
1767c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  static bool classof(const SDNode *N) {
1768c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // We lower some target intrinsics to their target opcode
1769c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    // early a node with a target opcode can be of this class
1770c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang    return N->getOpcode() == ISD::INTRINSIC_W_CHAIN ||
1771c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->getOpcode() == ISD::INTRINSIC_VOID ||
1772c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang           N->isTargetOpcode();
1773c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang  }
1774c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang};
1775c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang
177663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode {
17774fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantInt *Value;
177863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
177963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
17804fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT)
1781bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)),
1782bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      Value(val) {
178363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
178463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
178563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
17864fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantInt *getConstantIntValue() const { return Value; }
17874fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const APInt &getAPIntValue() const { return Value->getValue(); }
17884fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  uint64_t getZExtValue() const { return Value->getZExtValue(); }
17897810bfed5570c192e0714a8fd0e5130a0c38dd2eDan Gohman  int64_t getSExtValue() const { return Value->getSExtValue(); }
179063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
17914fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  bool isNullValue() const { return Value->isNullValue(); }
17924fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  bool isAllOnesValue() const { return Value->isAllOnesValue(); }
179363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
179463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantSDNode *) { return true; }
179563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1796056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    return N->getOpcode() == ISD::Constant ||
1797056f9f61d071c6c583951678f2bf543a1316efccChris Lattner           N->getOpcode() == ISD::TargetConstant;
179863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
179963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
180063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
180163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode {
18024fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantFP *Value;
180363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
180463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
18054fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT)
180687503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP,
180787503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen             getSDVTList(VT)), Value(val) {
180863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
180963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
181063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
18114fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const APFloat& getValueAPF() const { return Value->getValueAPF(); }
18124fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman  const ConstantFP *getConstantFPValue() const { return Value; }
181363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
181463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isExactlyValue - We don't rely on operator== working on double values, as
181563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
181663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// As such, this method can be used to do an exact bit-for-bit comparison of
181763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// two floating point values.
1818c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen
1819c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// We leave the version with the double argument here because it's just so
1820c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// convenient to write "2.0" and the like.  Without this function we'd
1821c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen  /// have to duplicate its logic everywhere it's called.
18229dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen  bool isExactlyValue(double V) const {
182323a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen    bool ignored;
18249dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen    // convert is not supported on this type
18254fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman    if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble)
18269dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen      return false;
182784cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner    APFloat Tmp(V);
18284fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman    Tmp.convert(Value->getValueAPF().getSemantics(),
182923a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen                APFloat::rmNearestTiesToEven, &ignored);
183084cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner    return isExactlyValue(Tmp);
183187503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen  }
1832e6c1742914149d44360fbf05a653041a672282afDale Johannesen  bool isExactlyValue(const APFloat& V) const;
183363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
183483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  bool isValueValidForType(MVT VT, const APFloat& Val);
1835f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen
183663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantFPSDNode *) { return true; }
183763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1838ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    return N->getOpcode() == ISD::ConstantFP ||
1839ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner           N->getOpcode() == ISD::TargetConstantFP;
184063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
184163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
184263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
184363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode {
184463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *TheGlobal;
18456520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  int64_t Offset;
184663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
184763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
18486520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT,
18496520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman                      int64_t o = 0);
185063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
185163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
185263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *getGlobal() const { return TheGlobal; }
18536520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman  int64_t getOffset() const { return Offset; }
185463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
185563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const GlobalAddressSDNode *) { return true; }
185663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1857f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    return N->getOpcode() == ISD::GlobalAddress ||
1858b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::TargetGlobalAddress ||
1859b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::GlobalTLSAddress ||
1860b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio           N->getOpcode() == ISD::TargetGlobalTLSAddress;
186163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
186263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
186363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
186463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode {
186563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int FI;
186663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
186763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
186883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  FrameIndexSDNode(int fi, MVT VT, bool isTarg)
1869bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)),
1870bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      FI(fi) {
187163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
187263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
187363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
187463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int getIndex() const { return FI; }
187563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
187663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const FrameIndexSDNode *) { return true; }
187763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1878afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    return N->getOpcode() == ISD::FrameIndex ||
1879afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner           N->getOpcode() == ISD::TargetFrameIndex;
188063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
188163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
188263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
188337efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode {
188437efe6764568a3829fee26aba532283131d1a104Nate Begeman  int JTI;
188537efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected:
188637efe6764568a3829fee26aba532283131d1a104Nate Begeman  friend class SelectionDAG;
188783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  JumpTableSDNode(int jti, MVT VT, bool isTarg)
1888bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)),
1889bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner      JTI(jti) {
189063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
189137efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic:
189237efe6764568a3829fee26aba532283131d1a104Nate Begeman
189359a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner  int getIndex() const { return JTI; }
189437efe6764568a3829fee26aba532283131d1a104Nate Begeman
189537efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const JumpTableSDNode *) { return true; }
189637efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const SDNode *N) {
189737efe6764568a3829fee26aba532283131d1a104Nate Begeman    return N->getOpcode() == ISD::JumpTable ||
189837efe6764568a3829fee26aba532283131d1a104Nate Begeman           N->getOpcode() == ISD::TargetJumpTable;
189937efe6764568a3829fee26aba532283131d1a104Nate Begeman  }
190037efe6764568a3829fee26aba532283131d1a104Nate Begeman};
190137efe6764568a3829fee26aba532283131d1a104Nate Begeman
190263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode {
1903d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  union {
1904d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Constant *ConstVal;
1905d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    MachineConstantPoolValue *MachineCPVal;
1906d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  } Val;
1907baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1908b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned Alignment;
190963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
191063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
191183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0)
1912ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1913bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(0) {
1914d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1915d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1916d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
191783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align)
1918ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1919bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(Align) {
1920d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1921d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1922d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1923d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
192483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands                     MVT VT, int o=0)
1925ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1926bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(0) {
1927d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1928d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1929d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1930d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1931d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
193283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands                     MVT VT, int o, unsigned Align)
1933ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool,
1934bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner             getSDVTList(VT)), Offset(o), Alignment(Align) {
1935d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
1936d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1937d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1938d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
193963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
194063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1941d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  bool isMachineConstantPoolEntry() const {
1942d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return (int)Offset < 0;
1943d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1944d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1945d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  Constant *getConstVal() const {
1946d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1947d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.ConstVal;
1948d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1949d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1950d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  MachineConstantPoolValue *getMachineCPVal() const {
1951d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1952d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.MachineCPVal;
1953d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1954d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1955baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int getOffset() const {
1956baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng    return Offset & ~(1 << (sizeof(unsigned)*8-1));
1957baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  }
1958ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner
1959ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // Return the alignment of this constant pool object, which is either 0 (for
1960ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // default alignment) or log2 of the desired value.
1961b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned getAlignment() const { return Alignment; }
196263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1963d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  const Type *getType() const;
1964d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
196563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantPoolSDNode *) { return true; }
196663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1967aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    return N->getOpcode() == ISD::ConstantPool ||
1968aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner           N->getOpcode() == ISD::TargetConstantPool;
196963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
197063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
197163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
197263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode {
197363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *MBB;
197463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
197563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1976423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit BasicBlockSDNode(MachineBasicBlock *mbb)
1977bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) {
197863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
19793edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  explicit BasicBlockSDNode(MachineBasicBlock *mbb, DebugLoc dl)
19803edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : SDNode(ISD::BasicBlock, dl, getSDVTList(MVT::Other)), MBB(mbb) {
19813edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
198263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
198363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
198463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *getBasicBlock() const { return MBB; }
198563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
198663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const BasicBlockSDNode *) { return true; }
198763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
198863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return N->getOpcode() == ISD::BasicBlock;
198963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
199063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
199163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
199214471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is
199314471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// used when the SelectionDAG needs to make a simple reference to something
199414471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// in the LLVM IR representation.
199514471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman///
199614471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// Note that this is not used for carrying alias information; that is done
199714471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// with MemOperandSDNode, which includes a Value which is required to be a
199814471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// pointer, and several other fields specific to memory references.
199914471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman///
20002d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode {
20012d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *V;
20022d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected:
20032d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  friend class SelectionDAG;
200469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  /// Create a SrcValue for a general value.
200569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  explicit SrcValueSDNode(const Value *v)
200669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {}
20072d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
20082d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic:
200969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  /// getValue - return the contained Value.
20102d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *getValue() const { return V; }
20112d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
20122d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SrcValueSDNode *) { return true; }
20132d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SDNode *N) {
20142d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth    return N->getOpcode() == ISD::SRCVALUE;
20152d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
20162d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth};
20172d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
201863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
201936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is
202069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// used to represent a reference to memory after ISD::LOAD
202169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// and ISD::STORE have been lowered.
202269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman///
202369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanclass MemOperandSDNode : public SDNode {
202469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanprotected:
202569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  friend class SelectionDAG;
202636b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  /// Create a MachineMemOperand node
202736b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  explicit MemOperandSDNode(const MachineMemOperand &mo)
202869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {}
202969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
203069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanpublic:
203136b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  /// MO - The contained MachineMemOperand.
203236b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman  const MachineMemOperand MO;
203369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
203469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  static bool classof(const MemOperandSDNode *) { return true; }
203569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  static bool classof(const SDNode *N) {
203669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman    return N->getOpcode() == ISD::MEMOPERAND;
203769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman  }
203869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman};
203969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
204069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman
2041d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode {
204263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned Reg;
204363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
204463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
204583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  RegisterSDNode(unsigned reg, MVT VT)
2046bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) {
204763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
204863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
204963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
205063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned getReg() const { return Reg; }
205163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
2052d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner  static bool classof(const RegisterSDNode *) { return true; }
205363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
2054d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    return N->getOpcode() == ISD::Register;
205563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
205663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
205763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
20587f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanclass DbgStopPointSDNode : public SDNode {
20597f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  SDUse Chain;
20607f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned Line;
20617f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned Column;
206283489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel  Value *CU;
20637f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanprotected:
20647f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  friend class SelectionDAG;
2065475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c,
206683489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel                     Value *cu)
20677f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)),
20687f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman      Line(l), Column(c), CU(cu) {
2069e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(&Chain, ch);
20707f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  }
20717f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanpublic:
20727f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned getLine() const { return Line; }
20737f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  unsigned getColumn() const { return Column; }
207483489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel  Value *getCompileUnit() const { return CU; }
20757f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman
20767f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  static bool classof(const DbgStopPointSDNode *) { return true; }
20777f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  static bool classof(const SDNode *N) {
20787f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman    return N->getOpcode() == ISD::DBG_STOPPOINT;
20797f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman  }
20807f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman};
20817f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman
20824406604047423576e36657c7ede266ca42e79642Dan Gohmanclass LabelSDNode : public SDNode {
20834406604047423576e36657c7ede266ca42e79642Dan Gohman  SDUse Chain;
20844406604047423576e36657c7ede266ca42e79642Dan Gohman  unsigned LabelID;
20854406604047423576e36657c7ede266ca42e79642Dan Gohmanprotected:
20864406604047423576e36657c7ede266ca42e79642Dan Gohman  friend class SelectionDAG;
2087475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id)
20884406604047423576e36657c7ede266ca42e79642Dan Gohman    : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) {
2089e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman    InitOperands(&Chain, ch);
20904406604047423576e36657c7ede266ca42e79642Dan Gohman  }
20913edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  LabelSDNode(unsigned NodeTy, DebugLoc dl, SDValue ch, unsigned id)
20923edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : SDNode(NodeTy, dl, getSDVTList(MVT::Other)), LabelID(id) {
20933edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    InitOperands(&Chain, ch);
20943edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
20954406604047423576e36657c7ede266ca42e79642Dan Gohmanpublic:
20964406604047423576e36657c7ede266ca42e79642Dan Gohman  unsigned getLabelID() const { return LabelID; }
20974406604047423576e36657c7ede266ca42e79642Dan Gohman
20984406604047423576e36657c7ede266ca42e79642Dan Gohman  static bool classof(const LabelSDNode *) { return true; }
20994406604047423576e36657c7ede266ca42e79642Dan Gohman  static bool classof(const SDNode *N) {
21004406604047423576e36657c7ede266ca42e79642Dan Gohman    return N->getOpcode() == ISD::DBG_LABEL ||
21014406604047423576e36657c7ede266ca42e79642Dan Gohman           N->getOpcode() == ISD::EH_LABEL;
21024406604047423576e36657c7ede266ca42e79642Dan Gohman  }
21034406604047423576e36657c7ede266ca42e79642Dan Gohman};
21044406604047423576e36657c7ede266ca42e79642Dan Gohman
2105056292fd738924f3f7703725d8f630983794b5a5Bill Wendlingclass ExternalSymbolSDNode : public SDNode {
210663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *Symbol;
210763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
210863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
2109056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT)
2110056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol,
2111056292fd738924f3f7703725d8f630983794b5a5Bill Wendling             getSDVTList(VT)), Symbol(Sym) {
2112056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  }
21133edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  ExternalSymbolSDNode(bool isTarget, DebugLoc dl, const char *Sym, MVT VT)
21143edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, dl,
21153edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen             getSDVTList(VT)), Symbol(Sym) {
21163edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
211763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
2118056292fd738924f3f7703725d8f630983794b5a5Bill Wendling
211963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *getSymbol() const { return Symbol; }
212063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
2121056292fd738924f3f7703725d8f630983794b5a5Bill Wendling  static bool classof(const ExternalSymbolSDNode *) { return true; }
212263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
2123056292fd738924f3f7703725d8f630983794b5a5Bill Wendling    return N->getOpcode() == ISD::ExternalSymbol ||
2124056292fd738924f3f7703725d8f630983794b5a5Bill Wendling           N->getOpcode() == ISD::TargetExternalSymbol;
212563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
212663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
212763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
21287cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode {
212963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ISD::CondCode Condition;
213063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
213163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
2132423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman  explicit CondCodeSDNode(ISD::CondCode Cond)
2133bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) {
213463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
213563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
213663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
21377cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  ISD::CondCode get() const { return Condition; }
213863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
21397cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  static bool classof(const CondCodeSDNode *) { return true; }
214063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
21417cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    return N->getOpcode() == ISD::CONDCODE;
214263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
214363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
214463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
214577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the
214677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// future and most targets don't support it.
214777cdf30742284a173fe818417eb482224cdee8d4Mon P Wangclass CvtRndSatSDNode : public SDNode {
214877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  ISD::CvtCode CvtCode;
214977cdf30742284a173fe818417eb482224cdee8d4Mon P Wangprotected:
215077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  friend class SelectionDAG;
215177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  explicit CvtRndSatSDNode(MVT VT, const SDValue *Ops, unsigned NumOps,
215277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang                           ISD::CvtCode Code)
215377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    : SDNode(ISD::CONVERT_RNDSAT, getSDVTList(VT), Ops, NumOps), CvtCode(Code) {
215477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    assert(NumOps == 5 && "wrong number of operations");
215577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  }
215677cdf30742284a173fe818417eb482224cdee8d4Mon P Wangpublic:
215777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  ISD::CvtCode getCvtCode() const { return CvtCode; }
215877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
215977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  static bool classof(const CvtRndSatSDNode *) { return true; }
216077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  static bool classof(const SDNode *N) {
216177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang    return N->getOpcode() == ISD::CONVERT_RNDSAT;
216277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang  }
216377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang};
216477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang
2165276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsnamespace ISD {
2166276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  struct ArgFlagsTy {
2167276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  private:
2168276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t NoFlagSet      = 0ULL;
2169276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ZExt           = 1ULL<<0;  ///< Zero extended
2170276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ZExtOffs       = 0;
2171276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SExt           = 1ULL<<1;  ///< Sign extended
2172276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SExtOffs       = 1;
2173276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t InReg          = 1ULL<<2;  ///< Passed in register
2174276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t InRegOffs      = 2;
2175276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SRet           = 1ULL<<3;  ///< Hidden struct-ret ptr
2176276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t SRetOffs       = 3;
2177276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByVal          = 1ULL<<4;  ///< Struct passed by value
2178276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValOffs      = 4;
2179276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t Nest           = 1ULL<<5;  ///< Nested fn static chain
2180276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t NestOffs       = 5;
2181276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValAlign     = 0xFULL << 6; //< Struct alignment
2182276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValAlignOffs = 6;
21836ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    static const uint64_t Split          = 1ULL << 10;
21846ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    static const uint64_t SplitOffs      = 10;
2185276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t OrigAlign      = 0x1FULL<<27;
2186276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t OrigAlignOffs  = 27;
2187276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValSize      = 0xffffffffULL << 32; //< Struct size
2188276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t ByValSizeOffs  = 32;
2189276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2190276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    static const uint64_t One            = 1ULL; //< 1 of this type, for shifts
2191276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2192276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    uint64_t Flags;
2193276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  public:
2194276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    ArgFlagsTy() : Flags(0) { }
2195276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2196276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isZExt()   const { return Flags & ZExt; }
2197276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setZExt()  { Flags |= One << ZExtOffs; }
2198276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2199276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isSExt()   const { return Flags & SExt; }
2200276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setSExt()  { Flags |= One << SExtOffs; }
2201276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2202276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isInReg()  const { return Flags & InReg; }
2203276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setInReg() { Flags |= One << InRegOffs; }
2204276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2205276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isSRet()   const { return Flags & SRet; }
2206276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setSRet()  { Flags |= One << SRetOffs; }
2207276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2208276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isByVal()  const { return Flags & ByVal; }
2209276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByVal() { Flags |= One << ByValOffs; }
2210276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2211276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    bool isNest()   const { return Flags & Nest; }
2212276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setNest()  { Flags |= One << NestOffs; }
2213276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2214276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getByValAlign() const {
221594bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)
221694bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen        ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
2217276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2218276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByValAlign(unsigned A) {
2219276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~ByValAlign) |
2220276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands        (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
2221276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2222c0cb28fd3abee9a8b40856990e04f1af2f9bd7b8Nicolas Geoffray
22236ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    bool isSplit()   const { return Flags & Split; }
22246ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray    void setSplit()  { Flags |= One << SplitOffs; }
2225276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2226276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getOrigAlign() const {
222794bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)
222894bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen        ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
2229276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2230276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setOrigAlign(unsigned A) {
2231276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~OrigAlign) |
2232276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands        (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
2233276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2234276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2235276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    unsigned getByValSize() const {
223694bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen      return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
2237276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2238276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    void setByValSize(unsigned S) {
2239276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands      Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
2240276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    }
2241276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2242276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
2243276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    std::string getArgFlagsString();
2244276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2245276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    /// getRawBits - Represent the flags as a bunch of bits.
2246276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    uint64_t getRawBits() const { return Flags; }
2247276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  };
2248276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands}
2249276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2250276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands/// ARG_FLAGSSDNode - Leaf node holding parameter flags.
2251276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsclass ARG_FLAGSSDNode : public SDNode {
2252276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ISD::ArgFlagsTy TheFlags;
2253276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsprotected:
2254276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  friend class SelectionDAG;
2255276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags)
2256276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) {
2257276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  }
2258276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandspublic:
2259276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  ISD::ArgFlagsTy getArgFlags() const { return TheFlags; }
2260276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2261276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  static bool classof(const ARG_FLAGSSDNode *) { return true; }
2262276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  static bool classof(const SDNode *N) {
2263276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands    return N->getOpcode() == ISD::ARG_FLAGS;
2264276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands  }
2265276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands};
2266276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands
2267095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman/// CallSDNode - Node for calls -- ISD::CALL.
2268095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanclass CallSDNode : public SDNode {
2269095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned CallingConv;
2270095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  bool IsVarArg;
2271095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  bool IsTailCall;
227286098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // We might eventually want a full-blown Attributes for the result; that
227386098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // will expand the size of the representation.  At the moment we only
227486098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  // need Inreg.
227586098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  bool Inreg;
2276095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanprotected:
2277095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  friend class SelectionDAG;
227886098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  CallSDNode(unsigned cc, bool isvararg, bool istailcall, bool isinreg,
2279095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman             SDVTList VTs, const SDValue *Operands, unsigned numOperands)
2280095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    : SDNode(ISD::CALL, VTs, Operands, numOperands),
228186098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen      CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall),
228286098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen      Inreg(isinreg) {}
22833edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  CallSDNode(unsigned cc, DebugLoc dl, bool isvararg, bool istailcall,
22843edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen             bool isinreg, SDVTList VTs, const SDValue *Operands,
22853edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen             unsigned numOperands)
22863edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : SDNode(ISD::CALL, dl, VTs, Operands, numOperands),
22873edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen      CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall),
22883edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen      Inreg(isinreg) {}
2289095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanpublic:
2290095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getCallingConv() const { return CallingConv; }
2291095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned isVarArg() const { return IsVarArg; }
2292095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned isTailCall() const { return IsTailCall; }
229386098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen  unsigned isInreg() const { return Inreg; }
2294095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2295095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  /// Set this call to not be marked as a tail call. Normally setter
2296095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  /// methods in SDNodes are unsafe because it breaks the CSE map,
22975eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman  /// but we don't include the tail call flag for calls so it's ok
22985eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman  /// in this case.
2299095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  void setNotTailCall() { IsTailCall = false; }
2300095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2301095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getChain() const { return getOperand(0); }
2302095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getCallee() const { return getOperand(1); }
2303095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2304095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getNumArgs() const { return (getNumOperands() - 2) / 2; }
2305095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getArg(unsigned i) const { return getOperand(2+2*i); }
2306095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  SDValue getArgFlagsVal(unsigned i) const {
2307095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return getOperand(3+2*i);
2308095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2309095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  ISD::ArgFlagsTy getArgFlags(unsigned i) const {
2310095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return cast<ARG_FLAGSSDNode>(getArgFlagsVal(i).getNode())->getArgFlags();
2311095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2312095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2313095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  unsigned getNumRetVals() const { return getNumValues() - 1; }
2314095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  MVT getRetValType(unsigned i) const { return getValueType(i); }
2315095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
2316095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  static bool classof(const CallSDNode *) { return true; }
2317095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  static bool classof(const SDNode *N) {
2318095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman    return N->getOpcode() == ISD::CALL;
2319095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman  }
2320095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman};
2321095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman
232283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands/// VTSDNode - This class is used to represent MVT's, which are used
232315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations.
232415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode {
232583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT ValueType;
232615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected:
232715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  friend class SelectionDAG;
232883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  explicit VTSDNode(MVT VT)
2329bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner    : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) {
233063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
233115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic:
233215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
233383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands  MVT getVT() const { return ValueType; }
233415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
233515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const VTSDNode *) { return true; }
233615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const SDNode *N) {
233715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    return N->getOpcode() == ISD::VALUETYPE;
233815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  }
233915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner};
234015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
23419de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode
23429de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel///
234328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass LSBaseSDNode : public MemSDNode {
23449de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprotected:
23459de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel  //! Operand array for load and store
23469de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel  /*!
23479de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    \note Moving this array to the base class captures more
23489de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    common functionality shared between LoadSDNode and
23499de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel    StoreSDNode
23509de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel   */
23519cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein  SDUse Ops[4];
23529de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic:
2353475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LSBaseSDNode(ISD::NodeType NodeTy, SDValue *Operands, unsigned numOperands,
235483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands               SDVTList VTs, ISD::MemIndexedMode AM, MVT VT,
2355b625f2f8960de32bc973092aaee8ac62863006feDan Gohman               const Value *SV, int SVO, unsigned Align, bool Vol)
2356ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman    : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol) {
2357b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    assert(Align != 0 && "Loads and stores should have non-zero aligment");
2358a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    SubclassData |= AM << 2;
2359a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    assert(getAddressingMode() == AM && "MemIndexedMode encoding error!");
2360a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    InitOperands(Ops, Operands, numOperands);
2361437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman    assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
2362437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman           "Only indexed loads and stores have a non-undef offset operand");
2363b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  }
23643edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  LSBaseSDNode(ISD::NodeType NodeTy, DebugLoc dl, SDValue *Operands,
23653edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen               unsigned numOperands, SDVTList VTs, ISD::MemIndexedMode AM,
23663edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen               MVT VT, const Value *SV, int SVO, unsigned Align, bool Vol)
23673edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : MemSDNode(NodeTy, dl, VTs, VT, SV, SVO, Align, Vol) {
23683edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    assert(Align != 0 && "Loads and stores should have non-zero aligment");
2369a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    SubclassData |= AM << 2;
2370a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    assert(getAddressingMode() == AM && "MemIndexedMode encoding error!");
2371a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    InitOperands(Ops, Operands, numOperands);
23723edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) &&
23733edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen           "Only indexed loads and stores have a non-undef offset operand");
23743edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
23759de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
2376475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const {
237763602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner    return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
237863602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner  }
23799de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
2380ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// getAddressingMode - Return the addressing mode for this load or store:
2381ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2382ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  ISD::MemIndexedMode getAddressingMode() const {
2383a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    return ISD::MemIndexedMode((SubclassData >> 2) & 7);
2384ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
2385b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
2386b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  /// isIndexed - Return true if this is a pre/post inc/dec load/store.
2387ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2388b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
2389b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store.
2390ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2391b625f2f8960de32bc973092aaee8ac62863006feDan Gohman
239213d57320bd212483463d4f8992d5787b29eda5dfBill Wendling  static bool classof(const LSBaseSDNode *) { return true; }
2393b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  static bool classof(const SDNode *N) {
2394b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    return N->getOpcode() == ISD::LOAD ||
2395b625f2f8960de32bc973092aaee8ac62863006feDan Gohman           N->getOpcode() == ISD::STORE;
2396b625f2f8960de32bc973092aaee8ac62863006feDan Gohman  }
23979de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel};
23989de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel
239924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
240024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
24019de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode {
240224446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
240324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
2404475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs,
240583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT,
240695c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb             const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2407b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3,
2408ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman                   VTs, AM, LVT, SV, O, Align, Vol) {
2409a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    SubclassData |= (unsigned short)ETy;
2410a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    assert(getExtensionType() == ETy && "LoadExtType encoding error!");
2411ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
24123edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  LoadSDNode(SDValue *ChainPtrOff, DebugLoc dl, SDVTList VTs,
24133edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT,
24143edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen             const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
24153edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : LSBaseSDNode(ISD::LOAD, dl, ChainPtrOff, 3,
24163edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen                   VTs, AM, LVT, SV, O, Align, Vol) {
2417a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    SubclassData |= (unsigned short)ETy;
2418a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    assert(getExtensionType() == ETy && "LoadExtType encoding error!");
24193edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
242024446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
242124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2422ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// getExtensionType - Return whether this is a plain node,
2423ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// or one of the varieties of value-extending loads.
2424ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  ISD::LoadExtType getExtensionType() const {
2425a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    return ISD::LoadExtType(SubclassData & 3);
2426ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
2427ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
2428475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(1); }
2429475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const { return getOperand(2); }
243039354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner
243124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const LoadSDNode *) { return true; }
243224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
243324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD;
243424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
243524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
243624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
243724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes.
243824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
24399de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode {
244024446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
244124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
2442475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs,
244383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands              ISD::MemIndexedMode AM, bool isTrunc, MVT SVT,
244424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
2445b625f2f8960de32bc973092aaee8ac62863006feDan Gohman    : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4,
2446ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman                   VTs, AM, SVT, SV, O, Align, Vol) {
2447a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    SubclassData |= (unsigned short)isTrunc;
2448a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    assert(isTruncatingStore() == isTrunc && "isTrunc encoding error!");
2449ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  }
24503edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  StoreSDNode(SDValue *ChainValuePtrOff, DebugLoc dl, SDVTList VTs,
24513edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen              ISD::MemIndexedMode AM, bool isTrunc, MVT SVT,
24523edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
24533edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen    : LSBaseSDNode(ISD::STORE, dl, ChainValuePtrOff, 4,
24543edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen                   VTs, AM, SVT, SV, O, Align, Vol) {
2455a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    SubclassData |= (unsigned short)isTrunc;
2456a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman    assert(isTruncatingStore() == isTrunc && "isTrunc encoding error!");
24573edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen  }
245824446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
245924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2460ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// isTruncatingStore - Return true if the op does a truncation before store.
2461ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// For integers this is the same as doing a TRUNCATE and storing the result.
2462ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman  /// For floats, it is the same as doing an FP_ROUND and storing the result.
2463a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman  bool isTruncatingStore() const { return SubclassData & 1; }
2464ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman
2465475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getValue() const { return getOperand(1); }
2466475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getBasePtr() const { return getOperand(2); }
2467475871a144eb604ddaf37503397ba0941442e5fbDan Gohman  const SDValue &getOffset() const { return getOperand(3); }
246839354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner
24696d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng  static bool classof(const StoreSDNode *) { return true; }
247024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
247124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::STORE;
247224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
247324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
247424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
247515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
24761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
24771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNode *Node;
24781080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned Operand;
2479ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
24801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
24811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic:
24821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator==(const SDNodeIterator& x) const {
24831080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return Operand == x.Operand;
24841080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
24851080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
24861080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
24871080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNodeIterator &operator=(const SDNodeIterator &I) {
24881080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
24891080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    Operand = I.Operand;
24901080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
24911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
2492ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
24931080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator*() const {
2494ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif    return Node->getOperand(Operand).getNode();
24951080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
24961080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator->() const { return operator*(); }
2497ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
24981080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator& operator++() {                // Preincrement
24991080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    ++Operand;
25001080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
25011080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
25021080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator operator++(int) { // Postincrement
2503ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SDNodeIterator tmp = *this; ++*this; return tmp;
25041080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
25051080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
25061080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
25071080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator end  (SDNode *N) {
25081080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator(N, N->getNumOperands());
25091080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
25101080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
25111080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned getOperand() const { return Operand; }
25121080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNode *getNode() const { return Node; }
25131080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
25141080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
25151080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> {
25161080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNode NodeType;
25171080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNodeIterator ChildIteratorType;
25181080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static inline NodeType *getEntryNode(SDNode *N) { return N; }
2519ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_begin(NodeType *N) {
25201080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::begin(N);
25211080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
2522ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_end(NodeType *N) {
25231080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::end(N);
25241080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
25251080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
25261080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
25270e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// LargestSDNode - The largest SDNode class.
25280e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman///
25290e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohmantypedef LoadSDNode LargestSDNode;
25300e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman
2531fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// MostAlignedSDNode - The SDNode class with the greatest alignment
2532fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// requirement.
2533fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman///
2534015b714f298ce3122302a4e996b81bd3e8c750cdDan Gohmantypedef ARG_FLAGSSDNode MostAlignedSDNode;
2535b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
2536c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD {
2537186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  /// isNormalLoad - Returns true if the specified node is a non-extending
2538186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  /// and unindexed load.
2539186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  inline bool isNormalLoad(const SDNode *N) {
2540c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N);
2541c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
2542186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng      Ld->getAddressingMode() == ISD::UNINDEXED;
2543186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng  }
2544186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng
254524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// isNON_EXTLoad - Returns true if the specified node is a non-extending
254624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// load.
254724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  inline bool isNON_EXTLoad(const SDNode *N) {
2548c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
254924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
255024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
255124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
2552c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
2553c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2554c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isEXTLoad(const SDNode *N) {
2555c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
255624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
2557c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
2558c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2559c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
2560c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2561c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isSEXTLoad(const SDNode *N) {
2562c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
256324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
2564c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
2565c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2566c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
2567c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
2568c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isZEXTLoad(const SDNode *N) {
2569c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
257024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
2571c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
25728b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
2573c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load.
257402c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  ///
257502c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  inline bool isUNINDEXEDLoad(const SDNode *N) {
2576c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<LoadSDNode>(N) &&
257702c50e4891841c28b2a743731dfc60744bb78879Evan Cheng      cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
257802c50e4891841c28b2a743731dfc60744bb78879Evan Cheng  }
257902c50e4891841c28b2a743731dfc60744bb78879Evan Cheng
2580c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isNormalStore - Returns true if the specified node is a non-truncating
2581c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// and unindexed store.
2582c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  inline bool isNormalStore(const SDNode *N) {
2583c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    const StoreSDNode *St = dyn_cast<StoreSDNode>(N);
2584c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return St && !St->isTruncatingStore() &&
2585c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands      St->getAddressingMode() == ISD::UNINDEXED;
2586c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  }
2587c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands
25888b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
25898b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
25908b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isNON_TRUNCStore(const SDNode *N) {
2591c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore();
25928b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
25938b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
25948b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isTRUNCStore - Returns true if the specified node is a truncating
25958b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
25968b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isTRUNCStore(const SDNode *N) {
2597c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore();
2598c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  }
2599c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands
2600c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// isUNINDEXEDStore - Returns true if the specified node is an
2601c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  /// unindexed store.
2602c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands  inline bool isUNINDEXEDStore(const SDNode *N) {
2603c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands    return isa<StoreSDNode>(N) &&
2604c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands      cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
26058b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
2606c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
2607c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
2608c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
260963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace
261063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
261163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif
2612