SelectionDAGNodes.h revision 0ea0356dff38dfd0420b8c0a2fdf2fae7898c024
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" 276394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman#include "llvm/ADT/APInt.h" 28d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h" 2969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman#include "llvm/CodeGen/MemOperand.h" 3039931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h" 3163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert> 3263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm { 3463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG; 3663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue; 3763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock; 38d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue; 3963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode; 4076c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate <typename T> struct DenseMapInfo; 4163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type; 42b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate <typename T> struct ilist_traits; 43b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<typename NodeTy, typename Traits> class iplist; 44b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<typename NodeTy> class ilist_iterator; 4563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 460b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by 470b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG. Instances of this simple value class are returned by 480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...). 490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// 500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList { 510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner const MVT::ValueType *VTs; 520b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner unsigned short NumVTs; 530b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner}; 540b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 5563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the 5663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types. 5763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 5863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD { 59d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov namespace ParamFlags { 60d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov enum Flags { 61d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov NoFlagSet = 0, 62d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov ZExt = 1<<0, ///< Parameter should be zero extended 63d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov ZExtOffs = 0, 64d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov SExt = 1<<1, ///< Parameter should be sign extended 65d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov SExtOffs = 1, 66d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov InReg = 1<<2, ///< Parameter should be passed in register 67d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov InRegOffs = 2, 68d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov StructReturn = 1<<3, ///< Hidden struct-return pointer 69d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov StructReturnOffs = 3, 701aa7efbd2c98e761f50992197473304b99257ca9Rafael Espindola ByVal = 1<<4, ///< Struct passed by value 711aa7efbd2c98e761f50992197473304b99257ca9Rafael Espindola ByValOffs = 4, 7236397f50343639ce9a25996f2d790c656791ab92Duncan Sands Nest = 1<<5, ///< Parameter is nested function static chain 7336397f50343639ce9a25996f2d790c656791ab92Duncan Sands NestOffs = 5, 74594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola ByValAlign = 0xF << 6, //< The alignment of the struct 75594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola ByValAlignOffs = 6, 76594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola ByValSize = 0x1ffff << 10, //< The size of the struct 77594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola ByValSizeOffs = 10, 78d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov OrigAlignment = 0x1F<<27, 79d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov OrigAlignmentOffs = 27 80d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov }; 81d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov } 82d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov 8363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 8463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::NodeType enum - This enum defines all of the operators valid in a 8563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SelectionDAG. 8663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 8763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum NodeType { 883258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // DELETED_NODE - This is an illegal flag value that is used to catch 893258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // errors. This opcode is not a legal opcode for any node. 903258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner DELETED_NODE, 913258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner 928a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // EntryToken - This is the marker used to indicate the start of the region. 938a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner EntryToken, 948a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner 958c4bde36a339b1c538002e819daff84caae4cbadReid Spencer // Token factor - This node takes multiple tokens as input and produces a 968a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // single token result. This is used to represent the fact that the operand 978a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // operators are independent of each other. 988a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner TokenFactor, 99f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman 100f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // AssertSext, AssertZext - These nodes record if a register contains a 101f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // value that has already been zero or sign extended from a narrower type. 102f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // These nodes take two operands. The first is the node that has already 103f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // been extended, and the second is a value type node indicating the width 104f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // of the extension 105f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman AssertSext, AssertZext, 106ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 1078a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // Various leaf nodes. 1081ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng STRING, BasicBlock, VALUETYPE, CONDCODE, Register, 1091ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng Constant, ConstantFP, 110b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio GlobalAddress, GlobalTLSAddress, FrameIndex, 111b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio JumpTable, ConstantPool, ExternalSymbol, 1121ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng 11382c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth // The address of the GOT 11482c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth GLOBAL_OFFSET_TABLE, 115bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman 116bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and 117bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // llvm.returnaddress on the DAG. These nodes take one operand, the index 118bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // of the frame or return address to return. An index of zero corresponds 119bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // to the current function's frame or return address, an index of one to the 120bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // parent's frame or return address, and so on. 121bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman FRAMEADDR, RETURNADDR, 1222365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 1232365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to 1242365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // first (possible) on-stack argument. This is needed for correct stack 1252365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // adjustment during unwind. 1262365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov FRAME_TO_ARGS_OFFSET, 127f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 128f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the 129f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // address of the exception block on entry to an landing pad block. 130f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EXCEPTIONADDR, 131f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 132f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents 133f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // the selection index of the exception thrown. 134f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EHSELECTION, 135beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth 1362365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 1372365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // 'eh_return' gcc dwarf builtin, which is used to return from 1382365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // exception. The general meaning is: adjust stack by OFFSET and pass 1392365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // execution to HANDLER. Many platform-related details also :) 1402365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov EH_RETURN, 1412365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 142ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // TargetConstant* - Like Constant*, but the DAG does not do any folding or 143ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // simplification of the constant. 144056f9f61d071c6c583951678f2bf543a1316efccChris Lattner TargetConstant, 145ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner TargetConstantFP, 146f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner 147f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or 148f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // anything else with this node, and this is valid in the target-specific 149f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // dag, turning into a GlobalAddress operand. 150f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner TargetGlobalAddress, 151b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio TargetGlobalTLSAddress, 152afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner TargetFrameIndex, 15337efe6764568a3829fee26aba532283131d1a104Nate Begeman TargetJumpTable, 154aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner TargetConstantPool, 1552a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth TargetExternalSymbol, 15672601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner 157ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) 158ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with no side effects. 159ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// The first operand is the ID number of the intrinsic from the 160ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The 161ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// node has returns the result of the intrinsic. 162ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_WO_CHAIN, 163ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 164ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) 165ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 166ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// returns a result. The first operand is a chain pointer. The second is 167ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The 168ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// operands to the intrinsic follow. The node has two results, the result 169ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// of the intrinsic and an output chain. 170ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_W_CHAIN, 17163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 172ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) 173ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 174ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// does not return a result. The first operand is a chain pointer. The 175ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// second is the ID number of the intrinsic from the llvm::Intrinsic 176ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// namespace. The operands to the intrinsic follow. 177ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_VOID, 178ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 179d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // CopyToReg - This node has three operands: a chain, a register number to 180d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // set to this value, and a value. 18163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyToReg, 18263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 18363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // CopyFromReg - This node indicates that the input value is a virtual or 18463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // physical register that is defined outside of the scope of this 185ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman // SelectionDAG. The register is available from the RegisterSDNode object. 18663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyFromReg, 18763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 188fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman // UNDEF - An undefined node 189fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman UNDEF, 190681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner 191b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node 192b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// represents the formal arguments for a function. CC# is a Constant value 193b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// indicating the calling convention of the function, and ISVARARG is a 194b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// flag that indicates whether the function is varargs or not. This node 195b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// has one result value for each incoming argument, plus one for the output 196b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// chain. It must be custom legalized. See description of CALL node for 197b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FLAG argument contents explanation. 198c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner /// 199681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner FORMAL_ARGUMENTS, 2006c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner 2016c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE, 202b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn) 2036c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// This node represents a fully general function call, before the legalizer 204b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// runs. This has one result value for each argument / flag pair, plus 205b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// a chain result. It must be custom legalized. Flag argument indicates 206b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// misc. argument attributes. Currently: 207b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 0 - signness 208b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 1 - 'inreg' attribute 209b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 2 - 'sret' attribute 210594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 4 - 'byval' attribute 211594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 5 - 'nest' attribute 212594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 6-9 - alignment of byval structures 213594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 10-26 - size of byval structures 21413a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// Bits 31:27 - argument ABI alignment in the first argument piece and 21513a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// alignment '1' in other argument pieces. 2166c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner CALL, 217fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman 21863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // EXTRACT_ELEMENT - This is used to get the first or second (determined by 21963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // a Constant, which is required to be operand #1), element of the aggregate 22063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // value specified as operand #0. This is only for use before legalization, 22163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // for values that will be broken into multiple registers. 22263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner EXTRACT_ELEMENT, 22363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 22463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given 22563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // two values of the same integer value type, this produces a value twice as 22663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // big. Like EXTRACT_ELEMENT, this can only be used before legalization. 22763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BUILD_PAIR, 228006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner 229006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // MERGE_VALUES - This node takes multiple discrete operands and returns 230006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // them all as its individual results. This nodes has exactly the same 231006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // number of inputs and outputs, and is only valid before legalization. 232006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // This node is useful for some pieces of the code generator that want to 233006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // think about a single node with multiple results, not multiple nodes. 234006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner MERGE_VALUES, 23563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 236615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple integer binary arithmetic operators. 237bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, 238fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 239fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing 240b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // a signed/unsigned value of type i[2*N], and return the full value as 241fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // two results, each of type iN. 242fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SMUL_LOHI, UMUL_LOHI, 243fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 244fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and 245fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // remainder result. 246fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SDIVREM, UDIVREM, 247615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner 24855e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // CARRY_FALSE - This node is used when folding other nodes, 24955e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // like ADDC/SUBC, which indicate the carry result is always false. 25055e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner CARRY_FALSE, 25155e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner 252551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-setting nodes for multiple precision addition and subtraction. 253551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // These nodes take two operands of the same value type, and produce two 254551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // results. The first result is the normal add or sub result, the second 255551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // result is the carry flag result. 256551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDC, SUBC, 257551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 258551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-using nodes for multiple precision addition and subtraction. These 259551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // nodes take three operands: The first two are the normal lhs and rhs to 260551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // the add or sub, and the third is the input carry flag. These nodes 261551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // produce two results; the normal result of the add or sub, and the output 262551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // carry flag. These nodes both read and write a carry flag to allow them 263551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // to them to be chained together for add and sub of arbitrarily large 264551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // values. 265551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDE, SUBE, 266551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 267615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple binary floating point operators. 268615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner FADD, FSUB, FMUL, FDIV, FREM, 26938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 27038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This 27138bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // DAG node does not require that X and Y have the same type, just that they 27238bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // are both floating point. X and the result must have the same type. 27338bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(f32, f64) is allowed. 27438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner FCOPYSIGN, 275fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner 2761a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point 2771a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // value as an integer 0/1 value. 2781a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner FGETSIGN, 2791a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner 280664e9546d674096c5a012536f1a424b1681ece51Dan Gohman /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector 28122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// with the specified, possibly variable, elements. The number of elements 28222232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// is required to be a power of two. 28322232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner BUILD_VECTOR, 28422232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2857f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element 2864f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// at IDX replaced with VAL. If the type of VAL is larger than the vector 2874f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// element type then VAL is truncated before replacement. 28822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner INSERT_VECTOR_ELT, 2894b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner 2904b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR 2917f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// identified by the (potentially variable) element number IDX. 2924b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner EXTRACT_VECTOR_ELT, 29322232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2947f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of 2957f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector type with the same length and element type, this produces a 2967f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// concatenated vector result value, with length equal to the sum of the 297b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman /// lengths of the input vectors. 2987f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman CONCAT_VECTORS, 2996595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman 3007f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an 3017f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector value) starting with the (potentially variable) element number 3027f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// IDX, which must be a multiple of the result vector length. 3037f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman EXTRACT_SUBVECTOR, 30459c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 30549c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same 30649c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values 30759c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// (maybe of an illegal datatype) or undef that indicate which value each 30859c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// result element will get. The elements of VEC1/VEC2 are enumerated in 30959c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// order. This is quite similar to the Altivec 'vperm' instruction, except 31059c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// that the indices must be constants and are in terms of the element size 31159c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// of VEC1/VEC2, not in terms of bytes. 31249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner VECTOR_SHUFFLE, 31359c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 314210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a 315a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// scalar value into element 0 of the resultant vector type. The top 316a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// elements 1 to N-1 of the N-element vector are undefined. 317210721aecc0916315f61660dc387a96b89ec423bChris Lattner SCALAR_TO_VECTOR, 318210721aecc0916315f61660dc387a96b89ec423bChris Lattner 319557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // EXTRACT_SUBREG - This node is used to extract a sub-register value. 320557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg and a constant sub-register index as operands. 321557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb EXTRACT_SUBREG, 322557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 323557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // INSERT_SUBREG - This node is used to insert a sub-register value. 324557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg, a subreg value, and a constant sub-register 325557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // index as operands. 326557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb INSERT_SUBREG, 327557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 328bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing 329b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // an unsigned/signed value of type i[2*N], then return the top part. 330bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner MULHU, MULHS, 33163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 33235ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // Bitwise operators - logical and, logical or, logical xor, shift left, 33335ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // shift right algebraic (shift in sign bits), shift right logical (shift in 33435ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // zeroes), rotate left, rotate right, and byteswap. 33535ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP, 33663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 337691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth // Counting operators 338691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth CTTZ, CTLZ, CTPOP, 339691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth 340fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner // Select(COND, TRUEVAL, FALSEVAL) 3419373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT, 3429373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman 3439373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // Select with condition operator - This selects between a true value and 3449373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // a false value (ops #2 and #3) based on the boolean result of comparing 3459373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // the lhs and rhs (ops #0 and #1) of a conditional expression with the 3469373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // condition code in op #4, a CondCodeSDNode. 3479373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT_CC, 34863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 34963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SetCC operator - This evaluates to a boolean (i1) true value if the 3507cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // condition is true. The operands to this are the left and right operands 3517cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // to compare (ops #0, and #1) and the condition code to compare them with 3527cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // (op #2) as a CondCodeSDNode. 35363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETCC, 35463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 35514c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded 35614c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // integer shift operations, just like ADD/SUB_PARTS. The operation 35714c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // ordering is: 3586b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner // [Lo,Hi] = op [LoLHS,HiLHS], Amt 35914c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner SHL_PARTS, SRA_PARTS, SRL_PARTS, 36014c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner 36163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Conversion operators. These are all single input single output 36263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operations. For all of these, the result type must be strictly 36363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // wider or narrower (depending on the operation) than the source 36463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // type. 36563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 36663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SIGN_EXTEND - Used for integer types, replicating the sign bit 36763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // into new bits. 36863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SIGN_EXTEND, 36963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 37063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // ZERO_EXTEND - Used for integer types, zeroing the new bits. 37163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ZERO_EXTEND, 37263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3737e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner // ANY_EXTEND - Used for integer types. The high bits are undefined. 3747e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner ANY_EXTEND, 3757e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner 37663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // TRUNCATE - Completely drop the high bits. 37763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner TRUNCATE, 37863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3791645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign 3801645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // depends on the first letter) to floating point. 3811645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner SINT_TO_FP, 3821645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner UINT_TO_FP, 3831645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 384ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to 385ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // sign extend a small value in a large integer register (e.g. sign 386ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // extending the low 8 bits of a 32-bit register to fill the top 24 bits 38715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // with the 7th bit). The size of the smaller type is indicated by the 1th 38815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // operand, a ValueType node. 389859157daee6a4b49e99921832e1dde065167b317Chris Lattner SIGN_EXTEND_INREG, 390859157daee6a4b49e99921832e1dde065167b317Chris Lattner 3910bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned 3920bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// integer. 3931645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_SINT, 3941645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_UINT, 3951645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 3960bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type 3970bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// down to the precision of the destination VT. TRUNC is a flag, which is 3980bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// always an integer that is zero or one. If TRUNC is 0, this is a 3990bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// normal rounding, if it is 1, this FP_ROUND is known to not change the 4000bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// value of Y. 4010bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// 4020bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// The TRUNC = 1 case is used in cases where we know that the value will 4030bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// not be modified by the node, because Y is not using any of the extra 4040bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// precision of source type. This allows certain transformations like 4050bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for 4060bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed. 40763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_ROUND, 4080bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner 4091a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman // FLT_ROUNDS_ - Returns current rounding mode: 410917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // -1 Undefined 411917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 0 Round to 0 412917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 1 Round to nearest 413917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 2 Round to +inf 414917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 3 Round to -inf 4151a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman FLT_ROUNDS_, 416917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov 4170bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and 4180bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// rounds it to a floating point value. It then promotes it and returns it 4190bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// in a register of the same size. This operation effectively just 4200bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// discards excess precision. The type to round down to is specified by 4210bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// the VT operand, a VTSDNode. 422859157daee6a4b49e99921832e1dde065167b317Chris Lattner FP_ROUND_INREG, 423859157daee6a4b49e99921832e1dde065167b317Chris Lattner 4240bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type. 42563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_EXTEND, 42663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4271ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // BIT_CONVERT - Theis operator converts between integer and FP values, as 4281ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // if one was stored to memory as integer and the other was loaded from the 42980f55abf009c86bc03821e10746832f88f8a735fChris Lattner // same address (or equivalently for vector format conversions, etc). The 43080f55abf009c86bc03821e10746832f88f8a735fChris Lattner // source and result are required to have the same bit size (e.g. 43180f55abf009c86bc03821e10746832f88f8a735fChris Lattner // f32 <-> i32). This can also be used for int-to-int or fp-to-fp 43280f55abf009c86bc03821e10746832f88f8a735fChris Lattner // conversions, but that is a noop, deleted by getNode(). 4331ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner BIT_CONVERT, 4341ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner 43507f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW - Perform unary floating point 43607f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman // negation, absolute value, square root, sine and cosine, powi, and pow 437dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner // operations. 43807f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, 43938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 4408862ef148100070b7bf28beead3951464250c926Evan Cheng // LOAD and STORE have token chains as their first operand, then the same 4418862ef148100070b7bf28beead3951464250c926Evan Cheng // operands as an LLVM load/store instruction, then an offset node that 4428862ef148100070b7bf28beead3951464250c926Evan Cheng // is added / subtracted from the base pointer to form the address (for 4438862ef148100070b7bf28beead3951464250c926Evan Cheng // indexed memory ops). 44463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner LOAD, STORE, 445ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 44663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned 44757fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // to a specified boundary. This node always has two return values: a new 44857fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // stack pointer value and a chain. The first operand is the token chain, 44957fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // the second is the number of bytes to allocate, and the third is the 45057fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment boundary. The size is guaranteed to be a multiple of the stack 45157fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment, and the alignment is guaranteed to be bigger than the stack 45274fe063e90045931eefaba561730e6a9175ced78Chris Lattner // alignment (if required) or 0 to get standard stack alignment. 45363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner DYNAMIC_STACKALLOC, 45463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 45563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Control flow instructions. These all have token chains. 456ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 45763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BR - Unconditional branch. The first operand is the chain 45863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operand, the second is the MBB to branch to. 45963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BR, 46063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 46137efe6764568a3829fee26aba532283131d1a104Nate Begeman // BRIND - Indirect branch. The first operand is the chain, the second 46237efe6764568a3829fee26aba532283131d1a104Nate Begeman // is the value to branch to, which must be of the same type as the target's 46337efe6764568a3829fee26aba532283131d1a104Nate Begeman // pointer type. 46437efe6764568a3829fee26aba532283131d1a104Nate Begeman BRIND, 465c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng 466c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // BR_JT - Jumptable branch. The first operand is the chain, the second 467c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // is the jumptable index, the last one is the jumptable entry index. 468c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng BR_JT, 46937efe6764568a3829fee26aba532283131d1a104Nate Begeman 47063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BRCOND - Conditional branch. The first operand is the chain, 47163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // the second is the condition, the third is the block to branch 47263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // to if the condition is true. 47363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BRCOND, 47463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4757cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in 4767cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // that the condition is represented as condition code, and two nodes to 4777cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // compare, rather than as a combined SetCC node. The operands in order are 4787cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // chain, cc, lhs, rhs, block to branch to if condition is true. 4797cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman BR_CC, 4807cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman 48163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // RET - Return from function. The first operand is the chain, 4828e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // and any subsequent operands are pairs of return value and return value 4838e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // signness for the function. This operation can have variable number of 4848e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // operands. 48563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner RET, 48663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4877572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // INLINEASM - Represents an inline asm block. This node always has two 4887572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // return values: a chain and a flag result. The inputs are as follows: 4897572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #0 : Input chain. 4907572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string. 4917572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+2: A RegisterNode. 4927572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def 4937572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #last: Optional, an incoming flag. 4947572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner INLINEASM, 4951ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey 4961ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // LABEL - Represents a label in mid basic block used to track 4971ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // locations needed for debug and exception handling tables. This node 4981ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // returns a chain. 4991ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // Operand #0 : input chain. 5001ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // Operand #1 : module unique number use to identify the label. 501bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng // Operand #2 : 0 indicates a debug label (e.g. stoppoint), 1 indicates 502bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng // a EH label, 2 indicates unknown label type. 5031ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey LABEL, 504a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng 505a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track 506a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // local variable declarations for debugging information. First operand is 507a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // a chain, while the next two operands are first two arguments (address 508a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // and variable) of a llvm.dbg.declare instruction. 509a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng DECLARE, 510f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 5115a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a 5125a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // value, the same type as the pointer type for the system, and an output 5135a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // chain. 5145a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKSAVE, 5155a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 5165a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKRESTORE has two operands, an input chain and a pointer to restore to 5175a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // it returns an output chain. 5185a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKRESTORE, 5195a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 5205c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola // MEMSET/MEMCPY/MEMMOVE - The first operand is the chain. The following 5215c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola // correspond to the operands of the LLVM intrinsic functions and the last 5225c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola // one is AlwaysInline. The only result is a token chain. The alignment 5235c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola // argument is guaranteed to be a Constant node. 524ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMSET, 525ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMMOVE, 526ef36aa75d7df2bb67e8bfb0da7c43c1b331611e4Chris Lattner MEMCPY, 527ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 52816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of 52916cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // a call sequence, and carry arbitrary information that target might want 53016cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // to know. The first operand is a chain, the rest are specified by the 53116cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // target and not touched by the DAG optimizers. 5320ea0356dff38dfd0420b8c0a2fdf2fae7898c024Dale Johannesen // CALLSEQ_START..CALLSEQ_END pairs may not be nested. 53316cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_START, // Beginning of a call sequence 53416cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_END, // End of a call sequence 535acc398c195a697795bff3245943d104eb19192b9Nate Begeman 536acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAARG - VAARG has three operands: an input chain, a pointer, and a 537acc398c195a697795bff3245943d104eb19192b9Nate Begeman // SRCVALUE. It returns a pair of values: the vaarg value and a new chain. 538acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAARG, 539acc398c195a697795bff3245943d104eb19192b9Nate Begeman 540acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VACOPY - VACOPY has five operands: an input chain, a destination pointer, 541acc398c195a697795bff3245943d104eb19192b9Nate Begeman // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the 542acc398c195a697795bff3245943d104eb19192b9Nate Begeman // source. 543acc398c195a697795bff3245943d104eb19192b9Nate Begeman VACOPY, 544acc398c195a697795bff3245943d104eb19192b9Nate Begeman 545acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a 546acc398c195a697795bff3245943d104eb19192b9Nate Begeman // pointer, and a SRCVALUE. 547acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAEND, VASTART, 54863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 54969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // SRCVALUE - This is a node type that holds a Value* that is used to 55069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // make reference to a value in the LLVM IR. 55121074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner SRCVALUE, 55221074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner 55369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // MEMOPERAND - This is a node that contains a MemOperand which records 55469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // information about a memory reference. This is used to make AliasAnalysis 55569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // queries from the backend. 55669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman MEMOPERAND, 55769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 558e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman // PCMARKER - This corresponds to the pcmarker intrinsic. 55995762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth PCMARKER, 56063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 561aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic. 5628b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // The only operand is a chain and a value and a chain are produced. The 5638b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // value is the contents of the architecture specific cycle counter like 5648b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // register (or other high accuracy low latency clock source) 565aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth READCYCLECOUNTER, 566aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth 567d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner // HANDLENODE node - Used as a handle for various purposes. 568d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner HANDLENODE, 5692d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 57047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // LOCATION - This node is used to represent a source location for debug 57147725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // info. It takes token chain as input, then a line number, then a column 57247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // number, then a filename, then a working dir. It produces a token chain 57347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // as output. 57447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner LOCATION, 57547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner 576f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey // DEBUG_LOC - This node is used to represent source line information 577abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // embedded in the code. It takes a token chain as input, then a line 57844c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey // number, then a column then a file id (provided by MachineModuleInfo.) It 579abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // produces a token chain as output. 580f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey DEBUG_LOC, 58136397f50343639ce9a25996f2d790c656791ab92Duncan Sands 58236397f50343639ce9a25996f2d790c656791ab92Duncan Sands // TRAMPOLINE - This corresponds to the init_trampoline intrinsic. 58336397f50343639ce9a25996f2d790c656791ab92Duncan Sands // It takes as input a token chain, the pointer to the trampoline, 58436397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the pointer to the nested function, the pointer to pass for the 58536397f50343639ce9a25996f2d790c656791ab92Duncan Sands // 'nest' parameter, a SRCVALUE for the trampoline and another for 58636397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the nested function (allowing targets to access the original 587f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // Function*). It produces the result of the intrinsic and a token 588f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // chain as output. 58936397f50343639ce9a25996f2d790c656791ab92Duncan Sands TRAMPOLINE, 59036397f50343639ce9a25996f2d790c656791ab92Duncan Sands 59166fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov // TRAP - Trapping instruction 59266fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov TRAP, 59366fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov 59422c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load, 59522c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // store-store, device) 596ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // This corresponds to the memory.barrier intrinsic. 59722c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // it takes an input chain, 4 operands to specify the type of barrier, an 59822c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // operand specifying if the barrier applies to device and uncached memory 59922c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // and produces an output chain. 60022c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth MEMBARRIER, 60122c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth 602ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // Val, OUTCHAIN = ATOMIC_LCS(INCHAIN, ptr, cmp, swap) 603ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.lcs intrinsic. 604ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // cmp is compared to *ptr, and if equal, swap is stored in *ptr. 605ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 606ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth ATOMIC_LCS, 607ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 608ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // Val, OUTCHAIN = ATOMIC_LAS(INCHAIN, ptr, amt) 609ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.las intrinsic. 610ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // *ptr + amt is stored to *ptr atomically. 611ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 612ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth ATOMIC_LAS, 613ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 614ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) 615ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.swap intrinsic. 616ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // amt is stored to *ptr atomically. 617ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 618ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth ATOMIC_SWAP, 619ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 62063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILTIN_OP_END - This must be the last enum value in this list. 621410354fe0c052141dadeca939395743f8dd58e38Chris Lattner BUILTIN_OP_END 62263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 62363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 624322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// Node predicates 625322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 626a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng /// isBuildVectorAllOnes - Return true if the specified node is a 627322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// BUILD_VECTOR where all of the elements are ~0 or undef. 628a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng bool isBuildVectorAllOnes(const SDNode *N); 6294a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng 6304a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// isBuildVectorAllZeros - Return true if the specified node is a 6314a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// BUILD_VECTOR where all of the elements are 0 or undef. 6324a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng bool isBuildVectorAllZeros(const SDNode *N); 633bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng 634efec751a1b786724862ceff52748df94873a807eEvan Cheng /// isScalarToVector - Return true if the specified node is a 635efec751a1b786724862ceff52748df94873a807eEvan Cheng /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low 636efec751a1b786724862ceff52748df94873a807eEvan Cheng /// element is not an undef. 637efec751a1b786724862ceff52748df94873a807eEvan Cheng bool isScalarToVector(const SDNode *N); 638efec751a1b786724862ceff52748df94873a807eEvan Cheng 639bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// isDebugLabel - Return true if the specified node represents a debug 640fc718542a3e73558af9c0272b0eea67a189e5397Evan Cheng /// label (i.e. ISD::LABEL or TargetInstrInfo::LABEL node and third operand 641bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// is 0). 642bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng bool isDebugLabel(const SDNode *N); 643322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 64463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 645144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// MemIndexedMode enum - This enum defines the load / store indexed 646144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// addressing modes. 64724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 64824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// UNINDEXED "Normal" load / store. The effective address is already 64924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computed and is available in the base pointer. The offset 65081c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// operand is always undefined. In addition to producing a 65181c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// chain, an unindexed load produces one value (result of the 65281c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// load); an unindexed store does not produces a value. 65324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 65435acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// PRE_INC Similar to the unindexed mode where the effective address is 6558862ef148100070b7bf28beead3951464250c926Evan Cheng /// PRE_DEC the value of the base pointer add / subtract the offset. 6568862ef148100070b7bf28beead3951464250c926Evan Cheng /// It considers the computation as being folded into the load / 65724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// store operation (i.e. the load / store does the address 65824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computation as well as performing the memory transaction). 65981c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// The base operand is always undefined. In addition to 66081c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// producing a chain, pre-indexed load produces two values 66181c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// (result of the load and the result of the address 66281c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// computation); a pre-indexed store produces one value (result 66381c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// of the address computation). 66424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 66535acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// POST_INC The effective address is the value of the base pointer. The 6668862ef148100070b7bf28beead3951464250c926Evan Cheng /// POST_DEC value of the offset operand is then added to / subtracted 6678862ef148100070b7bf28beead3951464250c926Evan Cheng /// from the base after memory transaction. In addition to 6688862ef148100070b7bf28beead3951464250c926Evan Cheng /// producing a chain, post-indexed load produces two values 6698862ef148100070b7bf28beead3951464250c926Evan Cheng /// (the result of the load and the result of the base +/- offset 6708862ef148100070b7bf28beead3951464250c926Evan Cheng /// computation); a post-indexed store produces one value (the 6718862ef148100070b7bf28beead3951464250c926Evan Cheng /// the result of the base +/- offset computation). 67224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 673144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng enum MemIndexedMode { 67424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng UNINDEXED = 0, 67535acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_INC, 67635acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_DEC, 67735acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng POST_INC, 678144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng POST_DEC, 679144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng LAST_INDEXED_MODE 68024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng }; 68124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 68224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng //===--------------------------------------------------------------------===// 683c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// LoadExtType enum - This enum defines the three variants of LOADEXT 684c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// (load with extension). 685c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 68624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// SEXTLOAD loads the integer operand and sign extends it to a larger 68724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 68824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// ZEXTLOAD loads the integer operand and zero extends it to a larger 68924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 69024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// EXTLOAD is used for three things: floating point extending loads, 69124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer extending loads [the top bits are undefined], and vector 69224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// extending loads [load into low elt]. 69324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 694c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng enum LoadExtType { 69524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng NON_EXTLOAD = 0, 696c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng EXTLOAD, 697c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng SEXTLOAD, 698c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng ZEXTLOAD, 699c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng LAST_LOADX_TYPE 700c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng }; 701c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 702c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng //===--------------------------------------------------------------------===// 70363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::CondCode enum - These are ordered carefully to make the bitfields 70463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// below work out, when considering SETFALSE (something that never exists 70563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered 70663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal 70763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to. If the "N" column is 1, the result of the comparison is undefined if 70863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the input is a NAN. 70963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 71063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// All of these (except for the 'always folded ops') should be handled for 71163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT, 71263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used. 71363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 71463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Note that these are laid out in a specific order to allow bit-twiddling 71563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to transform conditions. 71663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum CondCode { 71763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Opcode N U L G E Intuitive operation 71863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE, // 0 0 0 0 Always false (always folded) 71963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOEQ, // 0 0 0 1 True if ordered and equal 72063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGT, // 0 0 1 0 True if ordered and greater than 72163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGE, // 0 0 1 1 True if ordered and greater than or equal 72263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLT, // 0 1 0 0 True if ordered and less than 72363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLE, // 0 1 0 1 True if ordered and less than or equal 72463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETONE, // 0 1 1 0 True if ordered and operands are unequal 72563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETO, // 0 1 1 1 True if ordered (no nans) 72663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 72763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUEQ, // 1 0 0 1 True if unordered or equal 72863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGT, // 1 0 1 0 True if unordered or greater than 72963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGE, // 1 0 1 1 True if unordered, greater than, or equal 73063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETULT, // 1 1 0 0 True if unordered or less than 731ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETULE, // 1 1 0 1 True if unordered, less than, or equal 73263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUNE, // 1 1 1 0 True if unordered or not equal 73363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE, // 1 1 1 1 Always true (always folded) 73463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Don't care operations: undefined if the input is a nan. 73563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE2, // 1 X 0 0 0 Always false (always folded) 73663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETEQ, // 1 X 0 0 1 True if equal 73763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGT, // 1 X 0 1 0 True if greater than 73863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGE, // 1 X 0 1 1 True if greater than or equal 73963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETLT, // 1 X 1 0 0 True if less than 740ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETLE, // 1 X 1 0 1 True if less than or equal 74163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETNE, // 1 X 1 1 0 True if not equal 74263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE2, // 1 X 1 1 1 Always true (always folded) 74363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 744410354fe0c052141dadeca939395743f8dd58e38Chris Lattner SETCC_INVALID // Marker value. 74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 74763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isSignedIntSetCC - Return true if this is a setcc instruction that 74863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs a signed comparison when used with integer operands. 74963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isSignedIntSetCC(CondCode Code) { 75063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE; 75163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 75263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 75363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isUnsignedIntSetCC - Return true if this is a setcc instruction that 75463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs an unsigned comparison when used with integer operands. 75563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isUnsignedIntSetCC(CondCode Code) { 75663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE; 75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isTrueWhenEqual - Return true if the specified condition returns true if 76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the two operands to the condition are equal. Note that if one of the two 76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operands is a NaN, this value is meaningless. 76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isTrueWhenEqual(CondCode Cond) { 76363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond & 1) != 0; 76463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 76563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getUnorderedFlavor - This function returns 0 if the condition is always 76763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// false if an operand is a NaN, 1 if the condition is always true if the 76863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operand is a NaN, and 2 if the condition is undefined if the operand is a 76963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// NaN. 77063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getUnorderedFlavor(CondCode Cond) { 77163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond >> 3) & 3; 77263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 77363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCInverse - Return the operation corresponding to !(X op Y), where 77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 'op' is a valid SetCC operation. 77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCInverse(CondCode Operation, bool isInteger); 77763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 77863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) 77963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// when given the operation for (X op Y). 78063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCSwappedOperands(CondCode Operation); 78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 78263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCOrOperation - Return the result of a logical OR between different 78363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This 78463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 78563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 78663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger); 78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCAndOperation - Return the result of a logical AND between 78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This 79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger); 79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm::ISD namespace 79463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 79563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===// 79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple 79863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation. Many nodes return multiple values, 79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns 80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number 80163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values). 80263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that 80463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node. This pair 80563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of information is represented with the SDOperand value type. 80663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 807f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerclass SDOperand { 808f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerpublic: 80963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDNode *Val; // The node defining the value we are using. 81063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned ResNo; // Which return value of the node we are using. 81163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 812ace44dbbabe9ee0498834957632df2af0dbf9c59Reid Spencer SDOperand() : Val(0), ResNo(0) {} 81363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} 81463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 81563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator==(const SDOperand &O) const { 81663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val == O.Val && ResNo == O.ResNo; 81763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 81863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator!=(const SDOperand &O) const { 81963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return !operator==(O); 82063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 82163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool operator<(const SDOperand &O) const { 82263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val < O.Val || (Val == O.Val && ResNo < O.ResNo); 82363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 82463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 82563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDOperand getValue(unsigned R) const { 82663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return SDOperand(Val, R); 82763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 82863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 829917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng // isOperandOf - Return true if this node is an operand of N. 830917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOperandOf(SDNode *N) const; 831bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng 83263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the ValueType of the referenced return value. 83363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 83463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline MVT::ValueType getValueType() const; 835ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 8364fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType()). 8374fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// 8384fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman unsigned getValueSizeInBits() const { 8394fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman return MVT::getSizeInBits(getValueType()); 8404fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman } 8414fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman 84263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Forwarding methods - These forward to the corresponding methods in SDNode. 84363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getOpcode() const; 84463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getNumOperands() const; 84563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline const SDOperand &getOperand(unsigned i) const; 846c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline uint64_t getConstantOperandVal(unsigned i) const; 8470f66a9172175aa7c3055333358170581c999219bNate Begeman inline bool isTargetOpcode() const; 8480f66a9172175aa7c3055333358170581c999219bNate Begeman inline unsigned getTargetOpcode() const; 849a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner 850572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 851572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// reachesChainWithoutSideEffects - Return true if this operand (which must 852572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// be a chain) reaches the specified operand without crossing any 853572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// side-effecting instructions. In practice, this looks through token 854572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// factors and non-volatile loads. In order to remain efficient, this only 855572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// looks a couple of nodes in, it does not do an exhaustive search. 856572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner bool reachesChainWithoutSideEffects(SDOperand Dest, unsigned Depth = 2) const; 857572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 858a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner /// hasOneUse - Return true if there is exactly one operation using this 859a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner /// result value of the defining operator. 860a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner inline bool hasOneUse() const; 861e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman 862e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman /// use_empty - Return true if there are no operations using this 863e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman /// result value of the defining operator. 864e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman inline bool use_empty() const; 86563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 86663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 86763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 86876c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate<> struct DenseMapInfo<SDOperand> { 869c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); } 870c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);} 871c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static unsigned getHashValue(const SDOperand &Val) { 872ae9f3a3b7c915f725aef5a7250e88eaeddda03c6Anton Korobeynikov return ((unsigned)((uintptr_t)Val.Val >> 4) ^ 873ae9f3a3b7c915f725aef5a7250e88eaeddda03c6Anton Korobeynikov (unsigned)((uintptr_t)Val.Val >> 9)) + Val.ResNo; 874c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng } 87576c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) { 87676c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner return LHS == RHS; 87776c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner } 878c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static bool isPod() { return true; } 879c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng}; 880c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng 88163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on 88263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperands as if they were SDNode*'s. 88363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<SDOperand> { 88463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 88563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static SimpleType getSimplifiedValue(const SDOperand &Val) { 88663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return static_cast<SimpleType>(Val.Val); 88763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 88863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 88963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate<> struct simplify_type<const SDOperand> { 89063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 89163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static SimpleType getSimplifiedValue(const SDOperand &Val) { 89263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return static_cast<SimpleType>(Val.Val); 89363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 89463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 89563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 89663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 89763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG. 89863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 899583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskeyclass SDNode : public FoldingSetNode { 9000442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// NodeType - The operation that this node performs. 9010442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 9020442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner unsigned short NodeType; 90363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 90463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true, 90563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// then they will be delete[]'d when the node is destroyed. 90663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner bool OperandsNeedDelete : 1; 9070442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 908b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// NodeId - Unique id per SDNode in the DAG. 909b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int NodeId; 9100442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 911f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// OperandList - The values that are used by this operation. 9120442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 913f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner SDOperand *OperandList; 914f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 915f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// ValueList - The types of the values this node defines. SDNode's may 916f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// define multiple values simultaneously. 9172fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner const MVT::ValueType *ValueList; 91863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 919f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// NumOperands/NumValues - The number of entries in the Operand/Value list. 920f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned short NumOperands, NumValues; 921b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 922b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner /// Prev/Next pointers - These pointers form the linked list of of the 923b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner /// AllNodes list in the current DAG. 924b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner SDNode *Prev, *Next; 925b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner friend struct ilist_traits<SDNode>; 92663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 92763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Uses - These are all of the SDNode's that use a value produced by this 92863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// node. 9295892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner SmallVector<SDNode*,3> Uses; 930917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner 931917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner // Out-of-line virtual method to give class a home. 932917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner virtual void ANCHOR(); 93363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 934b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner virtual ~SDNode() { 935b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner assert(NumOperands == 0 && "Operand list not cleared before deletion"); 9363258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner NodeType = ISD::DELETED_NODE; 937b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 938b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 93963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 94063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Accessors 94163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // 94263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getOpcode() const { return NodeType; } 9430f66a9172175aa7c3055333358170581c999219bNate Begeman bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } 9440f66a9172175aa7c3055333358170581c999219bNate Begeman unsigned getTargetOpcode() const { 9450f66a9172175aa7c3055333358170581c999219bNate Begeman assert(isTargetOpcode() && "Not a target opcode!"); 9460f66a9172175aa7c3055333358170581c999219bNate Begeman return NodeType - ISD::BUILTIN_OP_END; 9470f66a9172175aa7c3055333358170581c999219bNate Begeman } 94863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 94963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner size_t use_size() const { return Uses.size(); } 95063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool use_empty() const { return Uses.empty(); } 95163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool hasOneUse() const { return Uses.size() == 1; } 95263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 953b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// getNodeId - Return the unique node id. 954b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// 955b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int getNodeId() const { return NodeId; } 9560442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 9572e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng /// setNodeId - Set unique node id. 9582e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng void setNodeId(int Id) { NodeId = Id; } 9592e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng 9605892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner typedef SmallVector<SDNode*,3>::const_iterator use_iterator; 9617ece380440238ad0630a225b85a09a2dbed1165aChris Lattner use_iterator use_begin() const { return Uses.begin(); } 9627ece380440238ad0630a225b85a09a2dbed1165aChris Lattner use_iterator use_end() const { return Uses.end(); } 9637ece380440238ad0630a225b85a09a2dbed1165aChris Lattner 964b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the 965b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// indicated value. This method ignores uses of other values defined by this 966b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// operation. 9674ee621125876cc954cba5280dd9395552755a871Evan Cheng bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; 9684ee621125876cc954cba5280dd9395552755a871Evan Cheng 96933d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// hasAnyUseOfValue - Return true if there are any use of the indicated 97033d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// value. This method ignores uses of other values defined by this operation. 97133d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng bool hasAnyUseOfValue(unsigned Value) const; 97233d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng 973917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isOnlyUseOf - Return true if this node is the only use of N. 974e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 975917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOnlyUseOf(SDNode *N) const; 976b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner 977917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isOperandOf - Return true if this node is an operand of N. 978e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 979917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOperandOf(SDNode *N) const; 98080d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng 981917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isPredecessorOf - Return true if this node is a predecessor of N. This 982917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// node is either an operand of N or it can be reached by recursively 983917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// traversing up the operands. 984e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// NOTE: this is an expensive method. Use it carefully. 985917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isPredecessorOf(SDNode *N) const; 9867ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng 98763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumOperands - Return the number of values used by this operation. 98863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 989f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumOperands() const { return NumOperands; } 99063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 991c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// getConstantOperandVal - Helper method returns the integer value of a 992c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// ConstantSDNode operand. 993c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng uint64_t getConstantOperandVal(unsigned Num) const; 994c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 99563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const SDOperand &getOperand(unsigned Num) const { 996f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(Num < NumOperands && "Invalid child # of SDNode!"); 997f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return OperandList[Num]; 99863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 999c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1000f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner typedef const SDOperand* op_iterator; 1001f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_begin() const { return OperandList; } 1002f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_end() const { return OperandList+NumOperands; } 100350f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner 100463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 10050b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList getVTList() const { 10060b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList X = { ValueList, NumValues }; 10070b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner return X; 10080b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner }; 10090b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 101063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumValues - Return the number of values defined/returned by this 101163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operator. 101263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 1013f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumValues() const { return NumValues; } 101463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 101563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the type of a specified result. 101663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 101763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MVT::ValueType getValueType(unsigned ResNo) const { 1018f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(ResNo < NumValues && "Illegal result number!"); 1019f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return ValueList[ResNo]; 102063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 10219eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen 10224fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)). 10234fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// 10244fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman unsigned getValueSizeInBits(unsigned ResNo) const { 10254fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman return MVT::getSizeInBits(getValueType(ResNo)); 10264fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman } 10274fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman 1028f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner typedef const MVT::ValueType* value_iterator; 1029f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_begin() const { return ValueList; } 1030f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_end() const { return ValueList+NumValues; } 103163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 10326e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// getOperationName - Return the opcode of this operation for printing. 10336e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// 1034ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer std::string getOperationName(const SelectionDAG *G = 0) const; 1035144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng static const char* getIndexedModeName(ISD::MemIndexedMode AM); 103663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner void dump() const; 1037efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner void dump(const SelectionDAG *G) const; 103863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 103963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *) { return true; } 104063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1041583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// Profile - Gather unique data for the node. 1042583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// 1043583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey void Profile(FoldingSetNodeID &ID); 1044583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey 104563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 104663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1047109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner 1048109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// getValueTypeList - Return a pointer to the specified value type. 1049109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// 1050547ca537b638c8fd5c8f4729e4c74898f8371e4eDan Gohman static const MVT::ValueType *getValueTypeList(MVT::ValueType VT); 105163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner static SDVTList getSDVTList(MVT::ValueType VT) { 105263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner SDVTList Ret = { getValueTypeList(VT), 1 }; 105363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner return Ret; 10542d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 105563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 1056ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps) 1057b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng : NodeType(Opc), NodeId(-1) { 105863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner OperandsNeedDelete = true; 1059f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner NumOperands = NumOps; 1060bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = NumOps ? new SDOperand[NumOperands] : 0; 1061f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 1062bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner for (unsigned i = 0; i != NumOps; ++i) { 1063f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner OperandList[i] = Ops[i]; 1064bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[i].Val->Uses.push_back(this); 10650442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner } 1066bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1067ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner ValueList = VTs.VTs; 1068ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner NumValues = VTs.NumVTs; 1069b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner Prev = 0; Next = 0; 1070f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner } 1071bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDNode(unsigned Opc, SDVTList VTs) : NodeType(Opc), NodeId(-1) { 1072bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandsNeedDelete = false; // Operands set with InitOperands. 1073bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = 0; 1074bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = 0; 1075bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1076bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner ValueList = VTs.VTs; 1077bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumValues = VTs.NumVTs; 1078bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Prev = 0; Next = 0; 1079bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 1080bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1081bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// InitOperands - Initialize the operands list of this node with the 1082bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// specified values, which are part of the node (thus they don't need to be 1083bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// copied in or allocated). 1084bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner void InitOperands(SDOperand *Ops, unsigned NumOps) { 1085bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner assert(OperandList == 0 && "Operands already set!"); 1086bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = NumOps; 1087bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = Ops; 1088bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1089bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner for (unsigned i = 0; i != NumOps; ++i) 1090bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Ops[i].Val->Uses.push_back(this); 1091bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 1092bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1093d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// MorphNodeTo - This frees the operands of the current node, resets the 1094d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// opcode, types, and operands to the specified value. This should only be 1095d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// used by the SelectionDAG class. 1096d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner void MorphNodeTo(unsigned Opc, SDVTList L, 1097d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner const SDOperand *Ops, unsigned NumOps); 10981b95095857b78e12138c22e76c7936611c51355bChris Lattner 10998c3484c5181834e6b7060a6064ac769878101f23Chris Lattner void addUser(SDNode *User) { 11008c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses.push_back(User); 11011b95095857b78e12138c22e76c7936611c51355bChris Lattner } 1102d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner void removeUser(SDNode *User) { 1103d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner // Remove this user from the operand's use list. 1104d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner for (unsigned i = Uses.size(); ; --i) { 1105d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner assert(i != 0 && "Didn't find user!"); 1106d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner if (Uses[i-1] == User) { 11078c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses[i-1] = Uses.back(); 11088c3484c5181834e6b7060a6064ac769878101f23Chris Lattner Uses.pop_back(); 11098c3484c5181834e6b7060a6064ac769878101f23Chris Lattner return; 1110d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 1111d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 1112d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 111363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 111463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 111563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 111663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner// Define inline functions from the SDOperand class. 111763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 111863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getOpcode() const { 111963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getOpcode(); 112063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 112163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline MVT::ValueType SDOperand::getValueType() const { 112263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getValueType(ResNo); 112363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 112463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline unsigned SDOperand::getNumOperands() const { 112563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getNumOperands(); 112663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 112763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerinline const SDOperand &SDOperand::getOperand(unsigned i) const { 112863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getOperand(i); 112963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1130c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chenginline uint64_t SDOperand::getConstantOperandVal(unsigned i) const { 1131c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng return Val->getConstantOperandVal(i); 1132c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 11330f66a9172175aa7c3055333358170581c999219bNate Begemaninline bool SDOperand::isTargetOpcode() const { 11340f66a9172175aa7c3055333358170581c999219bNate Begeman return Val->isTargetOpcode(); 11350f66a9172175aa7c3055333358170581c999219bNate Begeman} 11360f66a9172175aa7c3055333358170581c999219bNate Begemaninline unsigned SDOperand::getTargetOpcode() const { 11370f66a9172175aa7c3055333358170581c999219bNate Begeman return Val->getTargetOpcode(); 11380f66a9172175aa7c3055333358170581c999219bNate Begeman} 1139a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattnerinline bool SDOperand::hasOneUse() const { 1140a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner return Val->hasNUsesOfValue(1, ResNo); 1141a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner} 1142e1b50639a860934685dff840e1826b16dbe6a344Dan Gohmaninline bool SDOperand::use_empty() const { 1143e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman return !Val->hasAnyUseOfValue(ResNo); 1144e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman} 114563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 11463f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes. This is solely 11473f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 11483f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode { 11493f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 11503f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Op; 11513f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 11523f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X) 11533f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs), Op(X) { 11543f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(&Op, 1); 11553f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 11563f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 11573f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 11583f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes. This is solely 11593f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 11603f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode { 11613f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 11623f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Ops[2]; 11633f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 11643f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y) 11653f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 11663f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 11673f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 11683f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 2); 11693f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 11703f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 11713f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 11723f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely 11733f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 11743f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode { 11753f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 11763f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Ops[3]; 11773f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 11783f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y, 11793f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Z) 11803f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 11813f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 11823f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 11833f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[2] = Z; 11843f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 3); 11853f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 11863f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 11873f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 11883f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 1189d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that 1190d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its 1191d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand. This node should be directly created by end-users and not added to 1192d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list. 1193d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode { 1194c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1195bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDOperand Op; 1196d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic: 1197423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit HandleSDNode(SDOperand X) 1198bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)), Op(X) { 1199bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner InitOperands(&Op, 1); 1200bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 120148b85926524f9d29ae600123c90194cd73fd629eChris Lattner ~HandleSDNode(); 1202bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner SDOperand getValue() const { return Op; } 1203d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner}; 1204d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner 1205ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharthclass AtomicSDNode : public SDNode { 1206ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1207ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth SDOperand Ops[4]; 1208ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth MVT::ValueType OrigVT; 1209ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharthpublic: 1210c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, 1211c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth SDOperand Cmp, SDOperand Swp, MVT::ValueType VT) 1212ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth : SDNode(Opc, VTL) { 1213ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth Ops[0] = Chain; 1214c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[1] = Ptr; 1215c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[2] = Swp; 1216c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[3] = Cmp; 1217ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth InitOperands(Ops, 4); 1218ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth OrigVT=VT; 1219ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth } 1220c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, 1221c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth SDOperand Val, MVT::ValueType VT) 1222ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth : SDNode(Opc, VTL) { 1223ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth Ops[0] = Chain; 1224c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[1] = Ptr; 1225c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[2] = Val; 1226ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth InitOperands(Ops, 3); 1227ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth OrigVT=VT; 1228ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth } 1229ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth MVT::ValueType getVT() const { return OrigVT; } 1230c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth bool isCompareAndSwap() const { return getOpcode() == ISD::ATOMIC_LCS; } 1231ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth}; 1232ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 123347725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerclass StringSDNode : public SDNode { 123447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner std::string Value; 1235c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 123647725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerprotected: 123747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner friend class SelectionDAG; 1238423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit StringSDNode(const std::string &val) 1239bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) { 124047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner } 124147725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerpublic: 124247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner const std::string &getValue() const { return Value; } 124347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner static bool classof(const StringSDNode *) { return true; } 124447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner static bool classof(const SDNode *N) { 124547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner return N->getOpcode() == ISD::STRING; 124647725d059b259f8a0c145478300c9e9caa006b59Chris Lattner } 124747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner}; 124863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 124963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode { 12506394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman APInt Value; 1251c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 125263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 125363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 12546394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman ConstantSDNode(bool isTarget, const APInt &val, MVT::ValueType VT) 1255bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)), 1256bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Value(val) { 125763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 125863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 125963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 12606394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman const APInt &getAPIntValue() const { return Value; } 12616394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman uint64_t getValue() const { return Value.getZExtValue(); } 126263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 126363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int64_t getSignExtended() const { 126463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Bits = MVT::getSizeInBits(getValueType(0)); 12656394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman return ((int64_t)Value.getZExtValue() << (64-Bits)) >> (64-Bits); 126663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 126763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 126863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool isNullValue() const { return Value == 0; } 126963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool isAllOnesValue() const { 1270885a87ef8512a184a58a0ebe39705ccb221749efChris Lattner return Value == MVT::getIntVTBitMask(getValueType(0)); 127163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 127263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 127363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantSDNode *) { return true; } 127463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1275056f9f61d071c6c583951678f2bf543a1316efccChris Lattner return N->getOpcode() == ISD::Constant || 1276056f9f61d071c6c583951678f2bf543a1316efccChris Lattner N->getOpcode() == ISD::TargetConstant; 127763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 127863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 127963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 128063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode { 12818bb369b8072c919ef5802f639a52b17620201190Dale Johannesen APFloat Value; 1282c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 128363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 128463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1285e6c1742914149d44360fbf05a653041a672282afDale Johannesen ConstantFPSDNode(bool isTarget, const APFloat& val, MVT::ValueType VT) 128687503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 128787503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen getSDVTList(VT)), Value(val) { 128863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 128963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 129063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1291e6c1742914149d44360fbf05a653041a672282afDale Johannesen const APFloat& getValueAPF() const { return Value; } 129263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 129363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isExactlyValue - We don't rely on operator== working on double values, as 129463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 129563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// As such, this method can be used to do an exact bit-for-bit comparison of 129663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// two floating point values. 1297c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen 1298c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// We leave the version with the double argument here because it's just so 1299c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// convenient to write "2.0" and the like. Without this function we'd 1300c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// have to duplicate its logic everywhere it's called. 130187503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen bool isExactlyValue(double V) const { 130284cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner APFloat Tmp(V); 130384cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven); 130484cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner return isExactlyValue(Tmp); 130587503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen } 1306e6c1742914149d44360fbf05a653041a672282afDale Johannesen bool isExactlyValue(const APFloat& V) const; 130763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1308f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen bool isValueValidForType(MVT::ValueType VT, const APFloat& Val); 1309f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen 131063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantFPSDNode *) { return true; } 131163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1312ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner return N->getOpcode() == ISD::ConstantFP || 1313ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner N->getOpcode() == ISD::TargetConstantFP; 131463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 131563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 131663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 131763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode { 131863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *TheGlobal; 1319404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int Offset; 1320c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 132163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 132263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 132361ca74bc3a29b2af2be7e4bd612289da8aae85b5Evan Cheng GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT::ValueType VT, 13242c5c111b6c144b05718404c85b9dfcc76b1619e7Lauro Ramos Venancio int o = 0); 132563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 132663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 132763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *getGlobal() const { return TheGlobal; } 1328404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int getOffset() const { return Offset; } 132963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 133063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const GlobalAddressSDNode *) { return true; } 133163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1332f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner return N->getOpcode() == ISD::GlobalAddress || 1333b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalAddress || 1334b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::GlobalTLSAddress || 1335b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalTLSAddress; 133663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 133763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 133863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 133963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode { 134063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int FI; 1341c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 134263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 134363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1344afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner FrameIndexSDNode(int fi, MVT::ValueType VT, bool isTarg) 1345bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)), 1346bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner FI(fi) { 134763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 134863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 134963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 135063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int getIndex() const { return FI; } 135163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 135263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const FrameIndexSDNode *) { return true; } 135363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1354afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner return N->getOpcode() == ISD::FrameIndex || 1355afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner N->getOpcode() == ISD::TargetFrameIndex; 135663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 135763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 135863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 135937efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode { 136037efe6764568a3829fee26aba532283131d1a104Nate Begeman int JTI; 1361c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 136237efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected: 136337efe6764568a3829fee26aba532283131d1a104Nate Begeman friend class SelectionDAG; 136437efe6764568a3829fee26aba532283131d1a104Nate Begeman JumpTableSDNode(int jti, MVT::ValueType VT, bool isTarg) 1365bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)), 1366bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner JTI(jti) { 136763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 136837efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic: 136937efe6764568a3829fee26aba532283131d1a104Nate Begeman 137059a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner int getIndex() const { return JTI; } 137137efe6764568a3829fee26aba532283131d1a104Nate Begeman 137237efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const JumpTableSDNode *) { return true; } 137337efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const SDNode *N) { 137437efe6764568a3829fee26aba532283131d1a104Nate Begeman return N->getOpcode() == ISD::JumpTable || 137537efe6764568a3829fee26aba532283131d1a104Nate Begeman N->getOpcode() == ISD::TargetJumpTable; 137637efe6764568a3829fee26aba532283131d1a104Nate Begeman } 137737efe6764568a3829fee26aba532283131d1a104Nate Begeman}; 137837efe6764568a3829fee26aba532283131d1a104Nate Begeman 137963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode { 1380d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng union { 1381d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *ConstVal; 1382d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *MachineCPVal; 1383d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } Val; 1384baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int Offset; // It's a MachineConstantPoolValue if top bit is set. 1385b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned Alignment; 1386c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 138763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 138863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1389404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, 1390404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int o=0) 1391ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1392bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1393d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1394d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1395d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1396404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng ConstantPoolSDNode(bool isTarget, Constant *c, MVT::ValueType VT, int o, 1397404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng unsigned Align) 1398ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1399bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1400d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1401d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1402d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1403d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1404d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MVT::ValueType VT, int o=0) 1405ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1406bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1407d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1408d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1409d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1410d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1411d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1412d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MVT::ValueType VT, int o, unsigned Align) 1413ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1414bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1415d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1416d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1417d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1418d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 141963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 142063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1421d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng bool isMachineConstantPoolEntry() const { 1422d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return (int)Offset < 0; 1423d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1424d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1425d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *getConstVal() const { 1426d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1427d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.ConstVal; 1428d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1429d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1430d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *getMachineCPVal() const { 1431d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1432d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.MachineCPVal; 1433d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1434d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1435baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int getOffset() const { 1436baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng return Offset & ~(1 << (sizeof(unsigned)*8-1)); 1437baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng } 1438ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner 1439ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // Return the alignment of this constant pool object, which is either 0 (for 1440ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // default alignment) or log2 of the desired value. 1441b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned getAlignment() const { return Alignment; } 144263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1443d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng const Type *getType() const; 1444d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 144563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantPoolSDNode *) { return true; } 144663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1447aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner return N->getOpcode() == ISD::ConstantPool || 1448aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner N->getOpcode() == ISD::TargetConstantPool; 144963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 145063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 145163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 145263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode { 145363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *MBB; 1454c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 145563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 145663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1457423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit BasicBlockSDNode(MachineBasicBlock *mbb) 1458bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) { 145963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 146063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 146163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 146263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *getBasicBlock() const { return MBB; } 146363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 146463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const BasicBlockSDNode *) { return true; } 146563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 146663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return N->getOpcode() == ISD::BasicBlock; 146763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 146863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 146963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 147014471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is 147114471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// used when the SelectionDAG needs to make a simple reference to something 147214471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// in the LLVM IR representation. 147314471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 147414471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// Note that this is not used for carrying alias information; that is done 147514471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// with MemOperandSDNode, which includes a Value which is required to be a 147614471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// pointer, and several other fields specific to memory references. 147714471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 14782d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode { 14792d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *V; 1480c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 14812d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected: 14822d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth friend class SelectionDAG; 148369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// Create a SrcValue for a general value. 148469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman explicit SrcValueSDNode(const Value *v) 148569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {} 14862d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 14872d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic: 148869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// getValue - return the contained Value. 14892d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *getValue() const { return V; } 14902d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 14912d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SrcValueSDNode *) { return true; } 14922d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SDNode *N) { 14932d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth return N->getOpcode() == ISD::SRCVALUE; 14942d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 14952d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth}; 14962d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 149763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 149869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// MemOperandSDNode - An SDNode that holds a MemOperand. This is 149969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// used to represent a reference to memory after ISD::LOAD 150069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// and ISD::STORE have been lowered. 150169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// 150269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanclass MemOperandSDNode : public SDNode { 150369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 150469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanprotected: 150569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman friend class SelectionDAG; 150669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// Create a MemOperand node 1507f8df0ff9a5d1be41ca237bcd40ced821839b32faDan Gohman explicit MemOperandSDNode(const MemOperand &mo) 150869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {} 150969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 151069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanpublic: 151169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// MO - The contained MemOperand. 151269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman const MemOperand MO; 151369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 151469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const MemOperandSDNode *) { return true; } 151569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const SDNode *N) { 151669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman return N->getOpcode() == ISD::MEMOPERAND; 151769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman } 151869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman}; 151969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 152069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 1521d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode { 152263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Reg; 1523c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 152463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 152563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1526d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner RegisterSDNode(unsigned reg, MVT::ValueType VT) 1527bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) { 152863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 152963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 153063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 153163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getReg() const { return Reg; } 153263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1533d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner static bool classof(const RegisterSDNode *) { return true; } 153463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1535d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner return N->getOpcode() == ISD::Register; 153663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 153763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 153863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 153963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ExternalSymbolSDNode : public SDNode { 154063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *Symbol; 1541c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 154263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 154363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 15442a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT::ValueType VT) 1545ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 1546bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Symbol(Sym) { 154763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 154863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 154963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 155063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *getSymbol() const { return Symbol; } 155163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 155263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ExternalSymbolSDNode *) { return true; } 155363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 15542a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth return N->getOpcode() == ISD::ExternalSymbol || 15552a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth N->getOpcode() == ISD::TargetExternalSymbol; 155663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 155763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 155863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 15597cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode { 156063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ISD::CondCode Condition; 1561c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 156263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 156363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1564423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit CondCodeSDNode(ISD::CondCode Cond) 1565bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) { 156663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 156763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 156863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 15697cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner ISD::CondCode get() const { return Condition; } 157063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 15717cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner static bool classof(const CondCodeSDNode *) { return true; } 157263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 15737cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner return N->getOpcode() == ISD::CONDCODE; 157463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 157563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 157663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 157715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// VTSDNode - This class is used to represent MVT::ValueType's, which are used 157815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations. 157915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode { 158015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner MVT::ValueType ValueType; 1581c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 158215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected: 158315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner friend class SelectionDAG; 1584423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit VTSDNode(MVT::ValueType VT) 1585bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) { 158663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 158715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic: 158815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 158915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner MVT::ValueType getVT() const { return ValueType; } 159015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 159115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const VTSDNode *) { return true; } 159215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const SDNode *N) { 159315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner return N->getOpcode() == ISD::VALUETYPE; 159415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner } 159515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner}; 159615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 15979de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode 15989de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// 15999de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LSBaseSDNode : public SDNode { 16009de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprivate: 1601b625f2f8960de32bc973092aaee8ac62863006feDan Gohman // AddrMode - unindexed, pre-indexed, post-indexed. 1602b625f2f8960de32bc973092aaee8ac62863006feDan Gohman ISD::MemIndexedMode AddrMode; 1603b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1604b625f2f8960de32bc973092aaee8ac62863006feDan Gohman // MemoryVT - VT of in-memory value. 1605b625f2f8960de32bc973092aaee8ac62863006feDan Gohman MVT::ValueType MemoryVT; 1606b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 16079de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! SrcValue - Memory location for alias analysis. 16089de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const Value *SrcValue; 16099de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 16109de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! SVOffset - Memory location offset. 16119de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel int SVOffset; 16129de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 16139de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Alignment - Alignment of memory location in bytes. 16149de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel unsigned Alignment; 16159de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 16169de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! IsVolatile - True if the store is volatile. 16179de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel bool IsVolatile; 16189de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprotected: 16199de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Operand array for load and store 16209de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel /*! 16219de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel \note Moving this array to the base class captures more 16229de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel common functionality shared between LoadSDNode and 16239de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel StoreSDNode 16249de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel */ 16259de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel SDOperand Ops[4]; 16269de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic: 1627b625f2f8960de32bc973092aaee8ac62863006feDan Gohman LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned NumOperands, 1628b625f2f8960de32bc973092aaee8ac62863006feDan Gohman SDVTList VTs, ISD::MemIndexedMode AM, MVT::ValueType VT, 1629b625f2f8960de32bc973092aaee8ac62863006feDan Gohman const Value *SV, int SVO, unsigned Align, bool Vol) 16309de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel : SDNode(NodeTy, VTs), 1631b625f2f8960de32bc973092aaee8ac62863006feDan Gohman AddrMode(AM), MemoryVT(VT), 163259a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner SrcValue(SV), SVOffset(SVO), Alignment(Align), IsVolatile(Vol) { 1633b625f2f8960de32bc973092aaee8ac62863006feDan Gohman for (unsigned i = 0; i != NumOperands; ++i) 1634b625f2f8960de32bc973092aaee8ac62863006feDan Gohman Ops[i] = Operands[i]; 1635b625f2f8960de32bc973092aaee8ac62863006feDan Gohman InitOperands(Ops, NumOperands); 1636b625f2f8960de32bc973092aaee8ac62863006feDan Gohman assert(Align != 0 && "Loads and stores should have non-zero aligment"); 1637437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) && 1638437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman "Only indexed loads and stores have a non-undef offset operand"); 1639b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 16409de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 164159a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getChain() const { return getOperand(0); } 164259a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getBasePtr() const { 16439de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel return getOperand(getOpcode() == ISD::LOAD ? 1 : 2); 16449de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel } 164563602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner const SDOperand &getOffset() const { 164663602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); 164763602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner } 16489de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 16499de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const Value *getSrcValue() const { return SrcValue; } 16509de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel int getSrcValueOffset() const { return SVOffset; } 16519de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel unsigned getAlignment() const { return Alignment; } 1652b625f2f8960de32bc973092aaee8ac62863006feDan Gohman MVT::ValueType getMemoryVT() const { return MemoryVT; } 16539de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel bool isVolatile() const { return IsVolatile; } 16549de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 1655b625f2f8960de32bc973092aaee8ac62863006feDan Gohman ISD::MemIndexedMode getAddressingMode() const { return AddrMode; } 1656b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1657b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isIndexed - Return true if this is a pre/post inc/dec load/store. 1658b625f2f8960de32bc973092aaee8ac62863006feDan Gohman bool isIndexed() const { return AddrMode != ISD::UNINDEXED; } 1659b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1660b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. 1661b625f2f8960de32bc973092aaee8ac62863006feDan Gohman bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; } 1662b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 166369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// getMemOperand - Return a MemOperand object describing the memory 166469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// reference performed by this load or store. 166569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman MemOperand getMemOperand() const; 166669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 16679de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel static bool classof(const LSBaseSDNode *N) { return true; } 1668b625f2f8960de32bc973092aaee8ac62863006feDan Gohman static bool classof(const SDNode *N) { 1669b625f2f8960de32bc973092aaee8ac62863006feDan Gohman return N->getOpcode() == ISD::LOAD || 1670b625f2f8960de32bc973092aaee8ac62863006feDan Gohman N->getOpcode() == ISD::STORE; 1671b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 16729de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel}; 16739de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 167424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes. 167524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 16769de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode { 1677c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1678bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 167981c384578828dde08f63a4f030f4860a92391cddEvan Cheng // ExtType - non-ext, anyext, sext, zext. 168081c384578828dde08f63a4f030f4860a92391cddEvan Cheng ISD::LoadExtType ExtType; 168181c384578828dde08f63a4f030f4860a92391cddEvan Cheng 168224446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 168324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 1684ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs, 1685144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT::ValueType LVT, 168695c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 1687b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3, 1688b625f2f8960de32bc973092aaee8ac62863006feDan Gohman VTs, AM, LVT, SV, O, Align, Vol), 1689437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman ExtType(ETy) {} 169024446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 169124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 169224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng ISD::LoadExtType getExtensionType() const { return ExtType; } 169359a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getBasePtr() const { return getOperand(1); } 169459a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getOffset() const { return getOperand(2); } 169539354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 169624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const LoadSDNode *) { return true; } 169724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 169824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD; 169924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 170024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 170124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 170224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes. 170324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 17049de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode { 1705c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1706bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 17073ec81c0ee73462b7b9acd355b0013827d06ad93cDuncan Sands // IsTruncStore - True if the op does a truncation before store. 170881c384578828dde08f63a4f030f4860a92391cddEvan Cheng bool IsTruncStore; 170924446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 171024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 1711ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs, 1712144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng ISD::MemIndexedMode AM, bool isTrunc, MVT::ValueType SVT, 171324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 1714b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4, 1715b625f2f8960de32bc973092aaee8ac62863006feDan Gohman VTs, AM, SVT, SV, O, Align, Vol), 1716437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman IsTruncStore(isTrunc) {} 171724446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 171824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 171924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng bool isTruncatingStore() const { return IsTruncStore; } 172059a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getValue() const { return getOperand(1); } 172159a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getBasePtr() const { return getOperand(2); } 172259a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getOffset() const { return getOperand(3); } 172339354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 17246d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng static bool classof(const StoreSDNode *) { return true; } 172524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 172624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::STORE; 172724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 172824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 172924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 173015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 17311080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { 17321080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNode *Node; 17331080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned Operand; 1734ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 17351080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 17361080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic: 17371080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator==(const SDNodeIterator& x) const { 17381080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Operand == x.Operand; 17391080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 17401080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 17411080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 17421080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNodeIterator &operator=(const SDNodeIterator &I) { 17431080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 17441080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner Operand = I.Operand; 17451080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 17461080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 1747ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 17481080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator*() const { 17491080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Node->getOperand(Operand).Val; 17501080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 17511080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator->() const { return operator*(); } 1752ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 17531080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator& operator++() { // Preincrement 17541080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner ++Operand; 17551080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 17561080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 17571080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator operator++(int) { // Postincrement 1758ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SDNodeIterator tmp = *this; ++*this; return tmp; 17591080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 17601080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 17611080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 17621080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator end (SDNode *N) { 17631080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator(N, N->getNumOperands()); 17641080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 17651080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 17661080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned getOperand() const { return Operand; } 17671080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNode *getNode() const { return Node; } 17681080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 17691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 17701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> { 17711080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNode NodeType; 17721080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNodeIterator ChildIteratorType; 17731080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static inline NodeType *getEntryNode(SDNode *N) { return N; } 1774ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_begin(NodeType *N) { 17751080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::begin(N); 17761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 1777ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_end(NodeType *N) { 17781080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::end(N); 17791080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 17801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 17811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 1782b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<> 1783b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnerstruct ilist_traits<SDNode> { 1784b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *getPrev(const SDNode *N) { return N->Prev; } 1785b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *getNext(const SDNode *N) { return N->Next; } 1786b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1787b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; } 1788b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; } 1789b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1790b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *createSentinel() { 1791bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other)); 1792b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 1793b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void destroySentinel(SDNode *N) { delete N; } 1794b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner //static SDNode *createNode(const SDNode &V) { return new SDNode(V); } 1795b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1796b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1797b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void addNodeToList(SDNode *NTy) {} 1798b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void removeNodeFromList(SDNode *NTy) {} 1799b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner void transferNodesFromList(iplist<SDNode, ilist_traits> &L2, 1800b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner const ilist_iterator<SDNode> &X, 1801b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner const ilist_iterator<SDNode> &Y) {} 1802b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner}; 1803b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1804c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD { 1805186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// isNormalLoad - Returns true if the specified node is a non-extending 1806186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// and unindexed load. 1807186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng inline bool isNormalLoad(const SDNode *N) { 1808186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng if (N->getOpcode() != ISD::LOAD) 1809186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng return false; 1810186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng const LoadSDNode *Ld = cast<LoadSDNode>(N); 1811186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng return Ld->getExtensionType() == ISD::NON_EXTLOAD && 1812186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng Ld->getAddressingMode() == ISD::UNINDEXED; 1813186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng } 1814186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng 181524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// isNON_EXTLoad - Returns true if the specified node is a non-extending 181624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// load. 181724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng inline bool isNON_EXTLoad(const SDNode *N) { 181824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 181924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 182024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 182124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 1822c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 1823c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1824c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isEXTLoad(const SDNode *N) { 182524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 182624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 1827c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 1828c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1829c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 1830c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1831c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isSEXTLoad(const SDNode *N) { 183224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 183324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 1834c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 1835c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1836c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 1837c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 1838c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isZEXTLoad(const SDNode *N) { 183924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD && 184024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 1841c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 18428b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 184302c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// isUNINDEXEDLoad - Returns true if the specified node is a unindexed load. 184402c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// 184502c50e4891841c28b2a743731dfc60744bb78879Evan Cheng inline bool isUNINDEXEDLoad(const SDNode *N) { 184602c50e4891841c28b2a743731dfc60744bb78879Evan Cheng return N->getOpcode() == ISD::LOAD && 184702c50e4891841c28b2a743731dfc60744bb78879Evan Cheng cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 184802c50e4891841c28b2a743731dfc60744bb78879Evan Cheng } 184902c50e4891841c28b2a743731dfc60744bb78879Evan Cheng 18508b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 18518b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 18528b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isNON_TRUNCStore(const SDNode *N) { 18538b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng return N->getOpcode() == ISD::STORE && 18548b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng !cast<StoreSDNode>(N)->isTruncatingStore(); 18558b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 18568b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 18578b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isTRUNCStore - Returns true if the specified node is a truncating 18588b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 18598b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isTRUNCStore(const SDNode *N) { 18608b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng return N->getOpcode() == ISD::STORE && 18618b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng cast<StoreSDNode>(N)->isTruncatingStore(); 18628b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 1863c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 1864c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1865c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 186663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace 186763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 186863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif 1869