SelectionDAGNodes.h revision 63e3f14df6cf76f1a12de1153e1114f4b20b15a9
163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===//
2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//                     The LLVM Compiler Infrastructure
463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//
563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// This file was developed by the LLVM research group and is distributed under
663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// the University of Illinois Open Source License. See LICENSE.TXT for details.
7ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
9ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
1063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// This file declares the SDNode class and derived classes, which are used to
1163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// represent the nodes and operations present in a SelectionDAG.  These nodes
1263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// and operations are machine code level operations, with some similarities to
1363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// the GCC RTL representation.
1463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//
1563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// Clients should include the SelectionDAG.h file instead of this file directly.
1663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//
1763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
1863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
2063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#define LLVM_CODEGEN_SELECTIONDAGNODES_H
2163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
222d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth#include "llvm/Value.h"
23583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/ADT/FoldingSet.h"
241080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/GraphTraits.h"
251080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/iterator"
26d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h"
2739931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h"
2863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert>
2963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm {
3163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG;
3363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue;
3463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock;
35d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue;
3663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode;
3763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type;
38b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate <typename T> struct ilist_traits;
39b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<typename NodeTy, typename Traits> class iplist;
40b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<typename NodeTy> class ilist_iterator;
4163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
420b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by
430b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG.  Instances of this simple value class are returned by
440b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...).
450b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner///
460b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList {
470b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  const MVT::ValueType *VTs;
480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  unsigned short NumVTs;
490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner};
500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
5263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the
5363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types.
5463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
5563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD {
5663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
5763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::NodeType enum - This enum defines all of the operators valid in a
5863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SelectionDAG.
5963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
6063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum NodeType {
613258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // DELETED_NODE - This is an illegal flag value that is used to catch
623258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    // errors.  This opcode is not a legal opcode for any node.
633258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    DELETED_NODE,
643258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner
658a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // EntryToken - This is the marker used to indicate the start of the region.
668a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    EntryToken,
678a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner
688c4bde36a339b1c538002e819daff84caae4cbadReid Spencer    // Token factor - This node takes multiple tokens as input and produces a
698a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // single token result.  This is used to represent the fact that the operand
708a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // operators are independent of each other.
718a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    TokenFactor,
72f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman
73f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // AssertSext, AssertZext - These nodes record if a register contains a
74f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // value that has already been zero or sign extended from a narrower type.
75f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // These nodes take two operands.  The first is the node that has already
76f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // been extended, and the second is a value type node indicating the width
77f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    // of the extension
78f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman    AssertSext, AssertZext,
79ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
808a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner    // Various leaf nodes.
811ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    STRING, BasicBlock, VALUETYPE, CONDCODE, Register,
821ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    Constant, ConstantFP,
8337efe6764568a3829fee26aba532283131d1a104Nate Begeman    GlobalAddress, FrameIndex, JumpTable, ConstantPool, ExternalSymbol,
841ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng
8582c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    // The address of the GOT
8682c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth    GLOBAL_OFFSET_TABLE,
87bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman
88bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and
89bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // llvm.returnaddress on the DAG.  These nodes take one operand, the index
90bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // of the frame or return address to return.  An index of zero corresponds
91bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // to the current function's frame or return address, an index of one to the
92bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    // parent's frame or return address, and so on.
93bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman    FRAMEADDR, RETURNADDR,
94beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth
95ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // TargetConstant* - Like Constant*, but the DAG does not do any folding or
96ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    // simplification of the constant.
97056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    TargetConstant,
98ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    TargetConstantFP,
99f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner
100f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or
101f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // anything else with this node, and this is valid in the target-specific
102f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    // dag, turning into a GlobalAddress operand.
103f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    TargetGlobalAddress,
104afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    TargetFrameIndex,
10537efe6764568a3829fee26aba532283131d1a104Nate Begeman    TargetJumpTable,
106aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    TargetConstantPool,
1072a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth    TargetExternalSymbol,
10872601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner
109ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...)
110ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with no side effects.
111ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// The first operand is the ID number of the intrinsic from the
112ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// llvm::Intrinsic namespace.  The operands to the intrinsic follow.  The
113ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// node has returns the result of the intrinsic.
114ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_WO_CHAIN,
115ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
116ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...)
117ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
118ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// returns a result.  The first operand is a chain pointer.  The second is
119ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// the ID number of the intrinsic from the llvm::Intrinsic namespace.  The
120ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// operands to the intrinsic follow.  The node has two results, the result
121ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// of the intrinsic and an output chain.
122ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_W_CHAIN,
12363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
124ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...)
125ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// This node represents a target intrinsic function with side effects that
126ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// does not return a result.  The first operand is a chain pointer.  The
127ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// second is the ID number of the intrinsic from the llvm::Intrinsic
128ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    /// namespace.  The operands to the intrinsic follow.
129ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner    INTRINSIC_VOID,
130ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner
131d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // CopyToReg - This node has three operands: a chain, a register number to
132d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    // set to this value, and a value.
13363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyToReg,
13463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
13563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // CopyFromReg - This node indicates that the input value is a virtual or
13663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // physical register that is defined outside of the scope of this
13718c2f13e0f9d0e5d6227cf6d1881e9ee3d1b6109Chris Lattner    // SelectionDAG.  The register is available from the RegSDNode object.
13863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    CopyFromReg,
13963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
140fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    // UNDEF - An undefined node
141fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman    UNDEF,
142681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner
143b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
144b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// represents the formal arguments for a function.  CC# is a Constant value
145b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// indicating the calling convention of the function, and ISVARARG is a
146b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// flag that indicates whether the function is varargs or not. This node
147b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// has one result value for each incoming argument, plus one for the output
148b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// chain. It must be custom legalized. See description of CALL node for
149b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// FLAG argument contents explanation.
150c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner    ///
151681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner    FORMAL_ARGUMENTS,
1526c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner
1536c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE,
154b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    ///                              ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn)
1556c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    /// This node represents a fully general function call, before the legalizer
156b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// runs.  This has one result value for each argument / flag pair, plus
157b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// a chain result. It must be custom legalized. Flag argument indicates
158b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// misc. argument attributes. Currently:
159b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 0 - signness
160b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 1 - 'inreg' attribute
161b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov    /// Bit 2 - 'sret' attribute
1626c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner    CALL,
163fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman
16463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // EXTRACT_ELEMENT - This is used to get the first or second (determined by
16563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // a Constant, which is required to be operand #1), element of the aggregate
16663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // value specified as operand #0.  This is only for use before legalization,
16763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // for values that will be broken into multiple registers.
16863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    EXTRACT_ELEMENT,
16963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
17063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways.  Given
17163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // two values of the same integer value type, this produces a value twice as
17263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // big.  Like EXTRACT_ELEMENT, this can only be used before legalization.
17363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BUILD_PAIR,
174006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner
175006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // MERGE_VALUES - This node takes multiple discrete operands and returns
176006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // them all as its individual results.  This nodes has exactly the same
177006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // number of inputs and outputs, and is only valid before legalization.
178006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // This node is useful for some pieces of the code generator that want to
179006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    // think about a single node with multiple results, not multiple nodes.
180006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner    MERGE_VALUES,
18163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
182615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple integer binary arithmetic operators.
183bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    ADD, SUB, MUL, SDIV, UDIV, SREM, UREM,
184615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner
185551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-setting nodes for multiple precision addition and subtraction.
186551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // These nodes take two operands of the same value type, and produce two
187551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // results.  The first result is the normal add or sub result, the second
188551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // result is the carry flag result.
189551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDC, SUBC,
190551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman
191551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // Carry-using nodes for multiple precision addition and subtraction.  These
192551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // nodes take three operands: The first two are the normal lhs and rhs to
193551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // the add or sub, and the third is the input carry flag.  These nodes
194551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // produce two results; the normal result of the add or sub, and the output
195551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // carry flag.  These nodes both read and write a carry flag to allow them
196551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // to them to be chained together for add and sub of arbitrarily large
197551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    // values.
198551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman    ADDE, SUBE,
199551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman
200615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    // Simple binary floating point operators.
201615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner    FADD, FSUB, FMUL, FDIV, FREM,
20238bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
20338bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.  NOTE: This
20438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // DAG node does not require that X and Y have the same type, just that they
20538bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // are both floating point.  X and the result must have the same type.
20638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    // FCOPYSIGN(f32, f64) is allowed.
20738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner    FCOPYSIGN,
208fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner
20922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// VBUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,...,  COUNT,TYPE) - Return a vector
21022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// with the specified, possibly variable, elements.  The number of elements
21122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// is required to be a power of two.
21222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    VBUILD_VECTOR,
213bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner
21422232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// BUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,...) - Return a vector
21522232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// with the specified, possibly variable, elements.  The number of elements
21622232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// is required to be a power of two.
21722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    BUILD_VECTOR,
21822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
219fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner    /// VINSERT_VECTOR_ELT(VECTOR, VAL, IDX,  COUNT,TYPE) - Given a vector
220fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner    /// VECTOR, an element ELEMENT, and a (potentially variable) index IDX,
221fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner    /// return an vector with the specified element of VECTOR replaced with VAL.
222fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner    /// COUNT and TYPE specify the type of vector, as is standard for V* nodes.
223fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner    VINSERT_VECTOR_ELT,
224fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner
22522232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR (a legal packed
22622232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// type) with the element at IDX replaced with VAL.
22722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    INSERT_VECTOR_ELT,
2284b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner
2294b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// VEXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
2304b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// (an MVT::Vector value) identified by the (potentially variable) element
2314b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// number IDX.
2324b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    VEXTRACT_VECTOR_ELT,
2334b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner
2344b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR
2354b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// (a legal packed type vector) identified by the (potentially variable)
2364b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    /// element number IDX.
2374b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner    EXTRACT_VECTOR_ELT,
23822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner
239eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner    /// VVECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC, COUNT,TYPE) - Returns a vector,
240eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner    /// of the same type as VEC1/VEC2.  SHUFFLEVEC is a VBUILD_VECTOR of
241eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner    /// constant int values that indicate which value each result element will
242eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner    /// get.  The elements of VEC1/VEC2 are enumerated in order.  This is quite
243eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner    /// similar to the Altivec 'vperm' instruction, except that the indices must
244eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner    /// be constants and are in terms of the element size of VEC1/VEC2, not in
245eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner    /// terms of bytes.
246eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner    VVECTOR_SHUFFLE,
247eda6dfd5e46f2475eb1a9d79750bdd6be6b7e94aChris Lattner
24849c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same
24949c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// type as VEC1/VEC2.  SHUFFLEVEC is a BUILD_VECTOR of constant int values
25049c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// (regardless of whether its datatype is legal or not) that indicate
25149c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// which value each result element will get.  The elements of VEC1/VEC2 are
25249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// enumerated in order.  This is quite similar to the Altivec 'vperm'
25349c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// instruction, except that the indices must be constants and are in terms
25449c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    /// of the element size of VEC1/VEC2, not in terms of bytes.
25549c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner    VECTOR_SHUFFLE,
25649c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner
257762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner    /// X = VBIT_CONVERT(Y)  and X = VBIT_CONVERT(Y, COUNT,TYPE) - This node
258762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner    /// represents a conversion from or to an ISD::Vector type.
259762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner    ///
260762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner    /// This is lowered to a BIT_CONVERT of the appropriate input/output types.
261762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner    /// The input and output are required to have the same size and at least one
262313f13c5aa9f20ed58422e24c247c05f4f0af7ffChris Lattner    /// is required to be a vector (if neither is a vector, just use
263313f13c5aa9f20ed58422e24c247c05f4f0af7ffChris Lattner    /// BIT_CONVERT).
264762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner    ///
265313f13c5aa9f20ed58422e24c247c05f4f0af7ffChris Lattner    /// If the result is a vector, this takes three operands (like any other
266313f13c5aa9f20ed58422e24c247c05f4f0af7ffChris Lattner    /// vector producer) which indicate the size and type of the vector result.
267762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner    /// Otherwise it takes one input.
268762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner    VBIT_CONVERT,
269762f2ae0c4c07a93fd2f830fb079692dbccef85cChris Lattner
27022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// BINOP(LHS, RHS,  COUNT,TYPE)
27122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// Simple abstract vector operators.  Unlike the integer and floating point
27222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// binary operators, these nodes also take two additional operands:
27322232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// a constant element count, and a value type node indicating the type of
27422232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// the elements.  The order is count, type, op0, op1.  All vector opcodes,
27522232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// including VLOAD and VConstant must currently have count and type as
27622232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    /// their last two operands.
27722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    VADD, VSUB, VMUL, VSDIV, VUDIV,
27822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner    VAND, VOR, VXOR,
279210721aecc0916315f61660dc387a96b89ec423bChris Lattner
28049027e639eb40eef51837b55a3af17dcdb4d400aChris Lattner    /// VSELECT(COND,LHS,RHS,  COUNT,TYPE) - Select for MVT::Vector values.
28149027e639eb40eef51837b55a3af17dcdb4d400aChris Lattner    /// COND is a boolean value.  This node return LHS if COND is true, RHS if
28249027e639eb40eef51837b55a3af17dcdb4d400aChris Lattner    /// COND is false.
28349027e639eb40eef51837b55a3af17dcdb4d400aChris Lattner    VSELECT,
28449027e639eb40eef51837b55a3af17dcdb4d400aChris Lattner
285210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a
286210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// scalar value into the low element of the resultant vector type.  The top
287210721aecc0916315f61660dc387a96b89ec423bChris Lattner    /// elements of the vector are undefined.
288210721aecc0916315f61660dc387a96b89ec423bChris Lattner    SCALAR_TO_VECTOR,
289210721aecc0916315f61660dc387a96b89ec423bChris Lattner
290bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing
291bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    // an unsigned/signed value of type i[2*n], then return the top part.
292bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner    MULHU, MULHS,
29363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
29435ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // Bitwise operators - logical and, logical or, logical xor, shift left,
29535ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // shift right algebraic (shift in sign bits), shift right logical (shift in
29635ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    // zeroes), rotate left, rotate right, and byteswap.
29735ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman    AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP,
29863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
299691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    // Counting operators
300691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth    CTTZ, CTLZ, CTPOP,
301691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth
302fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner    // Select(COND, TRUEVAL, FALSEVAL)
3039373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    SELECT,
3049373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman
3059373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // Select with condition operator - This selects between a true value and
3069373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // a false value (ops #2 and #3) based on the boolean result of comparing
3079373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // the lhs and rhs (ops #0 and #1) of a conditional expression with the
3089373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    // condition code in op #4, a CondCodeSDNode.
3099373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman    SELECT_CC,
31063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
31163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // SetCC operator - This evaluates to a boolean (i1) true value if the
3127cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    // condition is true.  The operands to this are the left and right operands
3137cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    // to compare (ops #0, and #1) and the condition code to compare them with
3147cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    // (op #2) as a CondCodeSDNode.
31563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETCC,
31663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
31714c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded
31814c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // integer shift operations, just like ADD/SUB_PARTS.  The operation
31914c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    // ordering is:
3206b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner    //       [Lo,Hi] = op [LoLHS,HiLHS], Amt
32114c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner    SHL_PARTS, SRA_PARTS, SRL_PARTS,
32214c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner
32363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Conversion operators.  These are all single input single output
32463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operations.  For all of these, the result type must be strictly
32563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // wider or narrower (depending on the operation) than the source
32663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // type.
32763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
32863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // SIGN_EXTEND - Used for integer types, replicating the sign bit
32963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // into new bits.
33063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SIGN_EXTEND,
33163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
33263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // ZERO_EXTEND - Used for integer types, zeroing the new bits.
33363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    ZERO_EXTEND,
33463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3357e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    // ANY_EXTEND - Used for integer types.  The high bits are undefined.
3367e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner    ANY_EXTEND,
3377e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner
33863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // TRUNCATE - Completely drop the high bits.
33963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    TRUNCATE,
34063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3411645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign
3421645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // depends on the first letter) to floating point.
3431645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    SINT_TO_FP,
3441645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    UINT_TO_FP,
3451645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
346ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to
347ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // sign extend a small value in a large integer register (e.g. sign
348ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner    // extending the low 8 bits of a 32-bit register to fill the top 24 bits
34915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // with the 7th bit).  The size of the smaller type is indicated by the 1th
35015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // operand, a ValueType node.
351859157daee6a4b49e99921832e1dde065167b317Chris Lattner    SIGN_EXTEND_INREG,
352859157daee6a4b49e99921832e1dde065167b317Chris Lattner
3531645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // FP_TO_[US]INT - Convert a floating point value to a signed or unsigned
3541645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    // integer.
3551645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_SINT,
3561645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner    FP_TO_UINT,
3571645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner
35863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // FP_ROUND - Perform a rounding operation from the current
359859157daee6a4b49e99921832e1dde065167b317Chris Lattner    // precision down to the specified precision (currently always 64->32).
36063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_ROUND,
36163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
362859157daee6a4b49e99921832e1dde065167b317Chris Lattner    // FP_ROUND_INREG - This operator takes a floating point register, and
363859157daee6a4b49e99921832e1dde065167b317Chris Lattner    // rounds it to a floating point value.  It then promotes it and returns it
364859157daee6a4b49e99921832e1dde065167b317Chris Lattner    // in a register of the same size.  This operation effectively just discards
36515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // excess precision.  The type to round down to is specified by the 1th
36615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    // operation, a VTSDNode (currently always 64->32->64).
367859157daee6a4b49e99921832e1dde065167b317Chris Lattner    FP_ROUND_INREG,
368859157daee6a4b49e99921832e1dde065167b317Chris Lattner
36963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // FP_EXTEND - Extend a smaller FP type into a larger FP type.
37063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    FP_EXTEND,
37163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3721ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // BIT_CONVERT - Theis operator converts between integer and FP values, as
3731ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    // if one was stored to memory as integer and the other was loaded from the
37480f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // same address (or equivalently for vector format conversions, etc).  The
37580f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // source and result are required to have the same bit size (e.g.
37680f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // f32 <-> i32).  This can also be used for int-to-int or fp-to-fp
37780f55abf009c86bc03821e10746832f88f8a735fChris Lattner    // conversions, but that is a noop, deleted by getNode().
3781ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner    BIT_CONVERT,
3791ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner
380dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner    // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI - Perform unary floating point
381dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner    // negation, absolute value, square root, sine and cosine, and powi
382dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner    // operations.
383dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner    FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI,
38438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner
3858862ef148100070b7bf28beead3951464250c926Evan Cheng    // LOAD and STORE have token chains as their first operand, then the same
3868862ef148100070b7bf28beead3951464250c926Evan Cheng    // operands as an LLVM load/store instruction, then an offset node that
3878862ef148100070b7bf28beead3951464250c926Evan Cheng    // is added / subtracted from the base pointer to form the address (for
3888862ef148100070b7bf28beead3951464250c926Evan Cheng    // indexed memory ops).
38963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    LOAD, STORE,
3905fbb5d2459a5410590f285250faa604576308a93Nate Begeman
3911ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    // Abstract vector version of LOAD.  VLOAD has a constant element count as
3921ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    // the first operand, followed by a value type node indicating the type of
3931ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng    // the elements, a token chain, a pointer operand, and a SRCVALUE node.
3945fbb5d2459a5410590f285250faa604576308a93Nate Begeman    VLOAD,
39563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
3961cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner    // TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a
3971cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner    // value and stores it to memory in one operation.  This can be used for
398f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner    // either integer or floating point operands.  The first four operands of
399f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner    // this are the same as a standard store.  The fifth is the ValueType to
400f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner    // store it as (which will be smaller than the source value).
4011cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner    TRUNCSTORE,
4021cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner
40363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
40463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // to a specified boundary.  The first operand is the token chain, the
40563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // second is the number of bytes to allocate, and the third is the alignment
40674fe063e90045931eefaba561730e6a9175ced78Chris Lattner    // boundary.  The size is guaranteed to be a multiple of the stack
40774fe063e90045931eefaba561730e6a9175ced78Chris Lattner    // alignment, and the alignment is guaranteed to be bigger than the stack
40874fe063e90045931eefaba561730e6a9175ced78Chris Lattner    // alignment (if required) or 0 to get standard stack alignment.
40963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    DYNAMIC_STACKALLOC,
41063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
41163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Control flow instructions.  These all have token chains.
412ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
41363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BR - Unconditional branch.  The first operand is the chain
41463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // operand, the second is the MBB to branch to.
41563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BR,
41663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
41737efe6764568a3829fee26aba532283131d1a104Nate Begeman    // BRIND - Indirect branch.  The first operand is the chain, the second
41837efe6764568a3829fee26aba532283131d1a104Nate Begeman    // is the value to branch to, which must be of the same type as the target's
41937efe6764568a3829fee26aba532283131d1a104Nate Begeman    // pointer type.
42037efe6764568a3829fee26aba532283131d1a104Nate Begeman    BRIND,
421c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng
422c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // BR_JT - Jumptable branch. The first operand is the chain, the second
423c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    // is the jumptable index, the last one is the jumptable entry index.
424c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng    BR_JT,
42537efe6764568a3829fee26aba532283131d1a104Nate Begeman
42663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BRCOND - Conditional branch.  The first operand is the chain,
42763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // the second is the condition, the third is the block to branch
42863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // to if the condition is true.
42963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    BRCOND,
43063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4317cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // BR_CC - Conditional branch.  The behavior is like that of SELECT_CC, in
4327cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // that the condition is represented as condition code, and two nodes to
4337cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // compare, rather than as a combined SetCC node.  The operands in order are
4347cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    // chain, cc, lhs, rhs, block to branch to if condition is true.
4357cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman    BR_CC,
4367cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman
43763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // RET - Return from function.  The first operand is the chain,
4388e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // and any subsequent operands are pairs of return value and return value
4398e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // signness for the function.  This operation can have variable number of
4408e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng    // operands.
44163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    RET,
44263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
4437572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // INLINEASM - Represents an inline asm block.  This node always has two
4447572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    // return values: a chain and a flag result.  The inputs are as follows:
4457572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #0   : Input chain.
4467572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #1   : a ExternalSymbolSDNode with a pointer to the asm string.
4477572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+2: A RegisterNode.
4487572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #2n+3: A TargetConstant, indicating if the reg is a use/def
4497572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    //   Operand #last: Optional, an incoming flag.
4507572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner    INLINEASM,
4511ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey
4521ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    // LABEL - Represents a label in mid basic block used to track
4531ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    // locations needed for debug and exception handling tables.  This node
4541ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    // returns a chain.
4551ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    //   Operand #0 : input chain.
4561ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    //   Operand #1 : module unique number use to identify the label.
4571ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey    LABEL,
458ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner
4595a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKSAVE - STACKSAVE has one operand, an input chain.  It produces a
4605a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // value, the same type as the pointer type for the system, and an output
4615a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // chain.
4625a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKSAVE,
4635a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
4645a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // STACKRESTORE has two operands, an input chain and a pointer to restore to
4655a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    // it returns an output chain.
4665a67afc118d47a0061ca9809c763451ea3125306Chris Lattner    STACKRESTORE,
4675a67afc118d47a0061ca9809c763451ea3125306Chris Lattner
468ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain, and the rest
469ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    // correspond to the operands of the LLVM intrinsic functions.  The only
470ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    // result is a token chain.  The alignment argument is guaranteed to be a
471ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    // Constant node.
472ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    MEMSET,
473ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    MEMMOVE,
474ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner    MEMCPY,
475ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
47616cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of
47716cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // a call sequence, and carry arbitrary information that target might want
47816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // to know.  The first operand is a chain, the rest are specified by the
47916cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    // target and not touched by the DAG optimizers.
48016cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_START,  // Beginning of a call sequence
48116cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner    CALLSEQ_END,    // End of a call sequence
482acc398c195a697795bff3245943d104eb19192b9Nate Begeman
483acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAARG - VAARG has three operands: an input chain, a pointer, and a
484acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // SRCVALUE.  It returns a pair of values: the vaarg value and a new chain.
485acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAARG,
486acc398c195a697795bff3245943d104eb19192b9Nate Begeman
487acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VACOPY - VACOPY has five operands: an input chain, a destination pointer,
488acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the
489acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // source.
490acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VACOPY,
491acc398c195a697795bff3245943d104eb19192b9Nate Begeman
492acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a
493acc398c195a697795bff3245943d104eb19192b9Nate Begeman    // pointer, and a SRCVALUE.
494acc398c195a697795bff3245943d104eb19192b9Nate Begeman    VAEND, VASTART,
49563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
49621074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    // SRCVALUE - This corresponds to a Value*, and is used to associate memory
49721074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    // locations with their value.  This allows one use alias analysis
49821074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    // information in the backend.
49921074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner    SRCVALUE,
50021074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner
501e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman    // PCMARKER - This corresponds to the pcmarker intrinsic.
50295762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth    PCMARKER,
50363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
504aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
5058b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // The only operand is a chain and a value and a chain are produced.  The
5068b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // value is the contents of the architecture specific cycle counter like
5078b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth    // register (or other high accuracy low latency clock source)
508aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth    READCYCLECOUNTER,
509aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth
510d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    // HANDLENODE node - Used as a handle for various purposes.
511d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner    HANDLENODE,
5122d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
51347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    // LOCATION - This node is used to represent a source location for debug
51447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    // info.  It takes token chain as input, then a line number, then a column
51547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    // number, then a filename, then a working dir.  It produces a token chain
51647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    // as output.
51747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    LOCATION,
51847725d059b259f8a0c145478300c9e9caa006b59Chris Lattner
519f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    // DEBUG_LOC - This node is used to represent source line information
520abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // embedded in the code.  It takes a token chain as input, then a line
52144c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey    // number, then a column then a file id (provided by MachineModuleInfo.) It
522abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey    // produces a token chain as output.
523f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey    DEBUG_LOC,
524f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey
52563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // BUILTIN_OP_END - This must be the last enum value in this list.
526410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    BUILTIN_OP_END
52763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
52863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
529322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// Node predicates
530322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
531a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  /// isBuildVectorAllOnes - Return true if the specified node is a
532322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner  /// BUILD_VECTOR where all of the elements are ~0 or undef.
533a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng  bool isBuildVectorAllOnes(const SDNode *N);
5344a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng
5354a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// isBuildVectorAllZeros - Return true if the specified node is a
5364a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  /// BUILD_VECTOR where all of the elements are 0 or undef.
5374a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng  bool isBuildVectorAllZeros(const SDNode *N);
538322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner
53963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
540144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// MemIndexedMode enum - This enum defines the load / store indexed
541144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  /// addressing modes.
54224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
54324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// UNINDEXED    "Normal" load / store. The effective address is already
54424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computed and is available in the base pointer. The offset
54581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              operand is always undefined. In addition to producing a
54681c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              chain, an unindexed load produces one value (result of the
54781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              load); an unindexed store does not produces a value.
54824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
54935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// PRE_INC      Similar to the unindexed mode where the effective address is
5508862ef148100070b7bf28beead3951464250c926Evan Cheng  /// PRE_DEC      the value of the base pointer add / subtract the offset.
5518862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              It considers the computation as being folded into the load /
55224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              store operation (i.e. the load / store does the address
55324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///              computation as well as performing the memory transaction).
55481c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              The base operand is always undefined. In addition to
55581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              producing a chain, pre-indexed load produces two values
55681c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              (result of the load and the result of the address
55781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              computation); a pre-indexed store produces one value (result
55881c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ///              of the address computation).
55924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
56035acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng  /// POST_INC     The effective address is the value of the base pointer. The
5618862ef148100070b7bf28beead3951464250c926Evan Cheng  /// POST_DEC     value of the offset operand is then added to / subtracted
5628862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              from the base after memory transaction. In addition to
5638862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              producing a chain, post-indexed load produces two values
5648862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              (the result of the load and the result of the base +/- offset
5658862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              computation); a post-indexed store produces one value (the
5668862ef148100070b7bf28beead3951464250c926Evan Cheng  ///              the result of the base +/- offset computation).
56724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
568144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  enum MemIndexedMode {
56924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    UNINDEXED = 0,
57035acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_INC,
57135acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    PRE_DEC,
57235acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng    POST_INC,
573144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    POST_DEC,
574144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng    LAST_INDEXED_MODE
57524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  };
57624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
57724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  //===--------------------------------------------------------------------===//
578c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// LoadExtType enum - This enum defines the three variants of LOADEXT
579c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// (load with extension).
580c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
58124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// SEXTLOAD loads the integer operand and sign extends it to a larger
58224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
58324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// ZEXTLOAD loads the integer operand and zero extends it to a larger
58424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer result type.
58524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// EXTLOAD  is used for three things: floating point extending loads,
58624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          integer extending loads [the top bits are undefined], and vector
58724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///          extending loads [load into low elt].
58824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ///
589c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  enum LoadExtType {
59024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    NON_EXTLOAD = 0,
591c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    EXTLOAD,
592c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    SEXTLOAD,
593c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    ZEXTLOAD,
594c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng    LAST_LOADX_TYPE
595c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  };
596c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
597c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  //===--------------------------------------------------------------------===//
59863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// ISD::CondCode enum - These are ordered carefully to make the bitfields
59963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// below work out, when considering SETFALSE (something that never exists
60063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// dynamically) as 0.  "U" -> Unsigned (for integer operands) or Unordered
60163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal
60263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to.  If the "N" column is 1, the result of the comparison is undefined if
60363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the input is a NAN.
60463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
60563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// All of these (except for the 'always folded ops') should be handled for
60663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// floating point.  For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT,
60763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used.
60863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
60963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// Note that these are laid out in a specific order to allow bit-twiddling
61063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// to transform conditions.
61163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  enum CondCode {
61263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Opcode          N U L G E       Intuitive operation
61363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE,      //    0 0 0 0       Always false (always folded)
61463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOEQ,        //    0 0 0 1       True if ordered and equal
61563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGT,        //    0 0 1 0       True if ordered and greater than
61663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOGE,        //    0 0 1 1       True if ordered and greater than or equal
61763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLT,        //    0 1 0 0       True if ordered and less than
61863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETOLE,        //    0 1 0 1       True if ordered and less than or equal
61963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETONE,        //    0 1 1 0       True if ordered and operands are unequal
62063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETO,          //    0 1 1 1       True if ordered (no nans)
62163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUO,         //    1 0 0 0       True if unordered: isnan(X) | isnan(Y)
62263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUEQ,        //    1 0 0 1       True if unordered or equal
62363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGT,        //    1 0 1 0       True if unordered or greater than
62463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUGE,        //    1 0 1 1       True if unordered, greater than, or equal
62563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETULT,        //    1 1 0 0       True if unordered or less than
626ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETULE,        //    1 1 0 1       True if unordered, less than, or equal
62763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETUNE,        //    1 1 1 0       True if unordered or not equal
62863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE,       //    1 1 1 1       Always true (always folded)
62963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    // Don't care operations: undefined if the input is a nan.
63063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETFALSE2,     //  1 X 0 0 0       Always false (always folded)
63163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETEQ,         //  1 X 0 0 1       True if equal
63263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGT,         //  1 X 0 1 0       True if greater than
63363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETGE,         //  1 X 0 1 1       True if greater than or equal
63463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETLT,         //  1 X 1 0 0       True if less than
635ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SETLE,         //  1 X 1 0 1       True if less than or equal
63663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETNE,         //  1 X 1 1 0       True if not equal
63763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    SETTRUE2,      //  1 X 1 1 1       Always true (always folded)
63863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
639410354fe0c052141dadeca939395743f8dd58e38Chris Lattner    SETCC_INVALID       // Marker value.
64063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  };
64163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
64263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isSignedIntSetCC - Return true if this is a setcc instruction that
64363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs a signed comparison when used with integer operands.
64463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isSignedIntSetCC(CondCode Code) {
64563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE;
64663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
64763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
64863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isUnsignedIntSetCC - Return true if this is a setcc instruction that
64963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// performs an unsigned comparison when used with integer operands.
65063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isUnsignedIntSetCC(CondCode Code) {
65163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE;
65263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
65363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
65463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isTrueWhenEqual - Return true if the specified condition returns true if
65563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// the two operands to the condition are equal.  Note that if one of the two
65663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operands is a NaN, this value is meaningless.
65763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline bool isTrueWhenEqual(CondCode Cond) {
65863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond & 1) != 0;
65963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
66063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
66163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getUnorderedFlavor - This function returns 0 if the condition is always
66263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// false if an operand is a NaN, 1 if the condition is always true if the
66363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operand is a NaN, and 2 if the condition is undefined if the operand is a
66463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// NaN.
66563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getUnorderedFlavor(CondCode Cond) {
66663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return ((int)Cond >> 3) & 3;
66763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
66863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
66963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCInverse - Return the operation corresponding to !(X op Y), where
67063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// 'op' is a valid SetCC operation.
67163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCInverse(CondCode Operation, bool isInteger);
67263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
67363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X)
67463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// when given the operation for (X op Y).
67563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCSwappedOperands(CondCode Operation);
67663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
67763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCOrOperation - Return the result of a logical OR between different
67863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// comparisons of identical values: ((X op1 Y) | (X op2 Y)).  This
67963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
68063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
68163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger);
68263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
68363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getSetCCAndOperation - Return the result of a logical AND between
68463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)).  This
68563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// function returns SETCC_INVALID if it is not possible to represent the
68663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// resultant comparison.
68763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger);
68863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}  // end llvm::ISD namespace
68963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
69063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
69163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===//
69263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple
69363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation.  Many nodes return multiple values,
69463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns
69563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number
69663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values).
69763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
69863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that
69963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node.  This pair
70063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of information is represented with the SDOperand value type.
70163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
702f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerclass SDOperand {
703f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerpublic:
70463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  SDNode *Val;        // The node defining the value we are using.
70563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned ResNo;     // Which return value of the node we are using.
70663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
707ace44dbbabe9ee0498834957632df2af0dbf9c59Reid Spencer  SDOperand() : Val(0), ResNo(0) {}
70863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {}
70963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
71063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool operator==(const SDOperand &O) const {
71163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Val == O.Val && ResNo == O.ResNo;
71263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
71363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool operator!=(const SDOperand &O) const {
71463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return !operator==(O);
71563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
71663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool operator<(const SDOperand &O) const {
71763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return Val < O.Val || (Val == O.Val && ResNo < O.ResNo);
71863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
71963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
72063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  SDOperand getValue(unsigned R) const {
72163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return SDOperand(Val, R);
72263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
72363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
724bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng  // isOperand - Return true if this node is an operand of N.
725bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng  bool isOperand(SDNode *N) const;
726bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng
72763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the ValueType of the referenced return value.
72863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
72963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline MVT::ValueType getValueType() const;
730ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
73163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  // Forwarding methods - These forward to the corresponding methods in SDNode.
73263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getOpcode() const;
73363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline unsigned getNumOperands() const;
73463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  inline const SDOperand &getOperand(unsigned i) const;
735c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline uint64_t getConstantOperandVal(unsigned i) const;
7360f66a9172175aa7c3055333358170581c999219bNate Begeman  inline bool isTargetOpcode() const;
7370f66a9172175aa7c3055333358170581c999219bNate Begeman  inline unsigned getTargetOpcode() const;
738a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner
739a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner  /// hasOneUse - Return true if there is exactly one operation using this
740a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner  /// result value of the defining operator.
741a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner  inline bool hasOneUse() const;
74263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
74363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
74463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on
74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperands as if they were SDNode*'s.
74763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<SDOperand> {
74863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
74963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static SimpleType getSimplifiedValue(const SDOperand &Val) {
75063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return static_cast<SimpleType>(Val.Val);
75163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
75263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
75363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<const SDOperand> {
75463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  typedef SDNode* SimpleType;
75563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static SimpleType getSimplifiedValue(const SDOperand &Val) {
75663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return static_cast<SimpleType>(Val.Val);
75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG.
76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner///
763583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskeyclass SDNode : public FoldingSetNode {
7640442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  /// NodeType - The operation that this node performs.
7650442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
7660442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  unsigned short NodeType;
76763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
76863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// OperandsNeedDelete - This is true if OperandList was new[]'d.  If true,
76963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  /// then they will be delete[]'d when the node is destroyed.
77063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  bool OperandsNeedDelete : 1;
7710442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
772b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// NodeId - Unique id per SDNode in the DAG.
773b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int NodeId;
7740442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
775f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// OperandList - The values that are used by this operation.
7760442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner  ///
777f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  SDOperand *OperandList;
778f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner
779f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// ValueList - The types of the values this node defines.  SDNode's may
780f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// define multiple values simultaneously.
7812fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner  const MVT::ValueType *ValueList;
78263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
783f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  /// NumOperands/NumValues - The number of entries in the Operand/Value list.
784f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned short NumOperands, NumValues;
785b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
786b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  /// Prev/Next pointers - These pointers form the linked list of of the
787b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  /// AllNodes list in the current DAG.
788b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  SDNode *Prev, *Next;
789b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  friend struct ilist_traits<SDNode>;
79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// Uses - These are all of the SDNode's that use a value produced by this
79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// node.
7935892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner  SmallVector<SDNode*,3> Uses;
794917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner
795917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner  // Out-of-line virtual method to give class a home.
796917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner  virtual void ANCHOR();
79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
798b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  virtual ~SDNode() {
799b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner    assert(NumOperands == 0 && "Operand list not cleared before deletion");
8003258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner    NodeType = ISD::DELETED_NODE;
801b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  }
802b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //===--------------------------------------------------------------------===//
80463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //  Accessors
80563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  //
80663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned getOpcode()  const { return NodeType; }
8070f66a9172175aa7c3055333358170581c999219bNate Begeman  bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
8080f66a9172175aa7c3055333358170581c999219bNate Begeman  unsigned getTargetOpcode() const {
8090f66a9172175aa7c3055333358170581c999219bNate Begeman    assert(isTargetOpcode() && "Not a target opcode!");
8100f66a9172175aa7c3055333358170581c999219bNate Begeman    return NodeType - ISD::BUILTIN_OP_END;
8110f66a9172175aa7c3055333358170581c999219bNate Begeman  }
81263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
81363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  size_t use_size() const { return Uses.size(); }
81463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool use_empty() const { return Uses.empty(); }
81563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool hasOneUse() const { return Uses.size() == 1; }
81663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
817b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  /// getNodeId - Return the unique node id.
818b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  ///
819b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  int getNodeId() const { return NodeId; }
8200442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner
8215892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner  typedef SmallVector<SDNode*,3>::const_iterator use_iterator;
8227ece380440238ad0630a225b85a09a2dbed1165aChris Lattner  use_iterator use_begin() const { return Uses.begin(); }
8237ece380440238ad0630a225b85a09a2dbed1165aChris Lattner  use_iterator use_end() const { return Uses.end(); }
8247ece380440238ad0630a225b85a09a2dbed1165aChris Lattner
825b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the
826b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// indicated value.  This method ignores uses of other values defined by this
827b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner  /// operation.
8284ee621125876cc954cba5280dd9395552755a871Evan Cheng  bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
8294ee621125876cc954cba5280dd9395552755a871Evan Cheng
830e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// isOnlyUse - Return true if this node is the only use of N.
831e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
8324ee621125876cc954cba5280dd9395552755a871Evan Cheng  bool isOnlyUse(SDNode *N) const;
833b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner
834e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// isOperand - Return true if this node is an operand of N.
835e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  ///
83680d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng  bool isOperand(SDNode *N) const;
83780d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng
838e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// isPredecessor - Return true if this node is a predecessor of N. This node
839e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// is either an operand of N or it can be reached by recursively traversing
840e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// up the operands.
841e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng  /// NOTE: this is an expensive method. Use it carefully.
8427ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng  bool isPredecessor(SDNode *N) const;
8437ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng
84463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumOperands - Return the number of values used by this operation.
84563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
846f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumOperands() const { return NumOperands; }
84763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
848c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// getConstantOperandVal - Helper method returns the integer value of a
849c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// ConstantSDNode operand.
850c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  uint64_t getConstantOperandVal(unsigned Num) const;
851c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
85263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const SDOperand &getOperand(unsigned Num) const {
853f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(Num < NumOperands && "Invalid child # of SDNode!");
854f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    return OperandList[Num];
85563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
856c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
857f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  typedef const SDOperand* op_iterator;
858f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_begin() const { return OperandList; }
859f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  op_iterator op_end() const { return OperandList+NumOperands; }
86050f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner
86163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
8620b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  SDVTList getVTList() const {
8630b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    SDVTList X = { ValueList, NumValues };
8640b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    return X;
8650b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  };
8660b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner
86763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getNumValues - Return the number of values defined/returned by this
86863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// operator.
86963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
870f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  unsigned getNumValues() const { return NumValues; }
87163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
87263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// getValueType - Return the type of a specified result.
87363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ///
87463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MVT::ValueType getValueType(unsigned ResNo) const {
875f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(ResNo < NumValues && "Illegal result number!");
876f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    return ValueList[ResNo];
87763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
8789eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen
879f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  typedef const MVT::ValueType* value_iterator;
880f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_begin() const { return ValueList; }
881f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  value_iterator value_end() const { return ValueList+NumValues; }
88263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
8836e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  /// getOperationName - Return the opcode of this operation for printing.
8846e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner  ///
885efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner  const char* getOperationName(const SelectionDAG *G = 0) const;
886144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  static const char* getIndexedModeName(ISD::MemIndexedMode AM);
88763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  void dump() const;
888efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner  void dump(const SelectionDAG *G) const;
88963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
89063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *) { return true; }
89163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
892583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  /// Profile - Gather unique data for the node.
893583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  ///
894583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey  void Profile(FoldingSetNodeID &ID);
895583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey
89663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
89763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
898109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner
899109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  /// getValueTypeList - Return a pointer to the specified value type.
900109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  ///
901109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner  static MVT::ValueType *getValueTypeList(MVT::ValueType VT);
90263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  static SDVTList getSDVTList(MVT::ValueType VT) {
90363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    SDVTList Ret = { getValueTypeList(VT), 1 };
90463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    return Ret;
9052d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
90663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner
907f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner  SDNode(unsigned Opc, const SDOperand *Ops, unsigned NumOps)
908b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng    : NodeType(Opc), NodeId(-1) {
90963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    OperandsNeedDelete = true;
910f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner    NumOperands = NumOps;
911f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    OperandList = new SDOperand[NumOperands];
912f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner
913f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner    for (unsigned i = 0, e = NumOps; i != e; ++i) {
914f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner      OperandList[i] = Ops[i];
915f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner      SDNode *N = OperandList[i].Val;
916f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner      N->Uses.push_back(this);
9170442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner    }
918f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    ValueList = 0;
919f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    NumValues = 0;
920b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner    Prev = 0; Next = 0;
921f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner  }
9221b95095857b78e12138c22e76c7936611c51355bChris Lattner
923d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner  /// MorphNodeTo - This frees the operands of the current node, resets the
924d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner  /// opcode, types, and operands to the specified value.  This should only be
925d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner  /// used by the SelectionDAG class.
926d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner  void MorphNodeTo(unsigned Opc, SDVTList L,
927d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner                   const SDOperand *Ops, unsigned NumOps);
9281b95095857b78e12138c22e76c7936611c51355bChris Lattner
9290b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner  void setValueTypes(SDVTList L) {
930f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner    assert(NumValues == 0 && "Should not have values yet!");
9310b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    ValueList = L.VTs;
9320b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner    NumValues = L.NumVTs;
93363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
9341b95095857b78e12138c22e76c7936611c51355bChris Lattner
9358c3484c5181834e6b7060a6064ac769878101f23Chris Lattner  void addUser(SDNode *User) {
9368c3484c5181834e6b7060a6064ac769878101f23Chris Lattner    Uses.push_back(User);
9371b95095857b78e12138c22e76c7936611c51355bChris Lattner  }
938d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner  void removeUser(SDNode *User) {
939d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner    // Remove this user from the operand's use list.
940d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner    for (unsigned i = Uses.size(); ; --i) {
941d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner      assert(i != 0 && "Didn't find user!");
942d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner      if (Uses[i-1] == User) {
9438c3484c5181834e6b7060a6064ac769878101f23Chris Lattner        Uses[i-1] = Uses.back();
9448c3484c5181834e6b7060a6064ac769878101f23Chris Lattner        Uses.pop_back();
9458c3484c5181834e6b7060a6064ac769878101f23Chris Lattner        return;
946d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner      }
947d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner    }
948d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner  }
949b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng
950b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  void setNodeId(int Id) {
951b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng    NodeId = Id;
952b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng  }
95363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
95463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
95563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
95663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// Define inline functions from the SDOperand class.
95763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
95863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getOpcode() const {
95963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  return Val->getOpcode();
96063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
96163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline MVT::ValueType SDOperand::getValueType() const {
96263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  return Val->getValueType(ResNo);
96363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
96463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getNumOperands() const {
96563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  return Val->getNumOperands();
96663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
96763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline const SDOperand &SDOperand::getOperand(unsigned i) const {
96863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  return Val->getOperand(i);
96963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}
970c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chenginline uint64_t SDOperand::getConstantOperandVal(unsigned i) const {
971c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  return Val->getConstantOperandVal(i);
972c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
9730f66a9172175aa7c3055333358170581c999219bNate Begemaninline bool SDOperand::isTargetOpcode() const {
9740f66a9172175aa7c3055333358170581c999219bNate Begeman  return Val->isTargetOpcode();
9750f66a9172175aa7c3055333358170581c999219bNate Begeman}
9760f66a9172175aa7c3055333358170581c999219bNate Begemaninline unsigned SDOperand::getTargetOpcode() const {
9770f66a9172175aa7c3055333358170581c999219bNate Begeman  return Val->getTargetOpcode();
9780f66a9172175aa7c3055333358170581c999219bNate Begeman}
979a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattnerinline bool SDOperand::hasOneUse() const {
980a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner  return Val->hasNUsesOfValue(1, ResNo);
981a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner}
98263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
983d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that
984d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its
985d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand.  This node should be directly created by end-users and not added to
986d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list.
987d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode {
988c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
989d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic:
99063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  HandleSDNode(SDOperand X) : SDNode(ISD::HANDLENODE, &X, 1) {}
99148b85926524f9d29ae600123c90194cd73fd629eChris Lattner  ~HandleSDNode();
992d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner  SDOperand getValue() const { return getOperand(0); }
993d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner};
994d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner
99547725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerclass StringSDNode : public SDNode {
99647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  std::string Value;
997c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
99847725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerprotected:
99947725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  friend class SelectionDAG;
100047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  StringSDNode(const std::string &val)
100163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(ISD::STRING, 0, 0), Value(val) {
100263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(MVT::Other));
100347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  }
100447725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerpublic:
100547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  const std::string &getValue() const { return Value; }
100647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  static bool classof(const StringSDNode *) { return true; }
100747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  static bool classof(const SDNode *N) {
100847725d059b259f8a0c145478300c9e9caa006b59Chris Lattner    return N->getOpcode() == ISD::STRING;
100947725d059b259f8a0c145478300c9e9caa006b59Chris Lattner  }
101047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner};
101163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
101263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode {
101363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  uint64_t Value;
1014c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
101563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
101663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1017056f9f61d071c6c583951678f2bf543a1316efccChris Lattner  ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT)
101863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, 0), Value(val) {
101963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
102063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
102163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
102263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
102363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  uint64_t getValue() const { return Value; }
102463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
102563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int64_t getSignExtended() const {
102663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    unsigned Bits = MVT::getSizeInBits(getValueType(0));
1027f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattner    return ((int64_t)Value << (64-Bits)) >> (64-Bits);
102863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
102963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
103063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool isNullValue() const { return Value == 0; }
103163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  bool isAllOnesValue() const {
1032885a87ef8512a184a58a0ebe39705ccb221749efChris Lattner    return Value == MVT::getIntVTBitMask(getValueType(0));
103363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
103463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
103563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantSDNode *) { return true; }
103663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1037056f9f61d071c6c583951678f2bf543a1316efccChris Lattner    return N->getOpcode() == ISD::Constant ||
1038056f9f61d071c6c583951678f2bf543a1316efccChris Lattner           N->getOpcode() == ISD::TargetConstant;
103963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
104063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
104163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
104263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode {
104363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  double Value;
1044c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
104563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
104663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1047ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner  ConstantFPSDNode(bool isTarget, double val, MVT::ValueType VT)
104863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0, 0),
1049ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner      Value(val) {
105063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
105163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
105263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
105363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
105463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  double getValue() const { return Value; }
105563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
105663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// isExactlyValue - We don't rely on operator== working on double values, as
105763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
105863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// As such, this method can be used to do an exact bit-for-bit comparison of
105963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  /// two floating point values.
106058b968be853ef02d0f448e5e2c31676e361c210fJim Laskey  bool isExactlyValue(double V) const;
106163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
106263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantFPSDNode *) { return true; }
106363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1064ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner    return N->getOpcode() == ISD::ConstantFP ||
1065ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner           N->getOpcode() == ISD::TargetConstantFP;
106663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
106763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
106863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
106963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode {
107063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *TheGlobal;
1071404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng  int Offset;
1072c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
107363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
107463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
107561ca74bc3a29b2af2be7e4bd612289da8aae85b5Evan Cheng  GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT,
107661ca74bc3a29b2af2be7e4bd612289da8aae85b5Evan Cheng                      int o=0)
107763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarget ? ISD::TargetGlobalAddress : ISD::GlobalAddress, 0, 0),
1078404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng      Offset(o) {
107963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
108063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    TheGlobal = const_cast<GlobalValue*>(GA);
108163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
108263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
108363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
108463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  GlobalValue *getGlobal() const { return TheGlobal; }
1085404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng  int getOffset() const { return Offset; }
108663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
108763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const GlobalAddressSDNode *) { return true; }
108863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1089f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner    return N->getOpcode() == ISD::GlobalAddress ||
1090f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner           N->getOpcode() == ISD::TargetGlobalAddress;
109163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
109263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
109363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
109463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
109563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode {
109663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int FI;
1097c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
109863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
109963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1100afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner  FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg)
110163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, 0, 0), FI(fi) {
110263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
110363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
110463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
110563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
110663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  int getIndex() const { return FI; }
110763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
110863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const FrameIndexSDNode *) { return true; }
110963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1110afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner    return N->getOpcode() == ISD::FrameIndex ||
1111afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner           N->getOpcode() == ISD::TargetFrameIndex;
111263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
111363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
111463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
111537efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode {
111637efe6764568a3829fee26aba532283131d1a104Nate Begeman  int JTI;
1117c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
111837efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected:
111937efe6764568a3829fee26aba532283131d1a104Nate Begeman  friend class SelectionDAG;
112037efe6764568a3829fee26aba532283131d1a104Nate Begeman  JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg)
112163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, 0, 0), JTI(jti) {
112263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
112363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
112437efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic:
112537efe6764568a3829fee26aba532283131d1a104Nate Begeman
112637efe6764568a3829fee26aba532283131d1a104Nate Begeman    int getIndex() const { return JTI; }
112737efe6764568a3829fee26aba532283131d1a104Nate Begeman
112837efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const JumpTableSDNode *) { return true; }
112937efe6764568a3829fee26aba532283131d1a104Nate Begeman  static bool classof(const SDNode *N) {
113037efe6764568a3829fee26aba532283131d1a104Nate Begeman    return N->getOpcode() == ISD::JumpTable ||
113137efe6764568a3829fee26aba532283131d1a104Nate Begeman           N->getOpcode() == ISD::TargetJumpTable;
113237efe6764568a3829fee26aba532283131d1a104Nate Begeman  }
113337efe6764568a3829fee26aba532283131d1a104Nate Begeman};
113437efe6764568a3829fee26aba532283131d1a104Nate Begeman
113563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode {
1136d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  union {
1137d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Constant *ConstVal;
1138d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    MachineConstantPoolValue *MachineCPVal;
1139d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  } Val;
1140baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int Offset;  // It's a MachineConstantPoolValue if top bit is set.
1141b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned Alignment;
1142c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
114363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
114463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1145404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng  ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT,
1146404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng                     int o=0)
114763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, 0),
1148d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng      Offset(o), Alignment(0) {
1149d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
115063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
1151d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1152d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1153404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng  ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o,
1154404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng                     unsigned Align)
115563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, 0),
1156d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng      Offset(o), Alignment(Align) {
1157d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
115863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
1159d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.ConstVal = c;
1160d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1161d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1162d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng                     MVT::ValueType VT, int o=0)
116363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, 0),
1164d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng      Offset(o), Alignment(0) {
1165d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
116663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
1167d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1168d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1169d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1170d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v,
1171d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng                     MVT::ValueType VT, int o, unsigned Align)
117263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, 0),
1173d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng      Offset(o), Alignment(Align) {
1174d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert((int)Offset >= 0 && "Offset is too large");
117563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
1176d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Val.MachineCPVal = v;
1177d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    Offset |= 1 << (sizeof(unsigned)*8-1);
1178d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
117963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
118063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1181d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  bool isMachineConstantPoolEntry() const {
1182d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return (int)Offset < 0;
1183d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1184d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1185d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  Constant *getConstVal() const {
1186d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1187d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.ConstVal;
1188d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1189d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1190d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  MachineConstantPoolValue *getMachineCPVal() const {
1191d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1192d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng    return Val.MachineCPVal;
1193d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  }
1194d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
1195baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  int getOffset() const {
1196baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng    return Offset & ~(1 << (sizeof(unsigned)*8-1));
1197baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng  }
1198ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner
1199ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // Return the alignment of this constant pool object, which is either 0 (for
1200ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner  // default alignment) or log2 of the desired value.
1201b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng  unsigned getAlignment() const { return Alignment; }
120263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1203d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng  const Type *getType() const;
1204d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng
120563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ConstantPoolSDNode *) { return true; }
120663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1207aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner    return N->getOpcode() == ISD::ConstantPool ||
1208aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner           N->getOpcode() == ISD::TargetConstantPool;
120963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
121063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
121163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
121263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode {
121363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *MBB;
1214c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
121563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
121663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
121763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  BasicBlockSDNode(MachineBasicBlock *mbb)
121863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(ISD::BasicBlock, 0, 0), MBB(mbb) {
121963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(MVT::Other));
122063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
122163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
122263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
122363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  MachineBasicBlock *getBasicBlock() const { return MBB; }
122463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
122563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const BasicBlockSDNode *) { return true; }
122663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
122763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner    return N->getOpcode() == ISD::BasicBlock;
122863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
122963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
123063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
12312d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode {
12322d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *V;
1233691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth  int offset;
1234c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
12352d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected:
12362d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  friend class SelectionDAG;
1237691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth  SrcValueSDNode(const Value* v, int o)
123863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(ISD::SRCVALUE, 0, 0), V(v), offset(o) {
123963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(MVT::Other));
124063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
12412d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
12422d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic:
12432d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  const Value *getValue() const { return V; }
1244691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth  int getOffset() const { return offset; }
12452d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
12462d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SrcValueSDNode *) { return true; }
12472d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  static bool classof(const SDNode *N) {
12482d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth    return N->getOpcode() == ISD::SRCVALUE;
12492d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth  }
12502d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth};
12512d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth
125263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1253d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode {
125463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned Reg;
1255c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
125663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
125763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
1258d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner  RegisterSDNode(unsigned reg, MVT::ValueType VT)
125963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(ISD::Register, 0, 0), Reg(reg) {
126063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
126163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
126263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
126363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
126463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  unsigned getReg() const { return Reg; }
126563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
1266d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner  static bool classof(const RegisterSDNode *) { return true; }
126763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
1268d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner    return N->getOpcode() == ISD::Register;
126963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
127063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
127163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
127263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ExternalSymbolSDNode : public SDNode {
127363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *Symbol;
1274c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
127563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
127663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
12772a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth  ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT)
127863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 0, 0),
12792a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth      Symbol(Sym) {
128063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(VT));
128163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
128263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
128363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
128463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  const char *getSymbol() const { return Symbol; }
128563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
128663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const ExternalSymbolSDNode *) { return true; }
128763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
12882a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth    return N->getOpcode() == ISD::ExternalSymbol ||
12892a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth           N->getOpcode() == ISD::TargetExternalSymbol;
129063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
129163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
129263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
12937cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode {
129463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  ISD::CondCode Condition;
1295c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
129663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected:
129763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  friend class SelectionDAG;
12987cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  CondCodeSDNode(ISD::CondCode Cond)
129963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(ISD::CONDCODE, 0, 0), Condition(Cond) {
130063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(MVT::Other));
130163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
130263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic:
130363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
13047cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  ISD::CondCode get() const { return Condition; }
130563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
13067cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner  static bool classof(const CondCodeSDNode *) { return true; }
130763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  static bool classof(const SDNode *N) {
13087cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner    return N->getOpcode() == ISD::CONDCODE;
130963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner  }
131063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner};
131163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
131215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// VTSDNode - This class is used to represent MVT::ValueType's, which are used
131315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations.
131415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode {
131515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  MVT::ValueType ValueType;
1316c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
131715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected:
131815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  friend class SelectionDAG;
131963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  VTSDNode(MVT::ValueType VT) : SDNode(ISD::VALUETYPE, 0, 0), ValueType(VT) {
132063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    setValueTypes(getSDVTList(MVT::Other));
132163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  }
132215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic:
132315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
132415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  MVT::ValueType getVT() const { return ValueType; }
132515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
132615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const VTSDNode *) { return true; }
132715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  static bool classof(const SDNode *N) {
132815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner    return N->getOpcode() == ISD::VALUETYPE;
132915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner  }
133015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner};
133115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
133224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes.
133324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
133424446e253a17720f6462288255ab5ebd13b8491fEvan Chengclass LoadSDNode : public SDNode {
1335c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1336c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner
133781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // AddrMode - unindexed, pre-indexed, post-indexed.
1338144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  ISD::MemIndexedMode AddrMode;
133981c384578828dde08f63a4f030f4860a92391cddEvan Cheng
134081c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // ExtType - non-ext, anyext, sext, zext.
134181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  ISD::LoadExtType ExtType;
134281c384578828dde08f63a4f030f4860a92391cddEvan Cheng
13432e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng  // LoadedVT - VT of loaded value before extension.
13442e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng  MVT::ValueType LoadedVT;
134581c384578828dde08f63a4f030f4860a92391cddEvan Cheng
134681c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // SrcValue - Memory location for alias analysis.
134724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  const Value *SrcValue;
134881c384578828dde08f63a4f030f4860a92391cddEvan Cheng
134981c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // SVOffset - Memory location offset.
135024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  int SVOffset;
135181c384578828dde08f63a4f030f4860a92391cddEvan Cheng
135281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // Alignment - Alignment of memory location in bytes.
135324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  unsigned Alignment;
135481c384578828dde08f63a4f030f4860a92391cddEvan Cheng
135581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // IsVolatile - True if the load is volatile.
135624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool IsVolatile;
135724446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
135824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
135963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  LoadSDNode(SDOperand *ChainPtrOff,
1360144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng             ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT,
136124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng             const Value *SV, int O=0, unsigned Align=1, bool Vol=false)
136263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(ISD::LOAD, ChainPtrOff, 3),
13632e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng      AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O),
136424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      Alignment(Align), IsVolatile(Vol) {
136563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    assert((getOffset().getOpcode() == ISD::UNDEF ||
136663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner            AddrMode != ISD::UNINDEXED) &&
13678862ef148100070b7bf28beead3951464250c926Evan Cheng           "Only indexed load has a non-undef offset operand");
136824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
136924446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
137024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
137181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  const SDOperand getChain() const { return getOperand(0); }
137281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  const SDOperand getBasePtr() const { return getOperand(1); }
137381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  const SDOperand getOffset() const { return getOperand(2); }
1374144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  ISD::MemIndexedMode getAddressingMode() const { return AddrMode; }
137524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  ISD::LoadExtType getExtensionType() const { return ExtType; }
13762e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng  MVT::ValueType getLoadedVT() const { return LoadedVT; }
137724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  const Value *getSrcValue() const { return SrcValue; }
137824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  int getSrcValueOffset() const { return SVOffset; }
137924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  unsigned getAlignment() const { return Alignment; }
138024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool isVolatile() const { return IsVolatile; }
138124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
138224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const LoadSDNode *) { return true; }
138324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
138424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD;
138524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
138624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
138724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
138824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes.
138924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng///
139024446e253a17720f6462288255ab5ebd13b8491fEvan Chengclass StoreSDNode : public SDNode {
1391c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner  virtual void ANCHOR();  // Out-of-line virtual method to give class a home.
1392c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner
139381c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // AddrMode - unindexed, pre-indexed, post-indexed.
1394144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  ISD::MemIndexedMode AddrMode;
139581c384578828dde08f63a4f030f4860a92391cddEvan Cheng
139681c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // IsTruncStore - True is the op does a truncation before store.
139781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  bool IsTruncStore;
139881c384578828dde08f63a4f030f4860a92391cddEvan Cheng
13992e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng  // StoredVT - VT of the value after truncation.
140081c384578828dde08f63a4f030f4860a92391cddEvan Cheng  MVT::ValueType StoredVT;
140181c384578828dde08f63a4f030f4860a92391cddEvan Cheng
140281c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // SrcValue - Memory location for alias analysis.
140324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  const Value *SrcValue;
140481c384578828dde08f63a4f030f4860a92391cddEvan Cheng
140581c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // SVOffset - Memory location offset.
140624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  int SVOffset;
140781c384578828dde08f63a4f030f4860a92391cddEvan Cheng
140881c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // Alignment - Alignment of memory location in bytes.
140924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  unsigned Alignment;
141081c384578828dde08f63a4f030f4860a92391cddEvan Cheng
141181c384578828dde08f63a4f030f4860a92391cddEvan Cheng  // IsVolatile - True if the store is volatile.
141224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool IsVolatile;
141324446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected:
141424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  friend class SelectionDAG;
141563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner  StoreSDNode(SDOperand *ChainValuePtrOff,
1416144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng              ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT,
141724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng              const Value *SV, int O=0, unsigned Align=0, bool Vol=false)
141863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    : SDNode(ISD::STORE, ChainValuePtrOff, 4),
141924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      AddrMode(AM), IsTruncStore(isTrunc), StoredVT(SVT), SrcValue(SV),
142024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      SVOffset(O), Alignment(Align), IsVolatile(Vol) {
142163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    assert((getOffset().getOpcode() == ISD::UNDEF ||
142263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner            AddrMode != ISD::UNINDEXED) &&
14238862ef148100070b7bf28beead3951464250c926Evan Cheng           "Only indexed store has a non-undef offset operand");
142424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
142524446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic:
142624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
142781c384578828dde08f63a4f030f4860a92391cddEvan Cheng  const SDOperand getChain() const { return getOperand(0); }
14288b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  const SDOperand getValue() const { return getOperand(1); }
14298b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  const SDOperand getBasePtr() const { return getOperand(2); }
14308b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  const SDOperand getOffset() const { return getOperand(3); }
1431144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng  ISD::MemIndexedMode getAddressingMode() const { return AddrMode; }
143224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool isTruncatingStore() const { return IsTruncStore; }
143324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  MVT::ValueType getStoredVT() const { return StoredVT; }
143424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  const Value *getSrcValue() const { return SrcValue; }
143524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  int getSrcValueOffset() const { return SVOffset; }
143624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  unsigned getAlignment() const { return Alignment; }
143724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  bool isVolatile() const { return IsVolatile; }
143824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
14396d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng  static bool classof(const StoreSDNode *) { return true; }
144024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  static bool classof(const SDNode *N) {
144124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::STORE;
144224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
144324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng};
144424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
144515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner
14461080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> {
14471080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNode *Node;
14481080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned Operand;
1449ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
14501080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
14511080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic:
14521080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator==(const SDNodeIterator& x) const {
14531080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return Operand == x.Operand;
14541080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
14551080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
14561080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
14571080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNodeIterator &operator=(const SDNodeIterator &I) {
14581080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    assert(I.Node == Node && "Cannot assign iterators to two different nodes!");
14591080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    Operand = I.Operand;
14601080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
14611080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
1462ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
14631080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator*() const {
14641080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return Node->getOperand(Operand).Val;
14651080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
14661080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  pointer operator->() const { return operator*(); }
1467ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman
14681080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator& operator++() {                // Preincrement
14691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    ++Operand;
14701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return *this;
14711080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
14721080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  SDNodeIterator operator++(int) { // Postincrement
1473ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman    SDNodeIterator tmp = *this; ++*this; return tmp;
14741080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
14751080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
14761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); }
14771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static SDNodeIterator end  (SDNode *N) {
14781080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator(N, N->getNumOperands());
14791080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
14801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
14811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  unsigned getOperand() const { return Operand; }
14821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  const SDNode *getNode() const { return Node; }
14831080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
14841080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
14851080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> {
14861080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNode NodeType;
14871080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  typedef SDNodeIterator ChildIteratorType;
14881080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  static inline NodeType *getEntryNode(SDNode *N) { return N; }
1489ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_begin(NodeType *N) {
14901080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::begin(N);
14911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
1492ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman  static inline ChildIteratorType child_end(NodeType *N) {
14931080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner    return SDNodeIterator::end(N);
14941080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner  }
14951080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner};
14961080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner
1497b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<>
1498b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnerstruct ilist_traits<SDNode> {
1499b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static SDNode *getPrev(const SDNode *N) { return N->Prev; }
1500b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static SDNode *getNext(const SDNode *N) { return N->Next; }
1501b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1502b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; }
1503b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; }
1504b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1505b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static SDNode *createSentinel() {
150663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    SDNode *N = new SDNode(ISD::EntryToken, 0, 0);
150763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    N->setValueTypes(SDNode::getSDVTList(MVT::Other));
150863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner    return N;
1509b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  }
1510b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  static void destroySentinel(SDNode *N) { delete N; }
1511b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  //static SDNode *createNode(const SDNode &V) { return new SDNode(V); }
1512b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1513b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1514b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  void addNodeToList(SDNode *NTy) {}
1515b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  void removeNodeFromList(SDNode *NTy) {}
1516b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner  void transferNodesFromList(iplist<SDNode, ilist_traits> &L2,
1517b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner                             const ilist_iterator<SDNode> &X,
1518b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner                             const ilist_iterator<SDNode> &Y) {}
1519b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner};
1520b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner
1521c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD {
152224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// isNON_EXTLoad - Returns true if the specified node is a non-extending
152324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  /// load.
152424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  inline bool isNON_EXTLoad(const SDNode *N) {
152524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD &&
152624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
152724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng  }
152824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng
1529c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isEXTLoad - Returns true if the specified node is a EXTLOAD.
1530c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
1531c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isEXTLoad(const SDNode *N) {
153224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD &&
153324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
1534c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
1535c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1536c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD.
1537c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
1538c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isSEXTLoad(const SDNode *N) {
153924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD &&
154024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
1541c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
1542c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1543c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD.
1544c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  ///
1545c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  inline bool isZEXTLoad(const SDNode *N) {
154624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng    return N->getOpcode() == ISD::LOAD &&
154724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng      cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
1548c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng  }
15498b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
15508b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating
15518b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
15528b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isNON_TRUNCStore(const SDNode *N) {
15538b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng    return N->getOpcode() == ISD::STORE &&
15548b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng      !cast<StoreSDNode>(N)->isTruncatingStore();
15558b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
15568b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng
15578b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// isTRUNCStore - Returns true if the specified node is a truncating
15588b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  /// store.
15598b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  inline bool isTRUNCStore(const SDNode *N) {
15608b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng    return N->getOpcode() == ISD::STORE &&
15618b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng      cast<StoreSDNode>(N)->isTruncatingStore();
15628b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng  }
1563c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng}
1564c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
1565c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng
156663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace
156763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner
156863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif
1569