SelectionDAGNodes.h revision bb81d97feb396a8bb21d074db1c57e9f66525f40
163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===-- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ---*- C++ -*-===// 2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// The LLVM Compiler Infrastructure 463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// 57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source 67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details. 7ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===// 9ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 1063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// This file declares the SDNode class and derived classes, which are used to 1163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// represent the nodes and operations present in a SelectionDAG. These nodes 1263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// and operations are machine code level operations, with some similarities to 1363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// the GCC RTL representation. 1463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// 1563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// Clients should include the SelectionDAG.h file instead of this file directly. 1663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// 1763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===// 1863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H 2063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#define LLVM_CODEGEN_SELECTIONDAGNODES_H 2163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 222d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth#include "llvm/Value.h" 23583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/ADT/FoldingSet.h" 241080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/GraphTraits.h" 251080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/iterator" 268bb369b8072c919ef5802f639a52b17620201190Dale Johannesen#include "llvm/ADT/APFloat.h" 27d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h" 28c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman#include "llvm/CodeGen/MemOperand.h" 2939931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h" 3063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert> 3163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm { 3363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG; 3563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue; 3663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock; 37d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue; 3863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode; 3976c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate <typename T> struct DenseMapInfo; 4063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type; 41b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate <typename T> struct ilist_traits; 42b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<typename NodeTy, typename Traits> class iplist; 43b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<typename NodeTy> class ilist_iterator; 4463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 450b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by 460b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG. Instances of this simple value class are returned by 470b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...). 480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// 490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList { 500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner const MVT::ValueType *VTs; 510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner unsigned short NumVTs; 520b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner}; 530b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 5463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the 5563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types. 5663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 5763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD { 58d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov namespace ParamFlags { 59d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov enum Flags { 60d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov NoFlagSet = 0, 61d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov ZExt = 1<<0, ///< Parameter should be zero extended 62d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov ZExtOffs = 0, 63d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov SExt = 1<<1, ///< Parameter should be sign extended 64d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov SExtOffs = 1, 65d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov InReg = 1<<2, ///< Parameter should be passed in register 66d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov InRegOffs = 2, 67d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov StructReturn = 1<<3, ///< Hidden struct-return pointer 68d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov StructReturnOffs = 3, 691aa7efbd2c98e761f50992197473304b99257ca9Rafael Espindola ByVal = 1<<4, ///< Struct passed by value 701aa7efbd2c98e761f50992197473304b99257ca9Rafael Espindola ByValOffs = 4, 7136397f50343639ce9a25996f2d790c656791ab92Duncan Sands Nest = 1<<5, ///< Parameter is nested function static chain 7236397f50343639ce9a25996f2d790c656791ab92Duncan Sands NestOffs = 5, 73594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola ByValAlign = 0xF << 6, //< The alignment of the struct 74594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola ByValAlignOffs = 6, 75594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola ByValSize = 0x1ffff << 10, //< The size of the struct 76594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola ByValSizeOffs = 10, 77d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov OrigAlignment = 0x1F<<27, 78d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov OrigAlignmentOffs = 27 79d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov }; 80d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov } 81d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov 8263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 8363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::NodeType enum - This enum defines all of the operators valid in a 8463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SelectionDAG. 8563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 8663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum NodeType { 873258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // DELETED_NODE - This is an illegal flag value that is used to catch 883258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // errors. This opcode is not a legal opcode for any node. 893258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner DELETED_NODE, 903258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner 918a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // EntryToken - This is the marker used to indicate the start of the region. 928a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner EntryToken, 938a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner 948c4bde36a339b1c538002e819daff84caae4cbadReid Spencer // Token factor - This node takes multiple tokens as input and produces a 958a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // single token result. This is used to represent the fact that the operand 968a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // operators are independent of each other. 978a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner TokenFactor, 98f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman 99f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // AssertSext, AssertZext - These nodes record if a register contains a 100f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // value that has already been zero or sign extended from a narrower type. 101f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // These nodes take two operands. The first is the node that has already 102f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // been extended, and the second is a value type node indicating the width 103f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // of the extension 104f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman AssertSext, AssertZext, 105ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 1068a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // Various leaf nodes. 1071ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng STRING, BasicBlock, VALUETYPE, CONDCODE, Register, 1081ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng Constant, ConstantFP, 109b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio GlobalAddress, GlobalTLSAddress, FrameIndex, 110b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio JumpTable, ConstantPool, ExternalSymbol, 1111ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng 11282c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth // The address of the GOT 11382c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth GLOBAL_OFFSET_TABLE, 114bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman 115bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and 116bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // llvm.returnaddress on the DAG. These nodes take one operand, the index 117bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // of the frame or return address to return. An index of zero corresponds 118bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // to the current function's frame or return address, an index of one to the 119bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // parent's frame or return address, and so on. 120bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman FRAMEADDR, RETURNADDR, 1212365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 1222365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to 1232365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // first (possible) on-stack argument. This is needed for correct stack 1242365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // adjustment during unwind. 1252365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov FRAME_TO_ARGS_OFFSET, 126f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 127f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the 128f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // address of the exception block on entry to an landing pad block. 129f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EXCEPTIONADDR, 130f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 131f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents 132f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // the selection index of the exception thrown. 133f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EHSELECTION, 134beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth 1352365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 1362365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // 'eh_return' gcc dwarf builtin, which is used to return from 1372365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // exception. The general meaning is: adjust stack by OFFSET and pass 1382365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // execution to HANDLER. Many platform-related details also :) 1392365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov EH_RETURN, 1402365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 141ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // TargetConstant* - Like Constant*, but the DAG does not do any folding or 142ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // simplification of the constant. 143056f9f61d071c6c583951678f2bf543a1316efccChris Lattner TargetConstant, 144ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner TargetConstantFP, 145f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner 146f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or 147f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // anything else with this node, and this is valid in the target-specific 148f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // dag, turning into a GlobalAddress operand. 149f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner TargetGlobalAddress, 150b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio TargetGlobalTLSAddress, 151afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner TargetFrameIndex, 15237efe6764568a3829fee26aba532283131d1a104Nate Begeman TargetJumpTable, 153aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner TargetConstantPool, 1542a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth TargetExternalSymbol, 15572601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner 156ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) 157ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with no side effects. 158ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// The first operand is the ID number of the intrinsic from the 159ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The 160ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// node has returns the result of the intrinsic. 161ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_WO_CHAIN, 162ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 163ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) 164ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 165ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// returns a result. The first operand is a chain pointer. The second is 166ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The 167ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// operands to the intrinsic follow. The node has two results, the result 168ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// of the intrinsic and an output chain. 169ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_W_CHAIN, 17063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 171ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) 172ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 173ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// does not return a result. The first operand is a chain pointer. The 174ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// second is the ID number of the intrinsic from the llvm::Intrinsic 175ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// namespace. The operands to the intrinsic follow. 176ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_VOID, 177ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 178d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // CopyToReg - This node has three operands: a chain, a register number to 179d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // set to this value, and a value. 18063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyToReg, 18163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 18263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // CopyFromReg - This node indicates that the input value is a virtual or 18363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // physical register that is defined outside of the scope of this 184ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman // SelectionDAG. The register is available from the RegisterSDNode object. 18563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyFromReg, 18663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 187fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman // UNDEF - An undefined node 188fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman UNDEF, 189681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner 190b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node 191b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// represents the formal arguments for a function. CC# is a Constant value 192b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// indicating the calling convention of the function, and ISVARARG is a 193b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// flag that indicates whether the function is varargs or not. This node 194b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// has one result value for each incoming argument, plus one for the output 195b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// chain. It must be custom legalized. See description of CALL node for 196b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FLAG argument contents explanation. 197c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner /// 198681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner FORMAL_ARGUMENTS, 1996c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner 2006c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE, 201b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn) 2026c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// This node represents a fully general function call, before the legalizer 203b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// runs. This has one result value for each argument / flag pair, plus 204b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// a chain result. It must be custom legalized. Flag argument indicates 205b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// misc. argument attributes. Currently: 206b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 0 - signness 207b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 1 - 'inreg' attribute 208b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 2 - 'sret' attribute 209594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 4 - 'byval' attribute 210594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 5 - 'nest' attribute 211594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 6-9 - alignment of byval structures 212594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 10-26 - size of byval structures 21313a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// Bits 31:27 - argument ABI alignment in the first argument piece and 21413a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// alignment '1' in other argument pieces. 2156c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner CALL, 216fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman 21763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // EXTRACT_ELEMENT - This is used to get the first or second (determined by 21863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // a Constant, which is required to be operand #1), element of the aggregate 21963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // value specified as operand #0. This is only for use before legalization, 22063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // for values that will be broken into multiple registers. 22163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner EXTRACT_ELEMENT, 22263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 22363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given 22463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // two values of the same integer value type, this produces a value twice as 22563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // big. Like EXTRACT_ELEMENT, this can only be used before legalization. 22663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BUILD_PAIR, 227006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner 228006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // MERGE_VALUES - This node takes multiple discrete operands and returns 229006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // them all as its individual results. This nodes has exactly the same 230006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // number of inputs and outputs, and is only valid before legalization. 231006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // This node is useful for some pieces of the code generator that want to 232006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // think about a single node with multiple results, not multiple nodes. 233006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner MERGE_VALUES, 23463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 235615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple integer binary arithmetic operators. 236bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, 237fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 238fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing 239b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // a signed/unsigned value of type i[2*N], and return the full value as 240fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // two results, each of type iN. 241fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SMUL_LOHI, UMUL_LOHI, 242fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 243fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and 244fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // remainder result. 245fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SDIVREM, UDIVREM, 246615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner 24755e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // CARRY_FALSE - This node is used when folding other nodes, 24855e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // like ADDC/SUBC, which indicate the carry result is always false. 24955e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner CARRY_FALSE, 25055e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner 251551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-setting nodes for multiple precision addition and subtraction. 252551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // These nodes take two operands of the same value type, and produce two 253551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // results. The first result is the normal add or sub result, the second 254551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // result is the carry flag result. 255551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDC, SUBC, 256551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 257551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-using nodes for multiple precision addition and subtraction. These 258551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // nodes take three operands: The first two are the normal lhs and rhs to 259551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // the add or sub, and the third is the input carry flag. These nodes 260551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // produce two results; the normal result of the add or sub, and the output 261551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // carry flag. These nodes both read and write a carry flag to allow them 262551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // to them to be chained together for add and sub of arbitrarily large 263551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // values. 264551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDE, SUBE, 265551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 266615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple binary floating point operators. 267615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner FADD, FSUB, FMUL, FDIV, FREM, 26838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 26938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This 27038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // DAG node does not require that X and Y have the same type, just that they 27138bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // are both floating point. X and the result must have the same type. 27238bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(f32, f64) is allowed. 27338bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner FCOPYSIGN, 274fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner 2751a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point 2761a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // value as an integer 0/1 value. 2771a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner FGETSIGN, 2781a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner 279664e9546d674096c5a012536f1a424b1681ece51Dan Gohman /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector 28022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// with the specified, possibly variable, elements. The number of elements 28122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// is required to be a power of two. 28222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner BUILD_VECTOR, 28322232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2847f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element 2857f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// at IDX replaced with VAL. 28622232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner INSERT_VECTOR_ELT, 2874b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner 2884b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR 2897f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// identified by the (potentially variable) element number IDX. 2904b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner EXTRACT_VECTOR_ELT, 29122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2927f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of 2937f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector type with the same length and element type, this produces a 2947f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// concatenated vector result value, with length equal to the sum of the 295b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman /// lengths of the input vectors. 2967f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman CONCAT_VECTORS, 2976595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman 2987f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an 2997f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector value) starting with the (potentially variable) element number 3007f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// IDX, which must be a multiple of the result vector length. 3017f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman EXTRACT_SUBVECTOR, 3026595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman 30349c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same 30449c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values 30549c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// (regardless of whether its datatype is legal or not) that indicate 30649c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// which value each result element will get. The elements of VEC1/VEC2 are 30749c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// enumerated in order. This is quite similar to the Altivec 'vperm' 30849c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// instruction, except that the indices must be constants and are in terms 30949c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// of the element size of VEC1/VEC2, not in terms of bytes. 31049c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner VECTOR_SHUFFLE, 31149c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner 312210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a 313a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// scalar value into element 0 of the resultant vector type. The top 314a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// elements 1 to N-1 of the N-element vector are undefined. 315210721aecc0916315f61660dc387a96b89ec423bChris Lattner SCALAR_TO_VECTOR, 316210721aecc0916315f61660dc387a96b89ec423bChris Lattner 317557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // EXTRACT_SUBREG - This node is used to extract a sub-register value. 318557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg and a constant sub-register index as operands. 319557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb EXTRACT_SUBREG, 320557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 321557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // INSERT_SUBREG - This node is used to insert a sub-register value. 322557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg, a subreg value, and a constant sub-register 323557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // index as operands. 324557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb INSERT_SUBREG, 325557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 326bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing 327b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // an unsigned/signed value of type i[2*N], then return the top part. 328bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner MULHU, MULHS, 32963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 33035ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // Bitwise operators - logical and, logical or, logical xor, shift left, 33135ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // shift right algebraic (shift in sign bits), shift right logical (shift in 33235ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // zeroes), rotate left, rotate right, and byteswap. 33335ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP, 33463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 335691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth // Counting operators 336691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth CTTZ, CTLZ, CTPOP, 337691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth 338fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner // Select(COND, TRUEVAL, FALSEVAL) 3399373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT, 3409373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman 3419373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // Select with condition operator - This selects between a true value and 3429373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // a false value (ops #2 and #3) based on the boolean result of comparing 3439373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // the lhs and rhs (ops #0 and #1) of a conditional expression with the 3449373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // condition code in op #4, a CondCodeSDNode. 3459373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT_CC, 34663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 34763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SetCC operator - This evaluates to a boolean (i1) true value if the 3487cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // condition is true. The operands to this are the left and right operands 3497cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // to compare (ops #0, and #1) and the condition code to compare them with 3507cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // (op #2) as a CondCodeSDNode. 35163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETCC, 35263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 35314c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded 35414c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // integer shift operations, just like ADD/SUB_PARTS. The operation 35514c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // ordering is: 3566b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner // [Lo,Hi] = op [LoLHS,HiLHS], Amt 35714c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner SHL_PARTS, SRA_PARTS, SRL_PARTS, 35814c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner 35963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Conversion operators. These are all single input single output 36063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operations. For all of these, the result type must be strictly 36163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // wider or narrower (depending on the operation) than the source 36263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // type. 36363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 36463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SIGN_EXTEND - Used for integer types, replicating the sign bit 36563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // into new bits. 36663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SIGN_EXTEND, 36763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 36863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // ZERO_EXTEND - Used for integer types, zeroing the new bits. 36963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ZERO_EXTEND, 37063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3717e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner // ANY_EXTEND - Used for integer types. The high bits are undefined. 3727e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner ANY_EXTEND, 3737e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner 37463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // TRUNCATE - Completely drop the high bits. 37563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner TRUNCATE, 37663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3771645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign 3781645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // depends on the first letter) to floating point. 3791645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner SINT_TO_FP, 3801645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner UINT_TO_FP, 3811645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 382ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to 383ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // sign extend a small value in a large integer register (e.g. sign 384ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // extending the low 8 bits of a 32-bit register to fill the top 24 bits 38515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // with the 7th bit). The size of the smaller type is indicated by the 1th 38615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // operand, a ValueType node. 387859157daee6a4b49e99921832e1dde065167b317Chris Lattner SIGN_EXTEND_INREG, 388859157daee6a4b49e99921832e1dde065167b317Chris Lattner 3890bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned 3900bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// integer. 3911645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_SINT, 3921645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_UINT, 3931645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 3940bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type 3950bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// down to the precision of the destination VT. TRUNC is a flag, which is 3960bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// always an integer that is zero or one. If TRUNC is 0, this is a 3970bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// normal rounding, if it is 1, this FP_ROUND is known to not change the 3980bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// value of Y. 3990bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// 4000bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// The TRUNC = 1 case is used in cases where we know that the value will 4010bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// not be modified by the node, because Y is not using any of the extra 4020bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// precision of source type. This allows certain transformations like 4030bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for 4040bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed. 40563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_ROUND, 4060bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner 4071a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman // FLT_ROUNDS_ - Returns current rounding mode: 408917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // -1 Undefined 409917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 0 Round to 0 410917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 1 Round to nearest 411917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 2 Round to +inf 412917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 3 Round to -inf 4131a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman FLT_ROUNDS_, 414917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov 4150bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and 4160bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// rounds it to a floating point value. It then promotes it and returns it 4170bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// in a register of the same size. This operation effectively just 4180bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// discards excess precision. The type to round down to is specified by 4190bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// the VT operand, a VTSDNode. 420859157daee6a4b49e99921832e1dde065167b317Chris Lattner FP_ROUND_INREG, 421859157daee6a4b49e99921832e1dde065167b317Chris Lattner 4220bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type. 42363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_EXTEND, 42463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4251ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // BIT_CONVERT - Theis operator converts between integer and FP values, as 4261ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // if one was stored to memory as integer and the other was loaded from the 42780f55abf009c86bc03821e10746832f88f8a735fChris Lattner // same address (or equivalently for vector format conversions, etc). The 42880f55abf009c86bc03821e10746832f88f8a735fChris Lattner // source and result are required to have the same bit size (e.g. 42980f55abf009c86bc03821e10746832f88f8a735fChris Lattner // f32 <-> i32). This can also be used for int-to-int or fp-to-fp 43080f55abf009c86bc03821e10746832f88f8a735fChris Lattner // conversions, but that is a noop, deleted by getNode(). 4311ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner BIT_CONVERT, 4321ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner 43307f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW - Perform unary floating point 43407f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman // negation, absolute value, square root, sine and cosine, powi, and pow 435dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner // operations. 43607f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, 43738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 4388862ef148100070b7bf28beead3951464250c926Evan Cheng // LOAD and STORE have token chains as their first operand, then the same 4398862ef148100070b7bf28beead3951464250c926Evan Cheng // operands as an LLVM load/store instruction, then an offset node that 4408862ef148100070b7bf28beead3951464250c926Evan Cheng // is added / subtracted from the base pointer to form the address (for 4418862ef148100070b7bf28beead3951464250c926Evan Cheng // indexed memory ops). 44263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner LOAD, STORE, 4435fbb5d2459a5410590f285250faa604576308a93Nate Begeman 44463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned 44557fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // to a specified boundary. This node always has two return values: a new 44657fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // stack pointer value and a chain. The first operand is the token chain, 44757fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // the second is the number of bytes to allocate, and the third is the 44857fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment boundary. The size is guaranteed to be a multiple of the stack 44957fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment, and the alignment is guaranteed to be bigger than the stack 45074fe063e90045931eefaba561730e6a9175ced78Chris Lattner // alignment (if required) or 0 to get standard stack alignment. 45163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner DYNAMIC_STACKALLOC, 45263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 45363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Control flow instructions. These all have token chains. 454ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 45563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BR - Unconditional branch. The first operand is the chain 45663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operand, the second is the MBB to branch to. 45763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BR, 45863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 45937efe6764568a3829fee26aba532283131d1a104Nate Begeman // BRIND - Indirect branch. The first operand is the chain, the second 46037efe6764568a3829fee26aba532283131d1a104Nate Begeman // is the value to branch to, which must be of the same type as the target's 46137efe6764568a3829fee26aba532283131d1a104Nate Begeman // pointer type. 46237efe6764568a3829fee26aba532283131d1a104Nate Begeman BRIND, 463c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng 464c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // BR_JT - Jumptable branch. The first operand is the chain, the second 465c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // is the jumptable index, the last one is the jumptable entry index. 466c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng BR_JT, 46737efe6764568a3829fee26aba532283131d1a104Nate Begeman 46863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BRCOND - Conditional branch. The first operand is the chain, 46963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // the second is the condition, the third is the block to branch 47063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // to if the condition is true. 47163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BRCOND, 47263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4737cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in 4747cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // that the condition is represented as condition code, and two nodes to 4757cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // compare, rather than as a combined SetCC node. The operands in order are 4767cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // chain, cc, lhs, rhs, block to branch to if condition is true. 4777cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman BR_CC, 4787cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman 47963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // RET - Return from function. The first operand is the chain, 4808e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // and any subsequent operands are pairs of return value and return value 4818e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // signness for the function. This operation can have variable number of 4828e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // operands. 48363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner RET, 48463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4857572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // INLINEASM - Represents an inline asm block. This node always has two 4867572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // return values: a chain and a flag result. The inputs are as follows: 4877572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #0 : Input chain. 4887572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string. 4897572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+2: A RegisterNode. 4907572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def 4917572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #last: Optional, an incoming flag. 4927572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner INLINEASM, 4931ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey 4941ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // LABEL - Represents a label in mid basic block used to track 4951ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // locations needed for debug and exception handling tables. This node 4961ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // returns a chain. 4971ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // Operand #0 : input chain. 4981ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // Operand #1 : module unique number use to identify the label. 499bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng // Operand #2 : 0 indicates a debug label (e.g. stoppoint), 1 indicates 500bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng // a EH label, 2 indicates unknown label type. 5011ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey LABEL, 502f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 5035a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a 5045a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // value, the same type as the pointer type for the system, and an output 5055a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // chain. 5065a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKSAVE, 5075a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 5085a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKRESTORE has two operands, an input chain and a pointer to restore to 5095a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // it returns an output chain. 5105a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKRESTORE, 5115a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 5125c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain. The following 5135c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola // correspond to the operands of the LLVM intrinsic functions and the last 5145c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola // one is AlwaysInline. The only result is a token chain. The alignment 5155c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola // argument is guaranteed to be a Constant node. 516ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMSET, 517ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMMOVE, 518ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMCPY, 519ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 52016cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of 52116cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // a call sequence, and carry arbitrary information that target might want 52216cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // to know. The first operand is a chain, the rest are specified by the 52316cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // target and not touched by the DAG optimizers. 52416cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_START, // Beginning of a call sequence 52516cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_END, // End of a call sequence 526acc398c195a697795bff3245943d104eb19192b9Nate Begeman 527acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAARG - VAARG has three operands: an input chain, a pointer, and a 528acc398c195a697795bff3245943d104eb19192b9Nate Begeman // SRCVALUE. It returns a pair of values: the vaarg value and a new chain. 529acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAARG, 530acc398c195a697795bff3245943d104eb19192b9Nate Begeman 531acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VACOPY - VACOPY has five operands: an input chain, a destination pointer, 532acc398c195a697795bff3245943d104eb19192b9Nate Begeman // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the 533acc398c195a697795bff3245943d104eb19192b9Nate Begeman // source. 534acc398c195a697795bff3245943d104eb19192b9Nate Begeman VACOPY, 535acc398c195a697795bff3245943d104eb19192b9Nate Begeman 536acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a 537acc398c195a697795bff3245943d104eb19192b9Nate Begeman // pointer, and a SRCVALUE. 538acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAEND, VASTART, 53963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 540c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman // SRCVALUE - This is a node type that holds a Value* that is used to 541c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman // make reference to a value in the LLVM IR. 54221074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner SRCVALUE, 54321074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner 544c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman // MEMOPERAND - This is a node that contains a MemOperand which records 545c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman // information about a memory reference. This is used to make AliasAnalysis 546c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman // queries from the backend. 547c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman MEMOPERAND, 548c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman 549e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman // PCMARKER - This corresponds to the pcmarker intrinsic. 55095762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth PCMARKER, 55163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 552aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic. 5538b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // The only operand is a chain and a value and a chain are produced. The 5548b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // value is the contents of the architecture specific cycle counter like 5558b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // register (or other high accuracy low latency clock source) 556aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth READCYCLECOUNTER, 557aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth 558d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner // HANDLENODE node - Used as a handle for various purposes. 559d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner HANDLENODE, 5602d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 56147725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // LOCATION - This node is used to represent a source location for debug 56247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // info. It takes token chain as input, then a line number, then a column 56347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // number, then a filename, then a working dir. It produces a token chain 56447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // as output. 56547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner LOCATION, 56647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner 567f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey // DEBUG_LOC - This node is used to represent source line information 568abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // embedded in the code. It takes a token chain as input, then a line 56944c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey // number, then a column then a file id (provided by MachineModuleInfo.) It 570abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // produces a token chain as output. 571f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey DEBUG_LOC, 57236397f50343639ce9a25996f2d790c656791ab92Duncan Sands 57336397f50343639ce9a25996f2d790c656791ab92Duncan Sands // TRAMPOLINE - This corresponds to the init_trampoline intrinsic. 57436397f50343639ce9a25996f2d790c656791ab92Duncan Sands // It takes as input a token chain, the pointer to the trampoline, 57536397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the pointer to the nested function, the pointer to pass for the 57636397f50343639ce9a25996f2d790c656791ab92Duncan Sands // 'nest' parameter, a SRCVALUE for the trampoline and another for 57736397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the nested function (allowing targets to access the original 578f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // Function*). It produces the result of the intrinsic and a token 579f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // chain as output. 58036397f50343639ce9a25996f2d790c656791ab92Duncan Sands TRAMPOLINE, 58136397f50343639ce9a25996f2d790c656791ab92Duncan Sands 58266fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov // TRAP - Trapping instruction 58366fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov TRAP, 58466fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov 58563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILTIN_OP_END - This must be the last enum value in this list. 586410354fe0c052141dadeca939395743f8dd58e38Chris Lattner BUILTIN_OP_END 58763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 58863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 589322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// Node predicates 590322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 591a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng /// isBuildVectorAllOnes - Return true if the specified node is a 592322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// BUILD_VECTOR where all of the elements are ~0 or undef. 593a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng bool isBuildVectorAllOnes(const SDNode *N); 5944a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng 5954a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// isBuildVectorAllZeros - Return true if the specified node is a 5964a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// BUILD_VECTOR where all of the elements are 0 or undef. 5974a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng bool isBuildVectorAllZeros(const SDNode *N); 598bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng 599bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// isDebugLabel - Return true if the specified node represents a debug 600bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// label (i.e. ISD::LABEL or TargetInstrInfo::LANEL node and third operand 601bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// is 0). 602bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng bool isDebugLabel(const SDNode *N); 603322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 60463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 605144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// MemIndexedMode enum - This enum defines the load / store indexed 606144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// addressing modes. 60724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 60824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// UNINDEXED "Normal" load / store. The effective address is already 60924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computed and is available in the base pointer. The offset 61081c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// operand is always undefined. In addition to producing a 61181c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// chain, an unindexed load produces one value (result of the 61281c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// load); an unindexed store does not produces a value. 61324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 61435acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// PRE_INC Similar to the unindexed mode where the effective address is 6158862ef148100070b7bf28beead3951464250c926Evan Cheng /// PRE_DEC the value of the base pointer add / subtract the offset. 6168862ef148100070b7bf28beead3951464250c926Evan Cheng /// It considers the computation as being folded into the load / 61724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// store operation (i.e. the load / store does the address 61824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computation as well as performing the memory transaction). 61981c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// The base operand is always undefined. In addition to 62081c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// producing a chain, pre-indexed load produces two values 62181c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// (result of the load and the result of the address 62281c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// computation); a pre-indexed store produces one value (result 62381c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// of the address computation). 62424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 62535acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// POST_INC The effective address is the value of the base pointer. The 6268862ef148100070b7bf28beead3951464250c926Evan Cheng /// POST_DEC value of the offset operand is then added to / subtracted 6278862ef148100070b7bf28beead3951464250c926Evan Cheng /// from the base after memory transaction. In addition to 6288862ef148100070b7bf28beead3951464250c926Evan Cheng /// producing a chain, post-indexed load produces two values 6298862ef148100070b7bf28beead3951464250c926Evan Cheng /// (the result of the load and the result of the base +/- offset 6308862ef148100070b7bf28beead3951464250c926Evan Cheng /// computation); a post-indexed store produces one value (the 6318862ef148100070b7bf28beead3951464250c926Evan Cheng /// the result of the base +/- offset computation). 63224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 633144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng enum MemIndexedMode { 63424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng UNINDEXED = 0, 63535acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_INC, 63635acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_DEC, 63735acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng POST_INC, 638144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng POST_DEC, 639144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng LAST_INDEXED_MODE 64024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng }; 64124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 64224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng //===--------------------------------------------------------------------===// 643c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// LoadExtType enum - This enum defines the three variants of LOADEXT 644c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// (load with extension). 645c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 64624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// SEXTLOAD loads the integer operand and sign extends it to a larger 64724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 64824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// ZEXTLOAD loads the integer operand and zero extends it to a larger 64924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 65024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// EXTLOAD is used for three things: floating point extending loads, 65124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer extending loads [the top bits are undefined], and vector 65224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// extending loads [load into low elt]. 65324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 654c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng enum LoadExtType { 65524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng NON_EXTLOAD = 0, 656c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng EXTLOAD, 657c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng SEXTLOAD, 658c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng ZEXTLOAD, 659c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng LAST_LOADX_TYPE 660c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng }; 661c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 662c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng //===--------------------------------------------------------------------===// 66363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::CondCode enum - These are ordered carefully to make the bitfields 66463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// below work out, when considering SETFALSE (something that never exists 66563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered 66663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal 66763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to. If the "N" column is 1, the result of the comparison is undefined if 66863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the input is a NAN. 66963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 67063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// All of these (except for the 'always folded ops') should be handled for 67163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT, 67263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used. 67363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 67463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Note that these are laid out in a specific order to allow bit-twiddling 67563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to transform conditions. 67663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum CondCode { 67763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Opcode N U L G E Intuitive operation 67863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE, // 0 0 0 0 Always false (always folded) 67963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOEQ, // 0 0 0 1 True if ordered and equal 68063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGT, // 0 0 1 0 True if ordered and greater than 68163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGE, // 0 0 1 1 True if ordered and greater than or equal 68263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLT, // 0 1 0 0 True if ordered and less than 68363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLE, // 0 1 0 1 True if ordered and less than or equal 68463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETONE, // 0 1 1 0 True if ordered and operands are unequal 68563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETO, // 0 1 1 1 True if ordered (no nans) 68663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 68763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUEQ, // 1 0 0 1 True if unordered or equal 68863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGT, // 1 0 1 0 True if unordered or greater than 68963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGE, // 1 0 1 1 True if unordered, greater than, or equal 69063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETULT, // 1 1 0 0 True if unordered or less than 691ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETULE, // 1 1 0 1 True if unordered, less than, or equal 69263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUNE, // 1 1 1 0 True if unordered or not equal 69363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE, // 1 1 1 1 Always true (always folded) 69463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Don't care operations: undefined if the input is a nan. 69563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE2, // 1 X 0 0 0 Always false (always folded) 69663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETEQ, // 1 X 0 0 1 True if equal 69763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGT, // 1 X 0 1 0 True if greater than 69863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGE, // 1 X 0 1 1 True if greater than or equal 69963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETLT, // 1 X 1 0 0 True if less than 700ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETLE, // 1 X 1 0 1 True if less than or equal 70163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETNE, // 1 X 1 1 0 True if not equal 70263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE2, // 1 X 1 1 1 Always true (always folded) 70363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 704410354fe0c052141dadeca939395743f8dd58e38Chris Lattner SETCC_INVALID // Marker value. 70563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 70663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 70763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isSignedIntSetCC - Return true if this is a setcc instruction that 70863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs a signed comparison when used with integer operands. 70963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isSignedIntSetCC(CondCode Code) { 71063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE; 71163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 71263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 71363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isUnsignedIntSetCC - Return true if this is a setcc instruction that 71463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs an unsigned comparison when used with integer operands. 71563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isUnsignedIntSetCC(CondCode Code) { 71663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE; 71763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 71863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 71963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isTrueWhenEqual - Return true if the specified condition returns true if 72063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the two operands to the condition are equal. Note that if one of the two 72163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operands is a NaN, this value is meaningless. 72263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isTrueWhenEqual(CondCode Cond) { 72363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond & 1) != 0; 72463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 72563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 72663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getUnorderedFlavor - This function returns 0 if the condition is always 72763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// false if an operand is a NaN, 1 if the condition is always true if the 72863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operand is a NaN, and 2 if the condition is undefined if the operand is a 72963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// NaN. 73063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getUnorderedFlavor(CondCode Cond) { 73163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond >> 3) & 3; 73263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 73363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 73463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCInverse - Return the operation corresponding to !(X op Y), where 73563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 'op' is a valid SetCC operation. 73663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCInverse(CondCode Operation, bool isInteger); 73763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 73863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) 73963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// when given the operation for (X op Y). 74063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCSwappedOperands(CondCode Operation); 74163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 74263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCOrOperation - Return the result of a logical OR between different 74363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This 74463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger); 74763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 74863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCAndOperation - Return the result of a logical AND between 74963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This 75063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 75163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 75263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger); 75363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm::ISD namespace 75463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 75563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 75663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===// 75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple 75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation. Many nodes return multiple values, 75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns 76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number 76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values). 76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 76363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that 76463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node. This pair 76563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of information is represented with the SDOperand value type. 76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 767f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerclass SDOperand { 768f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerpublic: 76963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDNode *Val; // The node defining the value we are using. 77063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned ResNo; // Which return value of the node we are using. 77163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 772ace44dbbabe9ee0498834957632df2af0dbf9c59Reid Spencer SDOperand() : Val(0), ResNo(0) {} 77363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} 77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator==(const SDOperand &O) const { 77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val == O.Val && ResNo == O.ResNo; 77763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 77863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator!=(const SDOperand &O) const { 77963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return !operator==(O); 78063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator<(const SDOperand &O) const { 78263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val < O.Val || (Val == O.Val && ResNo < O.ResNo); 78363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 78463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 78563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDOperand getValue(unsigned R) const { 78663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return SDOperand(Val, R); 78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 789bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng // isOperand - Return true if this node is an operand of N. 790bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng bool isOperand(SDNode *N) const; 791bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng 79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the ValueType of the referenced return value. 79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 79463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline MVT::ValueType getValueType() const; 795ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Forwarding methods - These forward to the corresponding methods in SDNode. 79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getOpcode() const; 79863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getNumOperands() const; 79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline const SDOperand &getOperand(unsigned i) const; 800c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline uint64_t getConstantOperandVal(unsigned i) const; 8010f66a9172175aa7c3055333358170581c999219bNate Begeman inline bool isTargetOpcode() const; 8020f66a9172175aa7c3055333358170581c999219bNate Begeman inline unsigned getTargetOpcode() const; 803a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner 804572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 805572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// reachesChainWithoutSideEffects - Return true if this operand (which must 806572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// be a chain) reaches the specified operand without crossing any 807572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// side-effecting instructions. In practice, this looks through token 808572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// factors and non-volatile loads. In order to remain efficient, this only 809572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// looks a couple of nodes in, it does not do an exhaustive search. 810572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner bool reachesChainWithoutSideEffects(SDOperand Dest, unsigned Depth = 2) const; 811572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 812a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner /// hasOneUse - Return true if there is exactly one operation using this 813a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner /// result value of the defining operator. 814a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner inline bool hasOneUse() const; 815e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman 816e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman /// use_empty - Return true if there are no operations using this 817e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman /// result value of the defining operator. 818e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman inline bool use_empty() const; 81963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 82063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 82163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 82276c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate<> struct DenseMapInfo<SDOperand> { 823c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); } 824c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);} 825c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static unsigned getHashValue(const SDOperand &Val) { 826c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng return (unsigned)((uintptr_t)Val.Val >> 4) ^ 827c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng (unsigned)((uintptr_t)Val.Val >> 9) + Val.ResNo; 828c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng } 82976c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) { 83076c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner return LHS == RHS; 83176c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner } 832c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static bool isPod() { return true; } 833c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng}; 834c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng 83563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on 83663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperands as if they were SDNode*'s. 83763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<SDOperand> { 83863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 83963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static SimpleType getSimplifiedValue(const SDOperand &Val) { 84063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return static_cast<SimpleType>(Val.Val); 84163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 84263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 84363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<const SDOperand> { 84463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 84563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static SimpleType getSimplifiedValue(const SDOperand &Val) { 84663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return static_cast<SimpleType>(Val.Val); 84763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 84863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 84963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 85063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 85163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG. 85263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 853583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskeyclass SDNode : public FoldingSetNode { 8540442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// NodeType - The operation that this node performs. 8550442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 8560442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner unsigned short NodeType; 85763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 85863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true, 85963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// then they will be delete[]'d when the node is destroyed. 86063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner bool OperandsNeedDelete : 1; 8610442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 862b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// NodeId - Unique id per SDNode in the DAG. 863b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int NodeId; 8640442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 865f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// OperandList - The values that are used by this operation. 8660442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 867f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner SDOperand *OperandList; 868f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 869f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// ValueList - The types of the values this node defines. SDNode's may 870f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// define multiple values simultaneously. 8712fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner const MVT::ValueType *ValueList; 87263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 873f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// NumOperands/NumValues - The number of entries in the Operand/Value list. 874f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned short NumOperands, NumValues; 875b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 876b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner /// Prev/Next pointers - These pointers form the linked list of of the 877b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner /// AllNodes list in the current DAG. 878b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner SDNode *Prev, *Next; 879b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner friend struct ilist_traits<SDNode>; 88063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 88163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Uses - These are all of the SDNode's that use a value produced by this 88263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// node. 8835892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner SmallVector<SDNode*,3> Uses; 884917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner 885917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner // Out-of-line virtual method to give class a home. 886917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner virtual void ANCHOR(); 88763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 888b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner virtual ~SDNode() { 889b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner assert(NumOperands == 0 && "Operand list not cleared before deletion"); 8903258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner NodeType = ISD::DELETED_NODE; 891b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 892b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 89363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 89463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Accessors 89563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // 89663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getOpcode() const { return NodeType; } 8970f66a9172175aa7c3055333358170581c999219bNate Begeman bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } 8980f66a9172175aa7c3055333358170581c999219bNate Begeman unsigned getTargetOpcode() const { 8990f66a9172175aa7c3055333358170581c999219bNate Begeman assert(isTargetOpcode() && "Not a target opcode!"); 9000f66a9172175aa7c3055333358170581c999219bNate Begeman return NodeType - ISD::BUILTIN_OP_END; 9010f66a9172175aa7c3055333358170581c999219bNate Begeman } 90263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 90363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner size_t use_size() const { return Uses.size(); } 90463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool use_empty() const { return Uses.empty(); } 90563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool hasOneUse() const { return Uses.size() == 1; } 90663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 907b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// getNodeId - Return the unique node id. 908b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// 909b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int getNodeId() const { return NodeId; } 9100442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 9112e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng /// setNodeId - Set unique node id. 9122e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng void setNodeId(int Id) { NodeId = Id; } 9132e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng 9145892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner typedef SmallVector<SDNode*,3>::const_iterator use_iterator; 9157ece380440238ad0630a225b85a09a2dbed1165aChris Lattner use_iterator use_begin() const { return Uses.begin(); } 9167ece380440238ad0630a225b85a09a2dbed1165aChris Lattner use_iterator use_end() const { return Uses.end(); } 9177ece380440238ad0630a225b85a09a2dbed1165aChris Lattner 918b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the 919b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// indicated value. This method ignores uses of other values defined by this 920b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// operation. 9214ee621125876cc954cba5280dd9395552755a871Evan Cheng bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; 9224ee621125876cc954cba5280dd9395552755a871Evan Cheng 92333d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// hasAnyUseOfValue - Return true if there are any use of the indicated 92433d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// value. This method ignores uses of other values defined by this operation. 92533d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng bool hasAnyUseOfValue(unsigned Value) const; 92633d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng 927e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// isOnlyUse - Return true if this node is the only use of N. 928e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 9294ee621125876cc954cba5280dd9395552755a871Evan Cheng bool isOnlyUse(SDNode *N) const; 930b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner 931e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// isOperand - Return true if this node is an operand of N. 932e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 93380d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng bool isOperand(SDNode *N) const; 93480d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng 935e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// isPredecessor - Return true if this node is a predecessor of N. This node 936e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// is either an operand of N or it can be reached by recursively traversing 937e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// up the operands. 938e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// NOTE: this is an expensive method. Use it carefully. 9397ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng bool isPredecessor(SDNode *N) const; 9407ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng 94163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumOperands - Return the number of values used by this operation. 94263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 943f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumOperands() const { return NumOperands; } 94463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 945c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// getConstantOperandVal - Helper method returns the integer value of a 946c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// ConstantSDNode operand. 947c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng uint64_t getConstantOperandVal(unsigned Num) const; 948c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 94963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const SDOperand &getOperand(unsigned Num) const { 950f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(Num < NumOperands && "Invalid child # of SDNode!"); 951f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return OperandList[Num]; 95263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 953c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 954f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner typedef const SDOperand* op_iterator; 955f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_begin() const { return OperandList; } 956f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_end() const { return OperandList+NumOperands; } 95750f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner 95863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 9590b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList getVTList() const { 9600b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList X = { ValueList, NumValues }; 9610b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner return X; 9620b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner }; 9630b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 96463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumValues - Return the number of values defined/returned by this 96563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operator. 96663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 967f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumValues() const { return NumValues; } 96863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 96963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the type of a specified result. 97063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 97163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MVT::ValueType getValueType(unsigned ResNo) const { 972f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(ResNo < NumValues && "Illegal result number!"); 973f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return ValueList[ResNo]; 97463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 9759eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen 976f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner typedef const MVT::ValueType* value_iterator; 977f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_begin() const { return ValueList; } 978f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_end() const { return ValueList+NumValues; } 97963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 9806e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// getOperationName - Return the opcode of this operation for printing. 9816e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// 982ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer std::string getOperationName(const SelectionDAG *G = 0) const; 983144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng static const char* getIndexedModeName(ISD::MemIndexedMode AM); 98463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner void dump() const; 985efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner void dump(const SelectionDAG *G) const; 98663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 98763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *) { return true; } 98863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 989583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// Profile - Gather unique data for the node. 990583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// 991583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey void Profile(FoldingSetNodeID &ID); 992583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey 99363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 99463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 995109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner 996109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// getValueTypeList - Return a pointer to the specified value type. 997109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// 998109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner static MVT::ValueType *getValueTypeList(MVT::ValueType VT); 99963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner static SDVTList getSDVTList(MVT::ValueType VT) { 100063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner SDVTList Ret = { getValueTypeList(VT), 1 }; 100163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner return Ret; 10022d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 100363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 1004ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps) 1005b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng : NodeType(Opc), NodeId(-1) { 100663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner OperandsNeedDelete = true; 1007f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner NumOperands = NumOps; 1008bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = NumOps ? new SDOperand[NumOperands] : 0; 1009f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 1010bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner for (unsigned i = 0; i != NumOps; ++i) { 1011f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner OperandList[i] = Ops[i]; 1012bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[i].Val->Uses.push_back(this); 10130442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner } 1014bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1015ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner ValueList = VTs.VTs; 1016ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner NumValues = VTs.NumVTs; 1017b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner Prev = 0; Next = 0; 1018f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner } 1019bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDNode(unsigned Opc, SDVTList VTs) : NodeType(Opc), NodeId(-1) { 1020bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandsNeedDelete = false; // Operands set with InitOperands. 1021bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = 0; 1022bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = 0; 1023bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1024bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner ValueList = VTs.VTs; 1025bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumValues = VTs.NumVTs; 1026bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Prev = 0; Next = 0; 1027bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 1028bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1029bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// InitOperands - Initialize the operands list of this node with the 1030bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// specified values, which are part of the node (thus they don't need to be 1031bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// copied in or allocated). 1032bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner void InitOperands(SDOperand *Ops, unsigned NumOps) { 1033bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner assert(OperandList == 0 && "Operands already set!"); 1034bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = NumOps; 1035bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = Ops; 1036bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1037bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner for (unsigned i = 0; i != NumOps; ++i) 1038bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[i].Val->Uses.push_back(this); 1039bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 1040bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1041d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// MorphNodeTo - This frees the operands of the current node, resets the 1042d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// opcode, types, and operands to the specified value. This should only be 1043d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// used by the SelectionDAG class. 1044d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner void MorphNodeTo(unsigned Opc, SDVTList L, 1045d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner const SDOperand *Ops, unsigned NumOps); 10461b95095857b78e12138c22e76c7936611c51355bChris Lattner 10478c3484c5181834e6b7060a6064ac769878101f23Chris Lattner void addUser(SDNode *User) { 10488c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses.push_back(User); 10491b95095857b78e12138c22e76c7936611c51355bChris Lattner } 1050d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner void removeUser(SDNode *User) { 1051d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner // Remove this user from the operand's use list. 1052d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner for (unsigned i = Uses.size(); ; --i) { 1053d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner assert(i != 0 && "Didn't find user!"); 1054d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner if (Uses[i-1] == User) { 10558c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses[i-1] = Uses.back(); 10568c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses.pop_back(); 10578c3484c5181834e6b7060a6064ac769878101f23Chris Lattner return; 1058d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 1059d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 1060d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 106163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 106263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 106363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 106463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// Define inline functions from the SDOperand class. 106563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 106663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getOpcode() const { 106763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getOpcode(); 106863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 106963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline MVT::ValueType SDOperand::getValueType() const { 107063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getValueType(ResNo); 107163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 107263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getNumOperands() const { 107363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getNumOperands(); 107463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 107563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline const SDOperand &SDOperand::getOperand(unsigned i) const { 107663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getOperand(i); 107763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1078c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chenginline uint64_t SDOperand::getConstantOperandVal(unsigned i) const { 1079c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng return Val->getConstantOperandVal(i); 1080c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 10810f66a9172175aa7c3055333358170581c999219bNate Begemaninline bool SDOperand::isTargetOpcode() const { 10820f66a9172175aa7c3055333358170581c999219bNate Begeman return Val->isTargetOpcode(); 10830f66a9172175aa7c3055333358170581c999219bNate Begeman} 10840f66a9172175aa7c3055333358170581c999219bNate Begemaninline unsigned SDOperand::getTargetOpcode() const { 10850f66a9172175aa7c3055333358170581c999219bNate Begeman return Val->getTargetOpcode(); 10860f66a9172175aa7c3055333358170581c999219bNate Begeman} 1087a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattnerinline bool SDOperand::hasOneUse() const { 1088a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner return Val->hasNUsesOfValue(1, ResNo); 1089a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner} 1090e1b50639a860934685dff840e1826b16dbe6a344Dan Gohmaninline bool SDOperand::use_empty() const { 1091e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman return !Val->hasAnyUseOfValue(ResNo); 1092e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman} 109363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 10943f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes. This is solely 10953f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 10963f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode { 10973f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 10983f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Op; 10993f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 11003f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X) 11013f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs), Op(X) { 11023f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(&Op, 1); 11033f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 11043f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 11053f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 11063f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes. This is solely 11073f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 11083f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode { 11093f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 11103f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Ops[2]; 11113f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 11123f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y) 11133f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 11143f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 11153f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 11163f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 2); 11173f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 11183f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 11193f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 11203f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely 11213f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 11223f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode { 11233f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 11243f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Ops[3]; 11253f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 11263f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y, 11273f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Z) 11283f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 11293f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 11303f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 11313f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[2] = Z; 11323f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 3); 11333f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 11343f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 11353f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 11363f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 1137d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that 1138d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its 1139d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand. This node should be directly created by end-users and not added to 1140d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list. 1141d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode { 1142c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1143bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDOperand Op; 1144d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic: 1145423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit HandleSDNode(SDOperand X) 1146bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) { 1147bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner InitOperands(&Op, 1); 1148bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 114948b85926524f9d29ae600123c90194cd73fd629eChris Lattner ~HandleSDNode(); 1150bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDOperand getValue() const { return Op; } 1151d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner}; 1152d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner 115347725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerclass StringSDNode : public SDNode { 115447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner std::string Value; 1155c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 115647725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerprotected: 115747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner friend class SelectionDAG; 1158423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit StringSDNode(const std::string &val) 1159bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) { 116047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner } 116147725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerpublic: 116247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner const std::string &getValue() const { return Value; } 116347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner static bool classof(const StringSDNode *) { return true; } 116447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner static bool classof(const SDNode *N) { 116547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner return N->getOpcode() == ISD::STRING; 116647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner } 116747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner}; 116863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 116963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode { 117063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner uint64_t Value; 1171c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 117263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 117363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1174056f9f61d071c6c583951678f2bf543a1316efccChris Lattner ConstantSDNode(bool isTarget, uint64_t val, MVT::ValueType VT) 1175bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)), 1176bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Value(val) { 117763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 117863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 117963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 118063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner uint64_t getValue() const { return Value; } 118163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 118263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int64_t getSignExtended() const { 118363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Bits = MVT::getSizeInBits(getValueType(0)); 1184f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattner return ((int64_t)Value << (64-Bits)) >> (64-Bits); 118563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 118663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 118763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool isNullValue() const { return Value == 0; } 118863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool isAllOnesValue() const { 1189885a87ef8512a184a58a0ebe39705ccb221749efChris Lattner return Value == MVT::getIntVTBitMask(getValueType(0)); 119063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 119163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 119263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantSDNode *) { return true; } 119363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1194056f9f61d071c6c583951678f2bf543a1316efccChris Lattner return N->getOpcode() == ISD::Constant || 1195056f9f61d071c6c583951678f2bf543a1316efccChris Lattner N->getOpcode() == ISD::TargetConstant; 119663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 119763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 119863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 119963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode { 12008bb369b8072c919ef5802f639a52b17620201190Dale Johannesen APFloat Value; 1201c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1202c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen // Longterm plan: replace all uses of getValue with getValueAPF, remove 1203c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen // getValue, rename getValueAPF to getValue. 120463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 120563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1206e6c1742914149d44360fbf05a653041a672282afDale Johannesen ConstantFPSDNode(bool isTarget, const APFloat& val, MVT::ValueType VT) 120787503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 120887503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen getSDVTList(VT)), Value(val) { 120963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 121063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 121163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1212e6c1742914149d44360fbf05a653041a672282afDale Johannesen const APFloat& getValueAPF() const { return Value; } 121363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 121463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isExactlyValue - We don't rely on operator== working on double values, as 121563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 121663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// As such, this method can be used to do an exact bit-for-bit comparison of 121763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// two floating point values. 1218c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen 1219c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// We leave the version with the double argument here because it's just so 1220c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// convenient to write "2.0" and the like. Without this function we'd 1221c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// have to duplicate its logic everywhere it's called. 122287503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen bool isExactlyValue(double V) const { 122384cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner APFloat Tmp(V); 122484cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven); 122584cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner return isExactlyValue(Tmp); 122687503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen } 1227e6c1742914149d44360fbf05a653041a672282afDale Johannesen bool isExactlyValue(const APFloat& V) const; 122863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1229f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen bool isValueValidForType(MVT::ValueType VT, const APFloat& Val); 1230f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen 123163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantFPSDNode *) { return true; } 123263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1233ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner return N->getOpcode() == ISD::ConstantFP || 1234ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner N->getOpcode() == ISD::TargetConstantFP; 123563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 123663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 123763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 123863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode { 123963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *TheGlobal; 1240404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int Offset; 1241c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 124263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 124363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 124461ca74bc3a29b2af2be7e4bd612289da8aae85b5Evan Cheng GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT, 12452c5c111b6c144b05718404c85b9dfcc76b1619e7Lauro Ramos Venancio int o = 0); 124663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 124763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 124863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *getGlobal() const { return TheGlobal; } 1249404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int getOffset() const { return Offset; } 125063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 125163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const GlobalAddressSDNode *) { return true; } 125263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1253f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner return N->getOpcode() == ISD::GlobalAddress || 1254b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalAddress || 1255b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::GlobalTLSAddress || 1256b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalTLSAddress; 125763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 125863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 125963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 126063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode { 126163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int FI; 1262c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 126363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 126463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1265afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg) 1266bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)), 1267bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner FI(fi) { 126863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 126963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 127063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 127163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int getIndex() const { return FI; } 127263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 127363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const FrameIndexSDNode *) { return true; } 127463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1275afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner return N->getOpcode() == ISD::FrameIndex || 1276afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner N->getOpcode() == ISD::TargetFrameIndex; 127763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 127863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 127963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 128037efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode { 128137efe6764568a3829fee26aba532283131d1a104Nate Begeman int JTI; 1282c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 128337efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected: 128437efe6764568a3829fee26aba532283131d1a104Nate Begeman friend class SelectionDAG; 128537efe6764568a3829fee26aba532283131d1a104Nate Begeman JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg) 1286bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)), 1287bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner JTI(jti) { 128863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 128937efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic: 129037efe6764568a3829fee26aba532283131d1a104Nate Begeman 129137efe6764568a3829fee26aba532283131d1a104Nate Begeman int getIndex() const { return JTI; } 129237efe6764568a3829fee26aba532283131d1a104Nate Begeman 129337efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const JumpTableSDNode *) { return true; } 129437efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const SDNode *N) { 129537efe6764568a3829fee26aba532283131d1a104Nate Begeman return N->getOpcode() == ISD::JumpTable || 129637efe6764568a3829fee26aba532283131d1a104Nate Begeman N->getOpcode() == ISD::TargetJumpTable; 129737efe6764568a3829fee26aba532283131d1a104Nate Begeman } 129837efe6764568a3829fee26aba532283131d1a104Nate Begeman}; 129937efe6764568a3829fee26aba532283131d1a104Nate Begeman 130063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode { 1301d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng union { 1302d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *ConstVal; 1303d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *MachineCPVal; 1304d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } Val; 1305baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int Offset; // It's a MachineConstantPoolValue if top bit is set. 1306b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned Alignment; 1307c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 130863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 130963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1310404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, 1311404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int o=0) 1312ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1313bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1314d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1315d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1316d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1317404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o, 1318404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng unsigned Align) 1319ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1320bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1321d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1322d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1323d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1324d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1325d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MVT::ValueType VT, int o=0) 1326ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1327bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1328d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1329d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1330d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1331d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1332d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1333d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MVT::ValueType VT, int o, unsigned Align) 1334ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1335bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1336d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1337d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1338d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1339d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 134063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 134163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1342d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng bool isMachineConstantPoolEntry() const { 1343d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return (int)Offset < 0; 1344d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1345d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1346d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *getConstVal() const { 1347d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1348d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.ConstVal; 1349d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1350d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1351d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *getMachineCPVal() const { 1352d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1353d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.MachineCPVal; 1354d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1355d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1356baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int getOffset() const { 1357baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng return Offset & ~(1 << (sizeof(unsigned)*8-1)); 1358baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng } 1359ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner 1360ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // Return the alignment of this constant pool object, which is either 0 (for 1361ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // default alignment) or log2 of the desired value. 1362b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned getAlignment() const { return Alignment; } 136363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1364d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng const Type *getType() const; 1365d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 136663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantPoolSDNode *) { return true; } 136763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1368aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner return N->getOpcode() == ISD::ConstantPool || 1369aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner N->getOpcode() == ISD::TargetConstantPool; 137063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 137163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 137263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 137363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode { 137463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *MBB; 1375c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 137663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 137763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1378423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit BasicBlockSDNode(MachineBasicBlock *mbb) 1379bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) { 138063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 138163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 138263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 138363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *getBasicBlock() const { return MBB; } 138463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 138563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const BasicBlockSDNode *) { return true; } 138663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 138763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return N->getOpcode() == ISD::BasicBlock; 138863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 138963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 139063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13912d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode { 13922d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *V; 1393c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 13942d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected: 13952d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth friend class SelectionDAG; 1396c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman /// Create a SrcValue for a general value. 1397c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman explicit SrcValueSDNode(const Value *v) 1398c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {} 13992d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 14002d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic: 1401c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman /// getValue - return the contained Value. 14022d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *getValue() const { return V; } 14032d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 14042d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SrcValueSDNode *) { return true; } 14052d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SDNode *N) { 14062d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth return N->getOpcode() == ISD::SRCVALUE; 14072d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 14082d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth}; 14092d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 141063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1411c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman/// MemOperandSDNode - An SDNode that holds a MemOperand. This is 1412c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman/// used to represent a reference to memory after ISD::LOAD 1413c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman/// and ISD::STORE have been lowered. 1414c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman/// 1415c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohmanclass MemOperandSDNode : public SDNode { 1416c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1417c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohmanprotected: 1418c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman friend class SelectionDAG; 1419c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman /// Create a MemOperand node 1420c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman explicit MemOperandSDNode(MemOperand mo) 1421c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {} 1422c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman 1423c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohmanpublic: 1424c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman /// MO - The contained MemOperand. 1425c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman const MemOperand MO; 1426c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman 1427c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman static bool classof(const MemOperandSDNode *) { return true; } 1428c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman static bool classof(const SDNode *N) { 1429c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman return N->getOpcode() == ISD::MEMOPERAND; 1430c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman } 1431c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman}; 1432c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman 1433c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman 1434d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode { 143563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Reg; 1436c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 143763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 143863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1439d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner RegisterSDNode(unsigned reg, MVT::ValueType VT) 1440bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) { 144163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 144263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 144363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 144463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getReg() const { return Reg; } 144563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1446d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner static bool classof(const RegisterSDNode *) { return true; } 144763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1448d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner return N->getOpcode() == ISD::Register; 144963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 145063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 145163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 145263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ExternalSymbolSDNode : public SDNode { 145363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *Symbol; 1454c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 145563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 145663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 14572a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT) 1458ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 1459bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Symbol(Sym) { 146063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 146163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 146263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 146363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *getSymbol() const { return Symbol; } 146463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 146563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ExternalSymbolSDNode *) { return true; } 146663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 14672a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth return N->getOpcode() == ISD::ExternalSymbol || 14682a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth N->getOpcode() == ISD::TargetExternalSymbol; 146963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 147063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 147163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 14727cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode { 147363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ISD::CondCode Condition; 1474c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 147563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 147663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1477423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit CondCodeSDNode(ISD::CondCode Cond) 1478bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) { 147963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 148063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 148163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 14827cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner ISD::CondCode get() const { return Condition; } 148363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 14847cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner static bool classof(const CondCodeSDNode *) { return true; } 148563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 14867cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner return N->getOpcode() == ISD::CONDCODE; 148763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 148863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 148963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 149015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// VTSDNode - This class is used to represent MVT::ValueType's, which are used 149115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations. 149215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode { 149315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner MVT::ValueType ValueType; 1494c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 149515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected: 149615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner friend class SelectionDAG; 1497423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit VTSDNode(MVT::ValueType VT) 1498bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) { 149963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 150015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic: 150115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 150215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner MVT::ValueType getVT() const { return ValueType; } 150315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 150415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const VTSDNode *) { return true; } 150515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const SDNode *N) { 150615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner return N->getOpcode() == ISD::VALUETYPE; 150715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner } 150815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner}; 150915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 15109de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode 15119de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// 15129de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LSBaseSDNode : public SDNode { 15139de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprivate: 1514b625f2f8960de32bc973092aaee8ac62863006feDan Gohman // AddrMode - unindexed, pre-indexed, post-indexed. 1515b625f2f8960de32bc973092aaee8ac62863006feDan Gohman ISD::MemIndexedMode AddrMode; 1516b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1517b625f2f8960de32bc973092aaee8ac62863006feDan Gohman // MemoryVT - VT of in-memory value. 1518b625f2f8960de32bc973092aaee8ac62863006feDan Gohman MVT::ValueType MemoryVT; 1519b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 15209de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! SrcValue - Memory location for alias analysis. 15219de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const Value *SrcValue; 15229de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 15239de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! SVOffset - Memory location offset. 15249de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel int SVOffset; 15259de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 15269de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Alignment - Alignment of memory location in bytes. 15279de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel unsigned Alignment; 15289de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 15299de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! IsVolatile - True if the store is volatile. 15309de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel bool IsVolatile; 15319de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprotected: 15329de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Operand array for load and store 15339de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel /*! 15349de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel \note Moving this array to the base class captures more 15359de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel common functionality shared between LoadSDNode and 15369de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel StoreSDNode 15379de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel */ 15389de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel SDOperand Ops[4]; 15399de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic: 1540b625f2f8960de32bc973092aaee8ac62863006feDan Gohman LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned NumOperands, 1541b625f2f8960de32bc973092aaee8ac62863006feDan Gohman SDVTList VTs, ISD::MemIndexedMode AM, MVT::ValueType VT, 1542b625f2f8960de32bc973092aaee8ac62863006feDan Gohman const Value *SV, int SVO, unsigned Align, bool Vol) 15439de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel : SDNode(NodeTy, VTs), 1544b625f2f8960de32bc973092aaee8ac62863006feDan Gohman AddrMode(AM), MemoryVT(VT), 15459de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel SrcValue(SV), SVOffset(SVO), Alignment(Align), IsVolatile(Vol) 1546b625f2f8960de32bc973092aaee8ac62863006feDan Gohman { 1547b625f2f8960de32bc973092aaee8ac62863006feDan Gohman for (unsigned i = 0; i != NumOperands; ++i) 1548b625f2f8960de32bc973092aaee8ac62863006feDan Gohman Ops[i] = Operands[i]; 1549b625f2f8960de32bc973092aaee8ac62863006feDan Gohman InitOperands(Ops, NumOperands); 1550b625f2f8960de32bc973092aaee8ac62863006feDan Gohman assert(Align != 0 && "Loads and stores should have non-zero aligment"); 1551b625f2f8960de32bc973092aaee8ac62863006feDan Gohman assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) && 1552b625f2f8960de32bc973092aaee8ac62863006feDan Gohman "Only indexed loads and stores have a non-undef offset operand"); 1553b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 15549de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 15559de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const SDOperand getChain() const { 15569de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel return getOperand(0); 15579de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel } 15589de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const SDOperand getBasePtr() const { 15599de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel return getOperand(getOpcode() == ISD::LOAD ? 1 : 2); 15609de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel } 15619de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const SDOperand getOffset() const { 15629de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); 15639de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel } 15649de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const SDOperand getValue() const { 15659de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel assert(getOpcode() == ISD::STORE); 15669de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel return getOperand(1); 15679de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel } 15689de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 15699de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const Value *getSrcValue() const { return SrcValue; } 15709de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel int getSrcValueOffset() const { return SVOffset; } 15719de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel unsigned getAlignment() const { return Alignment; } 1572b625f2f8960de32bc973092aaee8ac62863006feDan Gohman MVT::ValueType getMemoryVT() const { return MemoryVT; } 15739de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel bool isVolatile() const { return IsVolatile; } 15749de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 1575b625f2f8960de32bc973092aaee8ac62863006feDan Gohman ISD::MemIndexedMode getAddressingMode() const { return AddrMode; } 1576b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1577b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isIndexed - Return true if this is a pre/post inc/dec load/store. 1578b625f2f8960de32bc973092aaee8ac62863006feDan Gohman bool isIndexed() const { return AddrMode != ISD::UNINDEXED; } 1579b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1580b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. 1581b625f2f8960de32bc973092aaee8ac62863006feDan Gohman bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; } 1582b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1583c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman /// getMemOperand - Return a MemOperand object describing the memory 1584c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman /// reference performed by this load or store. 1585c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman MemOperand getMemOperand() const; 1586c6c391daddbafa722d9ca87d18f204e9a6e617a3Dan Gohman 15879de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel static bool classof(const LSBaseSDNode *N) { return true; } 1588b625f2f8960de32bc973092aaee8ac62863006feDan Gohman static bool classof(const SDNode *N) { 1589b625f2f8960de32bc973092aaee8ac62863006feDan Gohman return N->getOpcode() == ISD::LOAD || 1590b625f2f8960de32bc973092aaee8ac62863006feDan Gohman N->getOpcode() == ISD::STORE; 1591b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 15929de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel}; 15939de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 159424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes. 159524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 15969de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode { 1597c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1598bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 159981c384578828dde08f63a4f030f4860a92391cddEvan Cheng // ExtType - non-ext, anyext, sext, zext. 160081c384578828dde08f63a4f030f4860a92391cddEvan Cheng ISD::LoadExtType ExtType; 160181c384578828dde08f63a4f030f4860a92391cddEvan Cheng 160224446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 160324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 1604ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs, 1605144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT, 160695c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 1607b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3, 1608b625f2f8960de32bc973092aaee8ac62863006feDan Gohman VTs, AM, LVT, SV, O, Align, Vol), 1609b625f2f8960de32bc973092aaee8ac62863006feDan Gohman ExtType(ETy) { } 161024446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 161124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 161224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng ISD::LoadExtType getExtensionType() const { return ExtType; } 161339354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 161424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const LoadSDNode *) { return true; } 161524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 161624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD; 161724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 161824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 161924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 162024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes. 162124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 16229de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode { 1623c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1624bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 16253ec81c0ee73462b7b9acd355b0013827d06ad93cDuncan Sands // IsTruncStore - True if the op does a truncation before store. 162681c384578828dde08f63a4f030f4860a92391cddEvan Cheng bool IsTruncStore; 162724446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 162824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 1629ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs, 1630144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT, 163124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 1632b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4, 1633b625f2f8960de32bc973092aaee8ac62863006feDan Gohman VTs, AM, SVT, SV, O, Align, Vol), 1634b625f2f8960de32bc973092aaee8ac62863006feDan Gohman IsTruncStore(isTrunc) { } 163524446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 163624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 163724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng bool isTruncatingStore() const { return IsTruncStore; } 163839354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 16396d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng static bool classof(const StoreSDNode *) { return true; } 164024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 164124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::STORE; 164224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 164324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 164424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 164515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 16461080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { 16471080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNode *Node; 16481080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned Operand; 1649ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 16501080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 16511080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic: 16521080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator==(const SDNodeIterator& x) const { 16531080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Operand == x.Operand; 16541080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 16551080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 16561080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 16571080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNodeIterator &operator=(const SDNodeIterator &I) { 16581080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 16591080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner Operand = I.Operand; 16601080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 16611080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 1662ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 16631080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator*() const { 16641080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Node->getOperand(Operand).Val; 16651080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 16661080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator->() const { return operator*(); } 1667ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 16681080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator& operator++() { // Preincrement 16691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner ++Operand; 16701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 16711080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 16721080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator operator++(int) { // Postincrement 1673ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SDNodeIterator tmp = *this; ++*this; return tmp; 16741080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 16751080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 16761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 16771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator end (SDNode *N) { 16781080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator(N, N->getNumOperands()); 16791080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 16801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 16811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned getOperand() const { return Operand; } 16821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNode *getNode() const { return Node; } 16831080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 16841080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 16851080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> { 16861080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNode NodeType; 16871080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNodeIterator ChildIteratorType; 16881080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static inline NodeType *getEntryNode(SDNode *N) { return N; } 1689ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_begin(NodeType *N) { 16901080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::begin(N); 16911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 1692ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_end(NodeType *N) { 16931080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::end(N); 16941080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 16951080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 16961080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 1697b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<> 1698b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnerstruct ilist_traits<SDNode> { 1699b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *getPrev(const SDNode *N) { return N->Prev; } 1700b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *getNext(const SDNode *N) { return N->Next; } 1701b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1702b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; } 1703b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; } 1704b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1705b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *createSentinel() { 1706bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other)); 1707b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 1708b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void destroySentinel(SDNode *N) { delete N; } 1709b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner //static SDNode *createNode(const SDNode &V) { return new SDNode(V); } 1710b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1711b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1712b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void addNodeToList(SDNode *NTy) {} 1713b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void removeNodeFromList(SDNode *NTy) {} 1714b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void transferNodesFromList(iplist<SDNode, ilist_traits> &L2, 1715b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner const ilist_iterator<SDNode> &X, 1716b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner const ilist_iterator<SDNode> &Y) {} 1717b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner}; 1718b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1719c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD { 1720186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// isNormalLoad - Returns true if the specified node is a non-extending 1721186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// and unindexed load. 1722186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng inline bool isNormalLoad(const SDNode *N) { 1723186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng if (N->getOpcode() != ISD::LOAD) 1724186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng return false; 1725186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng const LoadSDNode *Ld = cast<LoadSDNode>(N); 1726186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng return Ld->getExtensionType() == ISD::NON_EXTLOAD && 1727186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng Ld->getAddressingMode() == ISD::UNINDEXED; 1728186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng } 1729186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng 173024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// isNON_EXTLoad - Returns true if the specified node is a non-extending 173124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// load. 173224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng inline bool isNON_EXTLoad(const SDNode *N) { 173324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 173424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 173524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 173624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 1737c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 1738c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1739c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isEXTLoad(const SDNode *N) { 174024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 174124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 1742c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 1743c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1744c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 1745c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1746c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isSEXTLoad(const SDNode *N) { 174724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 174824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 1749c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 1750c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1751c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 1752c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1753c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isZEXTLoad(const SDNode *N) { 175424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 175524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 1756c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 17578b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 175802c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// isUNINDEXEDLoad - Returns true if the specified node is a unindexed load. 175902c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// 176002c50e4891841c28b2a743731dfc60744bb78879Evan Cheng inline bool isUNINDEXEDLoad(const SDNode *N) { 176102c50e4891841c28b2a743731dfc60744bb78879Evan Cheng return N->getOpcode() == ISD::LOAD && 176202c50e4891841c28b2a743731dfc60744bb78879Evan Cheng cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 176302c50e4891841c28b2a743731dfc60744bb78879Evan Cheng } 176402c50e4891841c28b2a743731dfc60744bb78879Evan Cheng 17658b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 17668b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 17678b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isNON_TRUNCStore(const SDNode *N) { 17688b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng return N->getOpcode() == ISD::STORE && 17698b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng !cast<StoreSDNode>(N)->isTruncatingStore(); 17708b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 17718b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 17728b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isTRUNCStore - Returns true if the specified node is a truncating 17738b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 17748b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isTRUNCStore(const SDNode *N) { 17758b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng return N->getOpcode() == ISD::STORE && 17768b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng cast<StoreSDNode>(N)->isTruncatingStore(); 17778b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 1778c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 1779c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1780c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 178163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace 178263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 178363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif 1784