SelectionDAGNodes.h revision b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540
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 5163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the 5263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types. 5363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 5463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD { 55d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov namespace ParamFlags { 56d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov enum Flags { 57d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov NoFlagSet = 0, 58d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov ZExt = 1<<0, ///< Parameter should be zero extended 59d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov ZExtOffs = 0, 60d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov SExt = 1<<1, ///< Parameter should be sign extended 61d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov SExtOffs = 1, 62d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov InReg = 1<<2, ///< Parameter should be passed in register 63d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov InRegOffs = 2, 64d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov StructReturn = 1<<3, ///< Hidden struct-return pointer 65d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov StructReturnOffs = 3, 66d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov OrigAlignment = 0x1F<<27, 67d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov OrigAlignmentOffs = 27 68d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov }; 69d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov } 70d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov 7163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 7263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::NodeType enum - This enum defines all of the operators valid in a 7363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SelectionDAG. 7463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 7563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum NodeType { 763258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // DELETED_NODE - This is an illegal flag value that is used to catch 773258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // errors. This opcode is not a legal opcode for any node. 783258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner DELETED_NODE, 793258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner 808a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // EntryToken - This is the marker used to indicate the start of the region. 818a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner EntryToken, 828a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner 838c4bde36a339b1c538002e819daff84caae4cbadReid Spencer // Token factor - This node takes multiple tokens as input and produces a 848a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // single token result. This is used to represent the fact that the operand 858a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // operators are independent of each other. 868a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner TokenFactor, 87f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman 88f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // AssertSext, AssertZext - These nodes record if a register contains a 89f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // value that has already been zero or sign extended from a narrower type. 90f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // These nodes take two operands. The first is the node that has already 91f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // been extended, and the second is a value type node indicating the width 92f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // of the extension 93f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman AssertSext, AssertZext, 94ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 958a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // Various leaf nodes. 961ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng STRING, BasicBlock, VALUETYPE, CONDCODE, Register, 971ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng Constant, ConstantFP, 98b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio GlobalAddress, GlobalTLSAddress, FrameIndex, 99b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio JumpTable, ConstantPool, ExternalSymbol, 1001ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng 10182c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth // The address of the GOT 10282c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth GLOBAL_OFFSET_TABLE, 103bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman 104bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and 105bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // llvm.returnaddress on the DAG. These nodes take one operand, the index 106bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // of the frame or return address to return. An index of zero corresponds 107bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // to the current function's frame or return address, an index of one to the 108bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // parent's frame or return address, and so on. 109bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman FRAMEADDR, RETURNADDR, 110f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 111f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the 112f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // address of the exception block on entry to an landing pad block. 113f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EXCEPTIONADDR, 114f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 115f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents 116f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // the selection index of the exception thrown. 117f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EHSELECTION, 118beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth 119ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // TargetConstant* - Like Constant*, but the DAG does not do any folding or 120ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // simplification of the constant. 121056f9f61d071c6c583951678f2bf543a1316efccChris Lattner TargetConstant, 122ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner TargetConstantFP, 123f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner 124f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or 125f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // anything else with this node, and this is valid in the target-specific 126f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // dag, turning into a GlobalAddress operand. 127f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner TargetGlobalAddress, 128b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio TargetGlobalTLSAddress, 129afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner TargetFrameIndex, 13037efe6764568a3829fee26aba532283131d1a104Nate Begeman TargetJumpTable, 131aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner TargetConstantPool, 1322a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth TargetExternalSymbol, 13372601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner 134ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) 135ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with no side effects. 136ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// The first operand is the ID number of the intrinsic from the 137ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The 138ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// node has returns the result of the intrinsic. 139ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_WO_CHAIN, 140ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 141ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) 142ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 143ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// returns a result. The first operand is a chain pointer. The second is 144ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The 145ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// operands to the intrinsic follow. The node has two results, the result 146ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// of the intrinsic and an output chain. 147ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_W_CHAIN, 14863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 149ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) 150ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 151ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// does not return a result. The first operand is a chain pointer. The 152ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// second is the ID number of the intrinsic from the llvm::Intrinsic 153ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// namespace. The operands to the intrinsic follow. 154ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_VOID, 155ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 156d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // CopyToReg - This node has three operands: a chain, a register number to 157d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // set to this value, and a value. 15863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyToReg, 15963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 16063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // CopyFromReg - This node indicates that the input value is a virtual or 16163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // physical register that is defined outside of the scope of this 16218c2f13e0f9d0e5d6227cf6d1881e9ee3d1b6109Chris Lattner // SelectionDAG. The register is available from the RegSDNode object. 16363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyFromReg, 16463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 165fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman // UNDEF - An undefined node 166fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman UNDEF, 167681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner 168b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node 169b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// represents the formal arguments for a function. CC# is a Constant value 170b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// indicating the calling convention of the function, and ISVARARG is a 171b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// flag that indicates whether the function is varargs or not. This node 172b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// has one result value for each incoming argument, plus one for the output 173b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// chain. It must be custom legalized. See description of CALL node for 174b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FLAG argument contents explanation. 175c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner /// 176681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner FORMAL_ARGUMENTS, 1776c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner 1786c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE, 179b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn) 1806c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// This node represents a fully general function call, before the legalizer 181b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// runs. This has one result value for each argument / flag pair, plus 182b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// a chain result. It must be custom legalized. Flag argument indicates 183b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// misc. argument attributes. Currently: 184b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 0 - signness 185b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 1 - 'inreg' attribute 186b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 2 - 'sret' attribute 18713a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// Bits 31:27 - argument ABI alignment in the first argument piece and 18813a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// alignment '1' in other argument pieces. 1896c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner CALL, 190fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman 19163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // EXTRACT_ELEMENT - This is used to get the first or second (determined by 19263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // a Constant, which is required to be operand #1), element of the aggregate 19363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // value specified as operand #0. This is only for use before legalization, 19463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // for values that will be broken into multiple registers. 19563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner EXTRACT_ELEMENT, 19663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 19763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given 19863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // two values of the same integer value type, this produces a value twice as 19963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // big. Like EXTRACT_ELEMENT, this can only be used before legalization. 20063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BUILD_PAIR, 201006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner 202006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // MERGE_VALUES - This node takes multiple discrete operands and returns 203006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // them all as its individual results. This nodes has exactly the same 204006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // number of inputs and outputs, and is only valid before legalization. 205006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // This node is useful for some pieces of the code generator that want to 206006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // think about a single node with multiple results, not multiple nodes. 207006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner MERGE_VALUES, 20863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 209615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple integer binary arithmetic operators. 210bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, 211615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner 21255e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // CARRY_FALSE - This node is used when folding other nodes, 21355e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // like ADDC/SUBC, which indicate the carry result is always false. 21455e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner CARRY_FALSE, 21555e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner 216551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-setting nodes for multiple precision addition and subtraction. 217551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // These nodes take two operands of the same value type, and produce two 218551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // results. The first result is the normal add or sub result, the second 219551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // result is the carry flag result. 220551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDC, SUBC, 221551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 222551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-using nodes for multiple precision addition and subtraction. These 223551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // nodes take three operands: The first two are the normal lhs and rhs to 224551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // the add or sub, and the third is the input carry flag. These nodes 225551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // produce two results; the normal result of the add or sub, and the output 226551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // carry flag. These nodes both read and write a carry flag to allow them 227551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // to them to be chained together for add and sub of arbitrarily large 228551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // values. 229551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDE, SUBE, 230551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 231615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple binary floating point operators. 232615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner FADD, FSUB, FMUL, FDIV, FREM, 23338bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 23438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This 23538bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // DAG node does not require that X and Y have the same type, just that they 23638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // are both floating point. X and the result must have the same type. 23738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(f32, f64) is allowed. 23838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner FCOPYSIGN, 239fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner 24022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// BUILD_VECTOR(ELT1, ELT2, ELT3, ELT4,...) - Return a vector 24122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// with the specified, possibly variable, elements. The number of elements 24222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// is required to be a power of two. 24322232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner BUILD_VECTOR, 24422232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2457f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element 2467f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// at IDX replaced with VAL. 24722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner INSERT_VECTOR_ELT, 2484b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner 2494b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR 2507f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// identified by the (potentially variable) element number IDX. 2514b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner EXTRACT_VECTOR_ELT, 25222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2537f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of 2547f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector type with the same length and element type, this produces a 2557f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// concatenated vector result value, with length equal to the sum of the 256b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman /// lengths of the input vectors. 2577f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman CONCAT_VECTORS, 2586595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman 2597f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an 2607f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector value) starting with the (potentially variable) element number 2617f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// IDX, which must be a multiple of the result vector length. 2627f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman EXTRACT_SUBVECTOR, 2636595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman 26449c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same 26549c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values 26649c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// (regardless of whether its datatype is legal or not) that indicate 26749c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// which value each result element will get. The elements of VEC1/VEC2 are 26849c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// enumerated in order. This is quite similar to the Altivec 'vperm' 26949c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// instruction, except that the indices must be constants and are in terms 27049c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// of the element size of VEC1/VEC2, not in terms of bytes. 27149c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner VECTOR_SHUFFLE, 27249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner 273210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a 274210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// scalar value into the low element of the resultant vector type. The top 275210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// elements of the vector are undefined. 276210721aecc0916315f61660dc387a96b89ec423bChris Lattner SCALAR_TO_VECTOR, 277210721aecc0916315f61660dc387a96b89ec423bChris Lattner 278bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing 279bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner // an unsigned/signed value of type i[2*n], then return the top part. 280bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner MULHU, MULHS, 28163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 28235ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // Bitwise operators - logical and, logical or, logical xor, shift left, 28335ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // shift right algebraic (shift in sign bits), shift right logical (shift in 28435ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // zeroes), rotate left, rotate right, and byteswap. 28535ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP, 28663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 287691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth // Counting operators 288691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth CTTZ, CTLZ, CTPOP, 289691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth 290fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner // Select(COND, TRUEVAL, FALSEVAL) 2919373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT, 2929373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman 2939373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // Select with condition operator - This selects between a true value and 2949373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // a false value (ops #2 and #3) based on the boolean result of comparing 2959373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // the lhs and rhs (ops #0 and #1) of a conditional expression with the 2969373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // condition code in op #4, a CondCodeSDNode. 2979373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT_CC, 29863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 29963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SetCC operator - This evaluates to a boolean (i1) true value if the 3007cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // condition is true. The operands to this are the left and right operands 3017cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // to compare (ops #0, and #1) and the condition code to compare them with 3027cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // (op #2) as a CondCodeSDNode. 30363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETCC, 30463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 30514c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded 30614c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // integer shift operations, just like ADD/SUB_PARTS. The operation 30714c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // ordering is: 3086b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner // [Lo,Hi] = op [LoLHS,HiLHS], Amt 30914c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner SHL_PARTS, SRA_PARTS, SRL_PARTS, 31014c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner 31163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Conversion operators. These are all single input single output 31263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operations. For all of these, the result type must be strictly 31363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // wider or narrower (depending on the operation) than the source 31463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // type. 31563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 31663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SIGN_EXTEND - Used for integer types, replicating the sign bit 31763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // into new bits. 31863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SIGN_EXTEND, 31963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 32063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // ZERO_EXTEND - Used for integer types, zeroing the new bits. 32163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ZERO_EXTEND, 32263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3237e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner // ANY_EXTEND - Used for integer types. The high bits are undefined. 3247e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner ANY_EXTEND, 3257e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner 32663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // TRUNCATE - Completely drop the high bits. 32763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner TRUNCATE, 32863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3291645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign 3301645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // depends on the first letter) to floating point. 3311645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner SINT_TO_FP, 3321645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner UINT_TO_FP, 3331645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 334ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to 335ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // sign extend a small value in a large integer register (e.g. sign 336ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // extending the low 8 bits of a 32-bit register to fill the top 24 bits 33715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // with the 7th bit). The size of the smaller type is indicated by the 1th 33815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // operand, a ValueType node. 339859157daee6a4b49e99921832e1dde065167b317Chris Lattner SIGN_EXTEND_INREG, 340859157daee6a4b49e99921832e1dde065167b317Chris Lattner 3411645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // FP_TO_[US]INT - Convert a floating point value to a signed or unsigned 3421645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // integer. 3431645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_SINT, 3441645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_UINT, 3451645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 34663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // FP_ROUND - Perform a rounding operation from the current 347859157daee6a4b49e99921832e1dde065167b317Chris Lattner // precision down to the specified precision (currently always 64->32). 34863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_ROUND, 34963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 350859157daee6a4b49e99921832e1dde065167b317Chris Lattner // FP_ROUND_INREG - This operator takes a floating point register, and 351859157daee6a4b49e99921832e1dde065167b317Chris Lattner // rounds it to a floating point value. It then promotes it and returns it 352859157daee6a4b49e99921832e1dde065167b317Chris Lattner // in a register of the same size. This operation effectively just discards 35315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // excess precision. The type to round down to is specified by the 1th 35415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // operation, a VTSDNode (currently always 64->32->64). 355859157daee6a4b49e99921832e1dde065167b317Chris Lattner FP_ROUND_INREG, 356859157daee6a4b49e99921832e1dde065167b317Chris Lattner 35763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // FP_EXTEND - Extend a smaller FP type into a larger FP type. 35863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_EXTEND, 35963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3601ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // BIT_CONVERT - Theis operator converts between integer and FP values, as 3611ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // if one was stored to memory as integer and the other was loaded from the 36280f55abf009c86bc03821e10746832f88f8a735fChris Lattner // same address (or equivalently for vector format conversions, etc). The 36380f55abf009c86bc03821e10746832f88f8a735fChris Lattner // source and result are required to have the same bit size (e.g. 36480f55abf009c86bc03821e10746832f88f8a735fChris Lattner // f32 <-> i32). This can also be used for int-to-int or fp-to-fp 36580f55abf009c86bc03821e10746832f88f8a735fChris Lattner // conversions, but that is a noop, deleted by getNode(). 3661ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner BIT_CONVERT, 3671ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner 368dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI - Perform unary floating point 369dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner // negation, absolute value, square root, sine and cosine, and powi 370dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner // operations. 371dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, 37238bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 3738862ef148100070b7bf28beead3951464250c926Evan Cheng // LOAD and STORE have token chains as their first operand, then the same 3748862ef148100070b7bf28beead3951464250c926Evan Cheng // operands as an LLVM load/store instruction, then an offset node that 3758862ef148100070b7bf28beead3951464250c926Evan Cheng // is added / subtracted from the base pointer to form the address (for 3768862ef148100070b7bf28beead3951464250c926Evan Cheng // indexed memory ops). 37763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner LOAD, STORE, 3785fbb5d2459a5410590f285250faa604576308a93Nate Begeman 3791cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner // TRUNCSTORE - This operators truncates (for integer) or rounds (for FP) a 3801cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner // value and stores it to memory in one operation. This can be used for 381f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner // either integer or floating point operands. The first four operands of 382f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner // this are the same as a standard store. The fifth is the ValueType to 383f7db8c69a12582c7d1ff7c5f25c948dca2dbf7dcChris Lattner // store it as (which will be smaller than the source value). 3841cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner TRUNCSTORE, 3851cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner 38663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned 38757fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // to a specified boundary. This node always has two return values: a new 38857fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // stack pointer value and a chain. The first operand is the token chain, 38957fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // the second is the number of bytes to allocate, and the third is the 39057fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment boundary. The size is guaranteed to be a multiple of the stack 39157fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment, and the alignment is guaranteed to be bigger than the stack 39274fe063e90045931eefaba561730e6a9175ced78Chris Lattner // alignment (if required) or 0 to get standard stack alignment. 39363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner DYNAMIC_STACKALLOC, 39463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 39563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Control flow instructions. These all have token chains. 396ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 39763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BR - Unconditional branch. The first operand is the chain 39863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operand, the second is the MBB to branch to. 39963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BR, 40063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 40137efe6764568a3829fee26aba532283131d1a104Nate Begeman // BRIND - Indirect branch. The first operand is the chain, the second 40237efe6764568a3829fee26aba532283131d1a104Nate Begeman // is the value to branch to, which must be of the same type as the target's 40337efe6764568a3829fee26aba532283131d1a104Nate Begeman // pointer type. 40437efe6764568a3829fee26aba532283131d1a104Nate Begeman BRIND, 405c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng 406c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // BR_JT - Jumptable branch. The first operand is the chain, the second 407c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // is the jumptable index, the last one is the jumptable entry index. 408c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng BR_JT, 40937efe6764568a3829fee26aba532283131d1a104Nate Begeman 41063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BRCOND - Conditional branch. The first operand is the chain, 41163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // the second is the condition, the third is the block to branch 41263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // to if the condition is true. 41363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BRCOND, 41463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4157cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in 4167cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // that the condition is represented as condition code, and two nodes to 4177cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // compare, rather than as a combined SetCC node. The operands in order are 4187cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // chain, cc, lhs, rhs, block to branch to if condition is true. 4197cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman BR_CC, 4207cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman 42163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // RET - Return from function. The first operand is the chain, 4228e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // and any subsequent operands are pairs of return value and return value 4238e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // signness for the function. This operation can have variable number of 4248e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // operands. 42563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner RET, 42663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4277572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // INLINEASM - Represents an inline asm block. This node always has two 4287572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // return values: a chain and a flag result. The inputs are as follows: 4297572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #0 : Input chain. 4307572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string. 4317572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+2: A RegisterNode. 4327572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def 4337572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #last: Optional, an incoming flag. 4347572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner INLINEASM, 4351ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey 4361ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // LABEL - Represents a label in mid basic block used to track 4371ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // locations needed for debug and exception handling tables. This node 4381ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // returns a chain. 4391ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // Operand #0 : input chain. 4401ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // Operand #1 : module unique number use to identify the label. 4411ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey LABEL, 442f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 4435a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a 4445a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // value, the same type as the pointer type for the system, and an output 4455a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // chain. 4465a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKSAVE, 4475a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 4485a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKRESTORE has two operands, an input chain and a pointer to restore to 4495a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // it returns an output chain. 4505a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKRESTORE, 4515a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 452ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain, and the rest 453ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner // correspond to the operands of the LLVM intrinsic functions. The only 454ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner // result is a token chain. The alignment argument is guaranteed to be a 455ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner // Constant node. 456ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMSET, 457ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMMOVE, 458ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMCPY, 459ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 46016cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of 46116cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // a call sequence, and carry arbitrary information that target might want 46216cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // to know. The first operand is a chain, the rest are specified by the 46316cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // target and not touched by the DAG optimizers. 46416cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_START, // Beginning of a call sequence 46516cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_END, // End of a call sequence 466acc398c195a697795bff3245943d104eb19192b9Nate Begeman 467acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAARG - VAARG has three operands: an input chain, a pointer, and a 468acc398c195a697795bff3245943d104eb19192b9Nate Begeman // SRCVALUE. It returns a pair of values: the vaarg value and a new chain. 469acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAARG, 470acc398c195a697795bff3245943d104eb19192b9Nate Begeman 471acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VACOPY - VACOPY has five operands: an input chain, a destination pointer, 472acc398c195a697795bff3245943d104eb19192b9Nate Begeman // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the 473acc398c195a697795bff3245943d104eb19192b9Nate Begeman // source. 474acc398c195a697795bff3245943d104eb19192b9Nate Begeman VACOPY, 475acc398c195a697795bff3245943d104eb19192b9Nate Begeman 476acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a 477acc398c195a697795bff3245943d104eb19192b9Nate Begeman // pointer, and a SRCVALUE. 478acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAEND, VASTART, 47963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 48021074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner // SRCVALUE - This corresponds to a Value*, and is used to associate memory 48121074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner // locations with their value. This allows one use alias analysis 48221074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner // information in the backend. 48321074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner SRCVALUE, 48421074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner 485e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman // PCMARKER - This corresponds to the pcmarker intrinsic. 48695762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth PCMARKER, 48763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 488aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic. 4898b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // The only operand is a chain and a value and a chain are produced. The 4908b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // value is the contents of the architecture specific cycle counter like 4918b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // register (or other high accuracy low latency clock source) 492aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth READCYCLECOUNTER, 493aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth 494d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner // HANDLENODE node - Used as a handle for various purposes. 495d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner HANDLENODE, 4962d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 49747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // LOCATION - This node is used to represent a source location for debug 49847725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // info. It takes token chain as input, then a line number, then a column 49947725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // number, then a filename, then a working dir. It produces a token chain 50047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // as output. 50147725d059b259f8a0c145478300c9e9caa006b59Chris Lattner LOCATION, 50247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner 503f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey // DEBUG_LOC - This node is used to represent source line information 504abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // embedded in the code. It takes a token chain as input, then a line 50544c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey // number, then a column then a file id (provided by MachineModuleInfo.) It 506abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // produces a token chain as output. 507f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey DEBUG_LOC, 508f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey 50963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILTIN_OP_END - This must be the last enum value in this list. 510410354fe0c052141dadeca939395743f8dd58e38Chris Lattner BUILTIN_OP_END 51163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 51263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 513322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// Node predicates 514322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 515a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng /// isBuildVectorAllOnes - Return true if the specified node is a 516322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// BUILD_VECTOR where all of the elements are ~0 or undef. 517a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng bool isBuildVectorAllOnes(const SDNode *N); 5184a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng 5194a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// isBuildVectorAllZeros - Return true if the specified node is a 5204a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// BUILD_VECTOR where all of the elements are 0 or undef. 5214a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng bool isBuildVectorAllZeros(const SDNode *N); 522322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 52363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 524144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// MemIndexedMode enum - This enum defines the load / store indexed 525144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// addressing modes. 52624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 52724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// UNINDEXED "Normal" load / store. The effective address is already 52824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computed and is available in the base pointer. The offset 52981c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// operand is always undefined. In addition to producing a 53081c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// chain, an unindexed load produces one value (result of the 53181c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// load); an unindexed store does not produces a value. 53224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 53335acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// PRE_INC Similar to the unindexed mode where the effective address is 5348862ef148100070b7bf28beead3951464250c926Evan Cheng /// PRE_DEC the value of the base pointer add / subtract the offset. 5358862ef148100070b7bf28beead3951464250c926Evan Cheng /// It considers the computation as being folded into the load / 53624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// store operation (i.e. the load / store does the address 53724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computation as well as performing the memory transaction). 53881c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// The base operand is always undefined. In addition to 53981c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// producing a chain, pre-indexed load produces two values 54081c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// (result of the load and the result of the address 54181c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// computation); a pre-indexed store produces one value (result 54281c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// of the address computation). 54324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 54435acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// POST_INC The effective address is the value of the base pointer. The 5458862ef148100070b7bf28beead3951464250c926Evan Cheng /// POST_DEC value of the offset operand is then added to / subtracted 5468862ef148100070b7bf28beead3951464250c926Evan Cheng /// from the base after memory transaction. In addition to 5478862ef148100070b7bf28beead3951464250c926Evan Cheng /// producing a chain, post-indexed load produces two values 5488862ef148100070b7bf28beead3951464250c926Evan Cheng /// (the result of the load and the result of the base +/- offset 5498862ef148100070b7bf28beead3951464250c926Evan Cheng /// computation); a post-indexed store produces one value (the 5508862ef148100070b7bf28beead3951464250c926Evan Cheng /// the result of the base +/- offset computation). 55124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 552144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng enum MemIndexedMode { 55324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng UNINDEXED = 0, 55435acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_INC, 55535acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_DEC, 55635acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng POST_INC, 557144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng POST_DEC, 558144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng LAST_INDEXED_MODE 55924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng }; 56024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 56124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng //===--------------------------------------------------------------------===// 562c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// LoadExtType enum - This enum defines the three variants of LOADEXT 563c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// (load with extension). 564c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 56524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// SEXTLOAD loads the integer operand and sign extends it to a larger 56624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 56724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// ZEXTLOAD loads the integer operand and zero extends it to a larger 56824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 56924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// EXTLOAD is used for three things: floating point extending loads, 57024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer extending loads [the top bits are undefined], and vector 57124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// extending loads [load into low elt]. 57224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 573c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng enum LoadExtType { 57424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng NON_EXTLOAD = 0, 575c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng EXTLOAD, 576c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng SEXTLOAD, 577c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng ZEXTLOAD, 578c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng LAST_LOADX_TYPE 579c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng }; 580c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 581c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng //===--------------------------------------------------------------------===// 58263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::CondCode enum - These are ordered carefully to make the bitfields 58363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// below work out, when considering SETFALSE (something that never exists 58463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered 58563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal 58663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to. If the "N" column is 1, the result of the comparison is undefined if 58763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the input is a NAN. 58863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 58963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// All of these (except for the 'always folded ops') should be handled for 59063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT, 59163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used. 59263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 59363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Note that these are laid out in a specific order to allow bit-twiddling 59463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to transform conditions. 59563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum CondCode { 59663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Opcode N U L G E Intuitive operation 59763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE, // 0 0 0 0 Always false (always folded) 59863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOEQ, // 0 0 0 1 True if ordered and equal 59963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGT, // 0 0 1 0 True if ordered and greater than 60063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGE, // 0 0 1 1 True if ordered and greater than or equal 60163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLT, // 0 1 0 0 True if ordered and less than 60263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLE, // 0 1 0 1 True if ordered and less than or equal 60363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETONE, // 0 1 1 0 True if ordered and operands are unequal 60463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETO, // 0 1 1 1 True if ordered (no nans) 60563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 60663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUEQ, // 1 0 0 1 True if unordered or equal 60763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGT, // 1 0 1 0 True if unordered or greater than 60863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGE, // 1 0 1 1 True if unordered, greater than, or equal 60963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETULT, // 1 1 0 0 True if unordered or less than 610ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETULE, // 1 1 0 1 True if unordered, less than, or equal 61163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUNE, // 1 1 1 0 True if unordered or not equal 61263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE, // 1 1 1 1 Always true (always folded) 61363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Don't care operations: undefined if the input is a nan. 61463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE2, // 1 X 0 0 0 Always false (always folded) 61563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETEQ, // 1 X 0 0 1 True if equal 61663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGT, // 1 X 0 1 0 True if greater than 61763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGE, // 1 X 0 1 1 True if greater than or equal 61863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETLT, // 1 X 1 0 0 True if less than 619ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETLE, // 1 X 1 0 1 True if less than or equal 62063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETNE, // 1 X 1 1 0 True if not equal 62163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE2, // 1 X 1 1 1 Always true (always folded) 62263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 623410354fe0c052141dadeca939395743f8dd58e38Chris Lattner SETCC_INVALID // Marker value. 62463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 62563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 62663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isSignedIntSetCC - Return true if this is a setcc instruction that 62763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs a signed comparison when used with integer operands. 62863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isSignedIntSetCC(CondCode Code) { 62963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE; 63063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 63163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 63263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isUnsignedIntSetCC - Return true if this is a setcc instruction that 63363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs an unsigned comparison when used with integer operands. 63463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isUnsignedIntSetCC(CondCode Code) { 63563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE; 63663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 63763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 63863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isTrueWhenEqual - Return true if the specified condition returns true if 63963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the two operands to the condition are equal. Note that if one of the two 64063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operands is a NaN, this value is meaningless. 64163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isTrueWhenEqual(CondCode Cond) { 64263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond & 1) != 0; 64363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 64463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 64563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getUnorderedFlavor - This function returns 0 if the condition is always 64663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// false if an operand is a NaN, 1 if the condition is always true if the 64763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operand is a NaN, and 2 if the condition is undefined if the operand is a 64863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// NaN. 64963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getUnorderedFlavor(CondCode Cond) { 65063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond >> 3) & 3; 65163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 65263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 65363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCInverse - Return the operation corresponding to !(X op Y), where 65463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 'op' is a valid SetCC operation. 65563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCInverse(CondCode Operation, bool isInteger); 65663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 65763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) 65863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// when given the operation for (X op Y). 65963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCSwappedOperands(CondCode Operation); 66063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 66163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCOrOperation - Return the result of a logical OR between different 66263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This 66363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 66463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 66563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger); 66663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 66763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCAndOperation - Return the result of a logical AND between 66863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This 66963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 67063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 67163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger); 67263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm::ISD namespace 67363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 67463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 67563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===// 67663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple 67763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation. Many nodes return multiple values, 67863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns 67963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number 68063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values). 68163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 68263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that 68363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node. This pair 68463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of information is represented with the SDOperand value type. 68563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 686f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerclass SDOperand { 687f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerpublic: 68863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDNode *Val; // The node defining the value we are using. 68963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned ResNo; // Which return value of the node we are using. 69063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 691ace44dbbabe9ee0498834957632df2af0dbf9c59Reid Spencer SDOperand() : Val(0), ResNo(0) {} 69263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} 69363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 69463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator==(const SDOperand &O) const { 69563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val == O.Val && ResNo == O.ResNo; 69663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 69763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator!=(const SDOperand &O) const { 69863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return !operator==(O); 69963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 70063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator<(const SDOperand &O) const { 70163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val < O.Val || (Val == O.Val && ResNo < O.ResNo); 70263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 70363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 70463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDOperand getValue(unsigned R) const { 70563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return SDOperand(Val, R); 70663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 70763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 708bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng // isOperand - Return true if this node is an operand of N. 709bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng bool isOperand(SDNode *N) const; 710bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng 71163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the ValueType of the referenced return value. 71263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 71363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline MVT::ValueType getValueType() const; 714ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 71563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Forwarding methods - These forward to the corresponding methods in SDNode. 71663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getOpcode() const; 71763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getNumOperands() const; 71863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline const SDOperand &getOperand(unsigned i) const; 719c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline uint64_t getConstantOperandVal(unsigned i) const; 7200f66a9172175aa7c3055333358170581c999219bNate Begeman inline bool isTargetOpcode() const; 7210f66a9172175aa7c3055333358170581c999219bNate Begeman inline unsigned getTargetOpcode() const; 722a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner 723a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner /// hasOneUse - Return true if there is exactly one operation using this 724a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner /// result value of the defining operator. 725a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner inline bool hasOneUse() const; 72663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 72763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 72863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 72963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on 73063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperands as if they were SDNode*'s. 73163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<SDOperand> { 73263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 73363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static SimpleType getSimplifiedValue(const SDOperand &Val) { 73463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return static_cast<SimpleType>(Val.Val); 73563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 73663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 73763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<const SDOperand> { 73863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 73963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static SimpleType getSimplifiedValue(const SDOperand &Val) { 74063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return static_cast<SimpleType>(Val.Val); 74163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 74263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 74363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 74463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG. 74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 747583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskeyclass SDNode : public FoldingSetNode { 7480442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// NodeType - The operation that this node performs. 7490442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 7500442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner unsigned short NodeType; 75163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 75263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true, 75363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// then they will be delete[]'d when the node is destroyed. 75463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner bool OperandsNeedDelete : 1; 7550442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 756b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// NodeId - Unique id per SDNode in the DAG. 757b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int NodeId; 7580442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 759f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// OperandList - The values that are used by this operation. 7600442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 761f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner SDOperand *OperandList; 762f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 763f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// ValueList - The types of the values this node defines. SDNode's may 764f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// define multiple values simultaneously. 7652fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner const MVT::ValueType *ValueList; 76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 767f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// NumOperands/NumValues - The number of entries in the Operand/Value list. 768f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned short NumOperands, NumValues; 769b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 770b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner /// Prev/Next pointers - These pointers form the linked list of of the 771b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner /// AllNodes list in the current DAG. 772b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner SDNode *Prev, *Next; 773b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner friend struct ilist_traits<SDNode>; 77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Uses - These are all of the SDNode's that use a value produced by this 77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// node. 7775892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner SmallVector<SDNode*,3> Uses; 778917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner 779917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner // Out-of-line virtual method to give class a home. 780917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner virtual void ANCHOR(); 78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 782b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner virtual ~SDNode() { 783b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner assert(NumOperands == 0 && "Operand list not cleared before deletion"); 7843258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner NodeType = ISD::DELETED_NODE; 785b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 786b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Accessors 78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // 79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getOpcode() const { return NodeType; } 7910f66a9172175aa7c3055333358170581c999219bNate Begeman bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } 7920f66a9172175aa7c3055333358170581c999219bNate Begeman unsigned getTargetOpcode() const { 7930f66a9172175aa7c3055333358170581c999219bNate Begeman assert(isTargetOpcode() && "Not a target opcode!"); 7940f66a9172175aa7c3055333358170581c999219bNate Begeman return NodeType - ISD::BUILTIN_OP_END; 7950f66a9172175aa7c3055333358170581c999219bNate Begeman } 79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner size_t use_size() const { return Uses.size(); } 79863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool use_empty() const { return Uses.empty(); } 79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool hasOneUse() const { return Uses.size() == 1; } 80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 801b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// getNodeId - Return the unique node id. 802b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// 803b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int getNodeId() const { return NodeId; } 8040442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 8055892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner typedef SmallVector<SDNode*,3>::const_iterator use_iterator; 8067ece380440238ad0630a225b85a09a2dbed1165aChris Lattner use_iterator use_begin() const { return Uses.begin(); } 8077ece380440238ad0630a225b85a09a2dbed1165aChris Lattner use_iterator use_end() const { return Uses.end(); } 8087ece380440238ad0630a225b85a09a2dbed1165aChris Lattner 809b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the 810b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// indicated value. This method ignores uses of other values defined by this 811b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// operation. 8124ee621125876cc954cba5280dd9395552755a871Evan Cheng bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; 8134ee621125876cc954cba5280dd9395552755a871Evan Cheng 814e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// isOnlyUse - Return true if this node is the only use of N. 815e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 8164ee621125876cc954cba5280dd9395552755a871Evan Cheng bool isOnlyUse(SDNode *N) const; 817b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner 818e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// isOperand - Return true if this node is an operand of N. 819e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 82080d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng bool isOperand(SDNode *N) const; 82180d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng 822e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// isPredecessor - Return true if this node is a predecessor of N. This node 823e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// is either an operand of N or it can be reached by recursively traversing 824e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// up the operands. 825e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// NOTE: this is an expensive method. Use it carefully. 8267ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng bool isPredecessor(SDNode *N) const; 8277ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng 82863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumOperands - Return the number of values used by this operation. 82963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 830f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumOperands() const { return NumOperands; } 83163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 832c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// getConstantOperandVal - Helper method returns the integer value of a 833c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// ConstantSDNode operand. 834c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng uint64_t getConstantOperandVal(unsigned Num) const; 835c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 83663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const SDOperand &getOperand(unsigned Num) const { 837f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(Num < NumOperands && "Invalid child # of SDNode!"); 838f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return OperandList[Num]; 83963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 840c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 841f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner typedef const SDOperand* op_iterator; 842f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_begin() const { return OperandList; } 843f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_end() const { return OperandList+NumOperands; } 84450f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner 84563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 8460b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList getVTList() const { 8470b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList X = { ValueList, NumValues }; 8480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner return X; 8490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner }; 8500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 85163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumValues - Return the number of values defined/returned by this 85263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operator. 85363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 854f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumValues() const { return NumValues; } 85563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 85663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the type of a specified result. 85763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 85863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MVT::ValueType getValueType(unsigned ResNo) const { 859f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(ResNo < NumValues && "Illegal result number!"); 860f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return ValueList[ResNo]; 86163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 8629eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen 863f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner typedef const MVT::ValueType* value_iterator; 864f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_begin() const { return ValueList; } 865f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_end() const { return ValueList+NumValues; } 86663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 8676e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// getOperationName - Return the opcode of this operation for printing. 8686e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// 869ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer std::string getOperationName(const SelectionDAG *G = 0) const; 870144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng static const char* getIndexedModeName(ISD::MemIndexedMode AM); 87163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner void dump() const; 872efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner void dump(const SelectionDAG *G) const; 87363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 87463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *) { return true; } 87563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 876583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// Profile - Gather unique data for the node. 877583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// 878583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey void Profile(FoldingSetNodeID &ID); 879583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey 88063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 88163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 882109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner 883109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// getValueTypeList - Return a pointer to the specified value type. 884109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// 885109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner static MVT::ValueType *getValueTypeList(MVT::ValueType VT); 88663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner static SDVTList getSDVTList(MVT::ValueType VT) { 88763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner SDVTList Ret = { getValueTypeList(VT), 1 }; 88863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner return Ret; 8892d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 89063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 891ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps) 892b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng : NodeType(Opc), NodeId(-1) { 89363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner OperandsNeedDelete = true; 894f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner NumOperands = NumOps; 895bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = NumOps ? new SDOperand[NumOperands] : 0; 896f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 897bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner for (unsigned i = 0; i != NumOps; ++i) { 898f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner OperandList[i] = Ops[i]; 899bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[i].Val->Uses.push_back(this); 9000442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner } 901bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 902ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner ValueList = VTs.VTs; 903ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner NumValues = VTs.NumVTs; 904b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner Prev = 0; Next = 0; 905f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner } 906bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDNode(unsigned Opc, SDVTList VTs) : NodeType(Opc), NodeId(-1) { 907bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandsNeedDelete = false; // Operands set with InitOperands. 908bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = 0; 909bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = 0; 910bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 911bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner ValueList = VTs.VTs; 912bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumValues = VTs.NumVTs; 913bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Prev = 0; Next = 0; 914bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 915bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 916bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// InitOperands - Initialize the operands list of this node with the 917bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// specified values, which are part of the node (thus they don't need to be 918bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// copied in or allocated). 919bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner void InitOperands(SDOperand *Ops, unsigned NumOps) { 920bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner assert(OperandList == 0 && "Operands already set!"); 921bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = NumOps; 922bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = Ops; 923bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 924bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner for (unsigned i = 0; i != NumOps; ++i) 925bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[i].Val->Uses.push_back(this); 926bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 927bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 928d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// MorphNodeTo - This frees the operands of the current node, resets the 929d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// opcode, types, and operands to the specified value. This should only be 930d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// used by the SelectionDAG class. 931d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner void MorphNodeTo(unsigned Opc, SDVTList L, 932d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner const SDOperand *Ops, unsigned NumOps); 9331b95095857b78e12138c22e76c7936611c51355bChris Lattner 9348c3484c5181834e6b7060a6064ac769878101f23Chris Lattner void addUser(SDNode *User) { 9358c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses.push_back(User); 9361b95095857b78e12138c22e76c7936611c51355bChris Lattner } 937d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner void removeUser(SDNode *User) { 938d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner // Remove this user from the operand's use list. 939d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner for (unsigned i = Uses.size(); ; --i) { 940d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner assert(i != 0 && "Didn't find user!"); 941d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner if (Uses[i-1] == User) { 9428c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses[i-1] = Uses.back(); 9438c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses.pop_back(); 9448c3484c5181834e6b7060a6064ac769878101f23Chris Lattner return; 945d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 946d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 947d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 948b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng 949b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng void setNodeId(int Id) { 950b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng NodeId = Id; 951b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng } 95263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 95363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 95463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 95563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// Define inline functions from the SDOperand class. 95663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 95763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getOpcode() const { 95863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getOpcode(); 95963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 96063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline MVT::ValueType SDOperand::getValueType() const { 96163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getValueType(ResNo); 96263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 96363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getNumOperands() const { 96463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getNumOperands(); 96563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 96663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline const SDOperand &SDOperand::getOperand(unsigned i) const { 96763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getOperand(i); 96863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 969c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chenginline uint64_t SDOperand::getConstantOperandVal(unsigned i) const { 970c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng return Val->getConstantOperandVal(i); 971c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 9720f66a9172175aa7c3055333358170581c999219bNate Begemaninline bool SDOperand::isTargetOpcode() const { 9730f66a9172175aa7c3055333358170581c999219bNate Begeman return Val->isTargetOpcode(); 9740f66a9172175aa7c3055333358170581c999219bNate Begeman} 9750f66a9172175aa7c3055333358170581c999219bNate Begemaninline unsigned SDOperand::getTargetOpcode() const { 9760f66a9172175aa7c3055333358170581c999219bNate Begeman return Val->getTargetOpcode(); 9770f66a9172175aa7c3055333358170581c999219bNate Begeman} 978a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattnerinline bool SDOperand::hasOneUse() const { 979a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner return Val->hasNUsesOfValue(1, ResNo); 980a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner} 98163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 9823f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes. This is solely 9833f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 9843f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode { 9853f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 9863f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Op; 9873f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 9883f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X) 9893f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs), Op(X) { 9903f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(&Op, 1); 9913f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 9923f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 9933f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 9943f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes. This is solely 9953f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 9963f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode { 9973f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 9983f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Ops[2]; 9993f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 10003f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y) 10013f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 10023f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 10033f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 10043f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 2); 10053f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 10063f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 10073f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 10083f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely 10093f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 10103f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode { 10113f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 10123f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Ops[3]; 10133f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 10143f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y, 10153f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Z) 10163f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 10173f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 10183f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 10193f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[2] = Z; 10203f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 3); 10213f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 10223f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 10233f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 10243f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 1025d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that 1026d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its 1027d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand. This node should be directly created by end-users and not added to 1028d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list. 1029d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode { 1030c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1031bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDOperand Op; 1032d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic: 1033423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit HandleSDNode(SDOperand X) 1034bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) { 1035bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner InitOperands(&Op, 1); 1036bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 103748b85926524f9d29ae600123c90194cd73fd629eChris Lattner ~HandleSDNode(); 1038bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDOperand getValue() const { return Op; } 1039d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner}; 1040d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner 104147725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerclass StringSDNode : public SDNode { 104247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner std::string Value; 1043c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 104447725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerprotected: 104547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner friend class SelectionDAG; 1046423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit StringSDNode(const std::string &val) 1047bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) { 104847725d059b259f8a0c145478300c9e9caa006b59Chris Lattner } 104947725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerpublic: 105047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner const std::string &getValue() const { return Value; } 105147725d059b259f8a0c145478300c9e9caa006b59Chris Lattner static bool classof(const StringSDNode *) { return true; } 105247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner static bool classof(const SDNode *N) { 105347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner return N->getOpcode() == ISD::STRING; 105447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner } 105547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner}; 105663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 105763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode { 105863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner uint64_t Value; 1059c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 106063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 106163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1062056f9f61d071c6c583951678f2bf543a1316efccChris Lattner ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT) 1063bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)), 1064bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Value(val) { 106563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 106663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 106763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 106863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner uint64_t getValue() const { return Value; } 106963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 107063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int64_t getSignExtended() const { 107163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Bits = MVT::getSizeInBits(getValueType(0)); 1072f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattner return ((int64_t)Value << (64-Bits)) >> (64-Bits); 107363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 107463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 107563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool isNullValue() const { return Value == 0; } 107663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool isAllOnesValue() const { 1077885a87ef8512a184a58a0ebe39705ccb221749efChris Lattner return Value == MVT::getIntVTBitMask(getValueType(0)); 107863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 107963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 108063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantSDNode *) { return true; } 108163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1082056f9f61d071c6c583951678f2bf543a1316efccChris Lattner return N->getOpcode() == ISD::Constant || 1083056f9f61d071c6c583951678f2bf543a1316efccChris Lattner N->getOpcode() == ISD::TargetConstant; 108463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 108563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 108663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 108763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode { 108863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner double Value; 1089c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 109063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 109163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1092ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner ConstantFPSDNode(bool isTarget, double val, MVT::ValueType VT) 1093ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 1094bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Value(val) { 109563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 109663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 109763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 109863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner double getValue() const { return Value; } 109963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 110063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isExactlyValue - We don't rely on operator== working on double values, as 110163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 110263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// As such, this method can be used to do an exact bit-for-bit comparison of 110363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// two floating point values. 110458b968be853ef02d0f448e5e2c31676e361c210fJim Laskey bool isExactlyValue(double V) const; 110563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 110663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantFPSDNode *) { return true; } 110763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1108ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner return N->getOpcode() == ISD::ConstantFP || 1109ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner N->getOpcode() == ISD::TargetConstantFP; 111063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 111163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 111263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 111363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode { 111463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *TheGlobal; 1115404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int Offset; 1116c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 111763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 111863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 111961ca74bc3a29b2af2be7e4bd612289da8aae85b5Evan Cheng GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT, 11202c5c111b6c144b05718404c85b9dfcc76b1619e7Lauro Ramos Venancio int o = 0); 112163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 112263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 112363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *getGlobal() const { return TheGlobal; } 1124404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int getOffset() const { return Offset; } 112563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 112663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const GlobalAddressSDNode *) { return true; } 112763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1128f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner return N->getOpcode() == ISD::GlobalAddress || 1129b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalAddress || 1130b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::GlobalTLSAddress || 1131b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalTLSAddress; 113263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 113363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 113463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 113563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode { 113663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int FI; 1137c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 113863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 113963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1140afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg) 1141bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)), 1142bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner FI(fi) { 114363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 114463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 114563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 114663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int getIndex() const { return FI; } 114763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 114863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const FrameIndexSDNode *) { return true; } 114963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1150afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner return N->getOpcode() == ISD::FrameIndex || 1151afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner N->getOpcode() == ISD::TargetFrameIndex; 115263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 115363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 115463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 115537efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode { 115637efe6764568a3829fee26aba532283131d1a104Nate Begeman int JTI; 1157c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 115837efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected: 115937efe6764568a3829fee26aba532283131d1a104Nate Begeman friend class SelectionDAG; 116037efe6764568a3829fee26aba532283131d1a104Nate Begeman JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg) 1161bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)), 1162bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner JTI(jti) { 116363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 116437efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic: 116537efe6764568a3829fee26aba532283131d1a104Nate Begeman 116637efe6764568a3829fee26aba532283131d1a104Nate Begeman int getIndex() const { return JTI; } 116737efe6764568a3829fee26aba532283131d1a104Nate Begeman 116837efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const JumpTableSDNode *) { return true; } 116937efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const SDNode *N) { 117037efe6764568a3829fee26aba532283131d1a104Nate Begeman return N->getOpcode() == ISD::JumpTable || 117137efe6764568a3829fee26aba532283131d1a104Nate Begeman N->getOpcode() == ISD::TargetJumpTable; 117237efe6764568a3829fee26aba532283131d1a104Nate Begeman } 117337efe6764568a3829fee26aba532283131d1a104Nate Begeman}; 117437efe6764568a3829fee26aba532283131d1a104Nate Begeman 117563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode { 1176d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng union { 1177d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *ConstVal; 1178d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *MachineCPVal; 1179d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } Val; 1180baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int Offset; // It's a MachineConstantPoolValue if top bit is set. 1181b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned Alignment; 1182c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 118363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 118463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1185404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, 1186404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int o=0) 1187ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1188bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1189d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1190d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1191d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1192404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o, 1193404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng unsigned Align) 1194ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1195bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1196d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1197d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1198d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1199d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1200d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MVT::ValueType VT, int o=0) 1201ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1202bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1203d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1204d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1205d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1206d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1207d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1208d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MVT::ValueType VT, int o, unsigned Align) 1209ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1210bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1211d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1212d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1213d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1214d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 121563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 121663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1217d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng bool isMachineConstantPoolEntry() const { 1218d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return (int)Offset < 0; 1219d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1220d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1221d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *getConstVal() const { 1222d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1223d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.ConstVal; 1224d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1225d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1226d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *getMachineCPVal() const { 1227d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1228d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.MachineCPVal; 1229d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1230d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1231baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int getOffset() const { 1232baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng return Offset & ~(1 << (sizeof(unsigned)*8-1)); 1233baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng } 1234ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner 1235ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // Return the alignment of this constant pool object, which is either 0 (for 1236ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // default alignment) or log2 of the desired value. 1237b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned getAlignment() const { return Alignment; } 123863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1239d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng const Type *getType() const; 1240d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 124163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantPoolSDNode *) { return true; } 124263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1243aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner return N->getOpcode() == ISD::ConstantPool || 1244aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner N->getOpcode() == ISD::TargetConstantPool; 124563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 124663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 124763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 124863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode { 124963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *MBB; 1250c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 125163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 125263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1253423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit BasicBlockSDNode(MachineBasicBlock *mbb) 1254bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) { 125563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 125663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 125763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 125863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *getBasicBlock() const { return MBB; } 125963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 126063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const BasicBlockSDNode *) { return true; } 126163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 126263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return N->getOpcode() == ISD::BasicBlock; 126363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 126463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 126563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 12662d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode { 12672d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *V; 1268691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth int offset; 1269c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 12702d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected: 12712d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth friend class SelectionDAG; 1272691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth SrcValueSDNode(const Value* v, int o) 1273bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v), offset(o) { 127463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 12752d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 12762d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic: 12772d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *getValue() const { return V; } 1278691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth int getOffset() const { return offset; } 12792d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 12802d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SrcValueSDNode *) { return true; } 12812d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SDNode *N) { 12822d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth return N->getOpcode() == ISD::SRCVALUE; 12832d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 12842d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth}; 12852d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 128663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1287d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode { 128863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Reg; 1289c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 129063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 129163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1292d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner RegisterSDNode(unsigned reg, MVT::ValueType VT) 1293bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) { 129463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 129563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 129663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 129763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getReg() const { return Reg; } 129863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1299d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner static bool classof(const RegisterSDNode *) { return true; } 130063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1301d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner return N->getOpcode() == ISD::Register; 130263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 130363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 130463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 130563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ExternalSymbolSDNode : public SDNode { 130663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *Symbol; 1307c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 130863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 130963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 13102a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT) 1311ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 1312bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Symbol(Sym) { 131363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 131463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 131563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 131663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *getSymbol() const { return Symbol; } 131763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 131863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ExternalSymbolSDNode *) { return true; } 131963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 13202a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth return N->getOpcode() == ISD::ExternalSymbol || 13212a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth N->getOpcode() == ISD::TargetExternalSymbol; 132263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 132363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 132463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13257cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode { 132663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ISD::CondCode Condition; 1327c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 132863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 132963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1330423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit CondCodeSDNode(ISD::CondCode Cond) 1331bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) { 133263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 133363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 133463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13357cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner ISD::CondCode get() const { return Condition; } 133663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13377cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner static bool classof(const CondCodeSDNode *) { return true; } 133863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 13397cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner return N->getOpcode() == ISD::CONDCODE; 134063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 134163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 134263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 134315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// VTSDNode - This class is used to represent MVT::ValueType's, which are used 134415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations. 134515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode { 134615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner MVT::ValueType ValueType; 1347c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 134815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected: 134915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner friend class SelectionDAG; 1350423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit VTSDNode(MVT::ValueType VT) 1351bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) { 135263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 135315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic: 135415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 135515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner MVT::ValueType getVT() const { return ValueType; } 135615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 135715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const VTSDNode *) { return true; } 135815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const SDNode *N) { 135915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner return N->getOpcode() == ISD::VALUETYPE; 136015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner } 136115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner}; 136215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 136324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes. 136424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 136524446e253a17720f6462288255ab5ebd13b8491fEvan Chengclass LoadSDNode : public SDNode { 1366c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1367bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDOperand Ops[3]; 1368bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 136981c384578828dde08f63a4f030f4860a92391cddEvan Cheng // AddrMode - unindexed, pre-indexed, post-indexed. 1370144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode AddrMode; 137181c384578828dde08f63a4f030f4860a92391cddEvan Cheng 137281c384578828dde08f63a4f030f4860a92391cddEvan Cheng // ExtType - non-ext, anyext, sext, zext. 137381c384578828dde08f63a4f030f4860a92391cddEvan Cheng ISD::LoadExtType ExtType; 137481c384578828dde08f63a4f030f4860a92391cddEvan Cheng 13752e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng // LoadedVT - VT of loaded value before extension. 13762e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng MVT::ValueType LoadedVT; 137781c384578828dde08f63a4f030f4860a92391cddEvan Cheng 137881c384578828dde08f63a4f030f4860a92391cddEvan Cheng // SrcValue - Memory location for alias analysis. 137924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *SrcValue; 138081c384578828dde08f63a4f030f4860a92391cddEvan Cheng 138181c384578828dde08f63a4f030f4860a92391cddEvan Cheng // SVOffset - Memory location offset. 138224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng int SVOffset; 138381c384578828dde08f63a4f030f4860a92391cddEvan Cheng 138481c384578828dde08f63a4f030f4860a92391cddEvan Cheng // Alignment - Alignment of memory location in bytes. 138524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng unsigned Alignment; 138681c384578828dde08f63a4f030f4860a92391cddEvan Cheng 138781c384578828dde08f63a4f030f4860a92391cddEvan Cheng // IsVolatile - True if the load is volatile. 138824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng bool IsVolatile; 138924446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 139024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 1391ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs, 1392144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT, 139395c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 1394bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::LOAD, VTs), 13952e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng AddrMode(AM), ExtType(ETy), LoadedVT(LVT), SrcValue(SV), SVOffset(O), 139624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng Alignment(Align), IsVolatile(Vol) { 1397bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[0] = ChainPtrOff[0]; // Chain 1398bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[1] = ChainPtrOff[1]; // Ptr 1399bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[2] = ChainPtrOff[2]; // Off 1400bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner InitOperands(Ops, 3); 140195c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb assert(Align != 0 && "Loads should have non-zero aligment"); 140263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner assert((getOffset().getOpcode() == ISD::UNDEF || 140363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner AddrMode != ISD::UNINDEXED) && 14048862ef148100070b7bf28beead3951464250c926Evan Cheng "Only indexed load has a non-undef offset operand"); 140524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 140624446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 140724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 140881c384578828dde08f63a4f030f4860a92391cddEvan Cheng const SDOperand getChain() const { return getOperand(0); } 140981c384578828dde08f63a4f030f4860a92391cddEvan Cheng const SDOperand getBasePtr() const { return getOperand(1); } 141081c384578828dde08f63a4f030f4860a92391cddEvan Cheng const SDOperand getOffset() const { return getOperand(2); } 1411144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode getAddressingMode() const { return AddrMode; } 141224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng ISD::LoadExtType getExtensionType() const { return ExtType; } 14132e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng MVT::ValueType getLoadedVT() const { return LoadedVT; } 141424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *getSrcValue() const { return SrcValue; } 141524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng int getSrcValueOffset() const { return SVOffset; } 141624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng unsigned getAlignment() const { return Alignment; } 141724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng bool isVolatile() const { return IsVolatile; } 141824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 141924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const LoadSDNode *) { return true; } 142024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 142124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD; 142224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 142324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 142424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 142524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes. 142624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 142724446e253a17720f6462288255ab5ebd13b8491fEvan Chengclass StoreSDNode : public SDNode { 1428c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1429bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDOperand Ops[4]; 1430bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 143181c384578828dde08f63a4f030f4860a92391cddEvan Cheng // AddrMode - unindexed, pre-indexed, post-indexed. 1432144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode AddrMode; 143381c384578828dde08f63a4f030f4860a92391cddEvan Cheng 143481c384578828dde08f63a4f030f4860a92391cddEvan Cheng // IsTruncStore - True is the op does a truncation before store. 143581c384578828dde08f63a4f030f4860a92391cddEvan Cheng bool IsTruncStore; 143681c384578828dde08f63a4f030f4860a92391cddEvan Cheng 14372e49f090f9656af7d5ed4d5c4e9fa26af59c7233Evan Cheng // StoredVT - VT of the value after truncation. 143881c384578828dde08f63a4f030f4860a92391cddEvan Cheng MVT::ValueType StoredVT; 143981c384578828dde08f63a4f030f4860a92391cddEvan Cheng 144081c384578828dde08f63a4f030f4860a92391cddEvan Cheng // SrcValue - Memory location for alias analysis. 144124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *SrcValue; 144281c384578828dde08f63a4f030f4860a92391cddEvan Cheng 144381c384578828dde08f63a4f030f4860a92391cddEvan Cheng // SVOffset - Memory location offset. 144424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng int SVOffset; 144581c384578828dde08f63a4f030f4860a92391cddEvan Cheng 144681c384578828dde08f63a4f030f4860a92391cddEvan Cheng // Alignment - Alignment of memory location in bytes. 144724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng unsigned Alignment; 144881c384578828dde08f63a4f030f4860a92391cddEvan Cheng 144981c384578828dde08f63a4f030f4860a92391cddEvan Cheng // IsVolatile - True if the store is volatile. 145024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng bool IsVolatile; 145124446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 145224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 1453ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs, 1454144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT, 145524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 1456bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::STORE, VTs), 145724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng AddrMode(AM), IsTruncStore(isTrunc), StoredVT(SVT), SrcValue(SV), 145824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng SVOffset(O), Alignment(Align), IsVolatile(Vol) { 1459bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[0] = ChainValuePtrOff[0]; // Chain 1460bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[1] = ChainValuePtrOff[1]; // Value 1461bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[2] = ChainValuePtrOff[2]; // Ptr 1462bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[3] = ChainValuePtrOff[3]; // Off 1463bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner InitOperands(Ops, 4); 146495c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb assert(Align != 0 && "Stores should have non-zero aligment"); 146563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner assert((getOffset().getOpcode() == ISD::UNDEF || 146663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner AddrMode != ISD::UNINDEXED) && 14678862ef148100070b7bf28beead3951464250c926Evan Cheng "Only indexed store has a non-undef offset operand"); 146824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 146924446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 147024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 147181c384578828dde08f63a4f030f4860a92391cddEvan Cheng const SDOperand getChain() const { return getOperand(0); } 14728b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng const SDOperand getValue() const { return getOperand(1); } 14738b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng const SDOperand getBasePtr() const { return getOperand(2); } 14748b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng const SDOperand getOffset() const { return getOperand(3); } 1475144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode getAddressingMode() const { return AddrMode; } 147624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng bool isTruncatingStore() const { return IsTruncStore; } 147724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng MVT::ValueType getStoredVT() const { return StoredVT; } 147824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *getSrcValue() const { return SrcValue; } 147924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng int getSrcValueOffset() const { return SVOffset; } 148024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng unsigned getAlignment() const { return Alignment; } 148124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng bool isVolatile() const { return IsVolatile; } 148224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 14836d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng static bool classof(const StoreSDNode *) { return true; } 148424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 148524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::STORE; 148624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 148724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 148824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 148915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 14901080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { 14911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNode *Node; 14921080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned Operand; 1493ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 14941080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 14951080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic: 14961080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator==(const SDNodeIterator& x) const { 14971080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Operand == x.Operand; 14981080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 14991080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 15001080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 15011080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNodeIterator &operator=(const SDNodeIterator &I) { 15021080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 15031080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner Operand = I.Operand; 15041080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 15051080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 1506ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 15071080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator*() const { 15081080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Node->getOperand(Operand).Val; 15091080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 15101080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator->() const { return operator*(); } 1511ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 15121080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator& operator++() { // Preincrement 15131080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner ++Operand; 15141080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 15151080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 15161080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator operator++(int) { // Postincrement 1517ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SDNodeIterator tmp = *this; ++*this; return tmp; 15181080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 15191080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 15201080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 15211080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator end (SDNode *N) { 15221080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator(N, N->getNumOperands()); 15231080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 15241080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 15251080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned getOperand() const { return Operand; } 15261080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNode *getNode() const { return Node; } 15271080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 15281080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 15291080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> { 15301080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNode NodeType; 15311080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNodeIterator ChildIteratorType; 15321080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static inline NodeType *getEntryNode(SDNode *N) { return N; } 1533ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_begin(NodeType *N) { 15341080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::begin(N); 15351080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 1536ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_end(NodeType *N) { 15371080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::end(N); 15381080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 15391080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 15401080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 1541b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<> 1542b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnerstruct ilist_traits<SDNode> { 1543b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *getPrev(const SDNode *N) { return N->Prev; } 1544b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *getNext(const SDNode *N) { return N->Next; } 1545b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1546b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; } 1547b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; } 1548b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1549b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *createSentinel() { 1550bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other)); 1551b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 1552b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void destroySentinel(SDNode *N) { delete N; } 1553b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner //static SDNode *createNode(const SDNode &V) { return new SDNode(V); } 1554b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1555b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1556b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void addNodeToList(SDNode *NTy) {} 1557b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void removeNodeFromList(SDNode *NTy) {} 1558b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void transferNodesFromList(iplist<SDNode, ilist_traits> &L2, 1559b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner const ilist_iterator<SDNode> &X, 1560b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner const ilist_iterator<SDNode> &Y) {} 1561b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner}; 1562b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1563c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD { 156424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// isNON_EXTLoad - Returns true if the specified node is a non-extending 156524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// load. 156624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng inline bool isNON_EXTLoad(const SDNode *N) { 156724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 156824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 156924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 157024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 1571c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 1572c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1573c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isEXTLoad(const SDNode *N) { 157424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 157524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 1576c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 1577c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1578c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 1579c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1580c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isSEXTLoad(const SDNode *N) { 158124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 158224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 1583c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 1584c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1585c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 1586c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1587c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isZEXTLoad(const SDNode *N) { 158824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 158924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 1590c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 15918b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 159202c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// isUNINDEXEDLoad - Returns true if the specified node is a unindexed load. 159302c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// 159402c50e4891841c28b2a743731dfc60744bb78879Evan Cheng inline bool isUNINDEXEDLoad(const SDNode *N) { 159502c50e4891841c28b2a743731dfc60744bb78879Evan Cheng return N->getOpcode() == ISD::LOAD && 159602c50e4891841c28b2a743731dfc60744bb78879Evan Cheng cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 159702c50e4891841c28b2a743731dfc60744bb78879Evan Cheng } 159802c50e4891841c28b2a743731dfc60744bb78879Evan Cheng 15998b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 16008b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 16018b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isNON_TRUNCStore(const SDNode *N) { 16028b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng return N->getOpcode() == ISD::STORE && 16038b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng !cast<StoreSDNode>(N)->isTruncatingStore(); 16048b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 16058b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 16068b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isTRUNCStore - Returns true if the specified node is a truncating 16078b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 16088b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isTRUNCStore(const SDNode *N) { 16098b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng return N->getOpcode() == ISD::STORE && 16108b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng cast<StoreSDNode>(N)->isTruncatingStore(); 16118b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 1612c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 1613c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1614c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 161563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace 161663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 161763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif 1618