SelectionDAGNodes.h revision c8f88cc8c0b4ce1664520d5390c623f2c44e4555
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" 2543d1fd449f1a0ac9d9dafa0b9569bb6b2e976198Anton Korobeynikov#include "llvm/ADT/iterator.h" 268bb369b8072c919ef5802f639a52b17620201190Dale Johannesen#include "llvm/ADT/APFloat.h" 276394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman#include "llvm/ADT/APInt.h" 28d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h" 2936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman#include "llvm/CodeGen/MachineMemOperand.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 { 5183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *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 6063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 6163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::NodeType enum - This enum defines all of the operators valid in a 6263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SelectionDAG. 6363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 6463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum NodeType { 653258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // DELETED_NODE - This is an illegal flag value that is used to catch 663258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // errors. This opcode is not a legal opcode for any node. 673258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner DELETED_NODE, 683258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner 698a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // EntryToken - This is the marker used to indicate the start of the region. 708a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner EntryToken, 718a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner 728c4bde36a339b1c538002e819daff84caae4cbadReid Spencer // Token factor - This node takes multiple tokens as input and produces a 738a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // single token result. This is used to represent the fact that the operand 748a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // operators are independent of each other. 758a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner TokenFactor, 76f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman 77f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // AssertSext, AssertZext - These nodes record if a register contains a 78f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // value that has already been zero or sign extended from a narrower type. 79f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // These nodes take two operands. The first is the node that has already 80f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // been extended, and the second is a value type node indicating the width 81f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // of the extension 82f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman AssertSext, AssertZext, 83ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 848a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // Various leaf nodes. 85276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands STRING, BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register, 861ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng Constant, ConstantFP, 87b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio GlobalAddress, GlobalTLSAddress, FrameIndex, 88b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio JumpTable, ConstantPool, ExternalSymbol, 891ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng 9082c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth // The address of the GOT 9182c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth GLOBAL_OFFSET_TABLE, 92bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman 93bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and 94bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // llvm.returnaddress on the DAG. These nodes take one operand, the index 95bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // of the frame or return address to return. An index of zero corresponds 96bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // to the current function's frame or return address, an index of one to the 97bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // parent's frame or return address, and so on. 98bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman FRAMEADDR, RETURNADDR, 992365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 1002365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to 1012365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // first (possible) on-stack argument. This is needed for correct stack 1022365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // adjustment during unwind. 1032365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov FRAME_TO_ARGS_OFFSET, 104f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 105f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the 106f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // address of the exception block on entry to an landing pad block. 107f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EXCEPTIONADDR, 108f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 109f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents 110f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // the selection index of the exception thrown. 111f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EHSELECTION, 112beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth 1132365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 1142365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // 'eh_return' gcc dwarf builtin, which is used to return from 1152365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // exception. The general meaning is: adjust stack by OFFSET and pass 1162365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // execution to HANDLER. Many platform-related details also :) 1172365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov EH_RETURN, 1182365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 119ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // TargetConstant* - Like Constant*, but the DAG does not do any folding or 120ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // simplification of the constant. 121056f9f61d071c6c583951678f2bf543a1316efccChris Lattner TargetConstant, 122ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner TargetConstantFP, 123f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner 124f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or 125f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // anything else with this node, and this is valid in the target-specific 126f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // dag, turning into a GlobalAddress operand. 127f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner TargetGlobalAddress, 128b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio TargetGlobalTLSAddress, 129afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner TargetFrameIndex, 13037efe6764568a3829fee26aba532283131d1a104Nate Begeman TargetJumpTable, 131aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner TargetConstantPool, 1322a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth TargetExternalSymbol, 13372601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner 134ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) 135ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with no side effects. 136ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// The first operand is the ID number of the intrinsic from the 137ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The 138ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// node has returns the result of the intrinsic. 139ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_WO_CHAIN, 140ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 141ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) 142ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 143ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// returns a result. The first operand is a chain pointer. The second is 144ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The 145ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// operands to the intrinsic follow. The node has two results, the result 146ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// of the intrinsic and an output chain. 147ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_W_CHAIN, 14863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 149ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) 150ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 151ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// does not return a result. The first operand is a chain pointer. The 152ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// second is the ID number of the intrinsic from the llvm::Intrinsic 153ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// namespace. The operands to the intrinsic follow. 154ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_VOID, 155ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 156d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // CopyToReg - This node has three operands: a chain, a register number to 157d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // set to this value, and a value. 15863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyToReg, 15963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 16063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // CopyFromReg - This node indicates that the input value is a virtual or 16163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // physical register that is defined outside of the scope of this 162ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman // SelectionDAG. The register is available from the RegisterSDNode object. 16363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyFromReg, 16463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 165fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman // UNDEF - An undefined node 166fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman UNDEF, 167681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner 168b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node 169b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// represents the formal arguments for a function. CC# is a Constant value 170b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// indicating the calling convention of the function, and ISVARARG is a 171b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// flag that indicates whether the function is varargs or not. This node 172b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// has one result value for each incoming argument, plus one for the output 173b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// chain. It must be custom legalized. See description of CALL node for 174b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FLAG argument contents explanation. 175c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner /// 176681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner FORMAL_ARGUMENTS, 1776c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner 1786c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CC#, ISVARARG, ISTAILCALL, CALLEE, 179b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn) 1806c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// This node represents a fully general function call, before the legalizer 181b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// runs. This has one result value for each argument / flag pair, plus 182b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// a chain result. It must be custom legalized. Flag argument indicates 183b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// misc. argument attributes. Currently: 184b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 0 - signness 185b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 1 - 'inreg' attribute 186b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 2 - 'sret' attribute 187594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 4 - 'byval' attribute 188594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 5 - 'nest' attribute 189594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 6-9 - alignment of byval structures 190594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 10-26 - size of byval structures 19113a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// Bits 31:27 - argument ABI alignment in the first argument piece and 19213a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// alignment '1' in other argument pieces. 1936c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner CALL, 194fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman 19525eb043759c23b61769108f78382eb9701c41db2Duncan Sands // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by 19625eb043759c23b61769108f78382eb9701c41db2Duncan Sands // a Constant, which is required to be operand #1) half of the integer value 19725eb043759c23b61769108f78382eb9701c41db2Duncan Sands // specified as operand #0. This is only for use before legalization, for 19825eb043759c23b61769108f78382eb9701c41db2Duncan Sands // values that will be broken into multiple registers. 19963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner EXTRACT_ELEMENT, 20063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 20163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given 20263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // two values of the same integer value type, this produces a value twice as 20363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // big. Like EXTRACT_ELEMENT, this can only be used before legalization. 20463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BUILD_PAIR, 205006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner 206006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // MERGE_VALUES - This node takes multiple discrete operands and returns 207006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // them all as its individual results. This nodes has exactly the same 208006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // number of inputs and outputs, and is only valid before legalization. 209006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // This node is useful for some pieces of the code generator that want to 210006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // think about a single node with multiple results, not multiple nodes. 211006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner MERGE_VALUES, 21263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 213615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple integer binary arithmetic operators. 214bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, 215fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 216fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing 217b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // a signed/unsigned value of type i[2*N], and return the full value as 218fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // two results, each of type iN. 219fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SMUL_LOHI, UMUL_LOHI, 220fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 221fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and 222fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // remainder result. 223fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SDIVREM, UDIVREM, 224615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner 22555e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // CARRY_FALSE - This node is used when folding other nodes, 22655e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // like ADDC/SUBC, which indicate the carry result is always false. 22755e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner CARRY_FALSE, 22855e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner 229551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-setting nodes for multiple precision addition and subtraction. 230551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // These nodes take two operands of the same value type, and produce two 231551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // results. The first result is the normal add or sub result, the second 232551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // result is the carry flag result. 233551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDC, SUBC, 234551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 235551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-using nodes for multiple precision addition and subtraction. These 236551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // nodes take three operands: The first two are the normal lhs and rhs to 237551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // the add or sub, and the third is the input carry flag. These nodes 238551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // produce two results; the normal result of the add or sub, and the output 239551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // carry flag. These nodes both read and write a carry flag to allow them 240551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // to them to be chained together for add and sub of arbitrarily large 241551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // values. 242551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDE, SUBE, 243551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 244615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple binary floating point operators. 245615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner FADD, FSUB, FMUL, FDIV, FREM, 24638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 24738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This 24838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // DAG node does not require that X and Y have the same type, just that they 24938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // are both floating point. X and the result must have the same type. 25038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(f32, f64) is allowed. 25138bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner FCOPYSIGN, 252fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner 2531a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point 2541a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // value as an integer 0/1 value. 2551a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner FGETSIGN, 2561a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner 257664e9546d674096c5a012536f1a424b1681ece51Dan Gohman /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector 25822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// with the specified, possibly variable, elements. The number of elements 25922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// is required to be a power of two. 26022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner BUILD_VECTOR, 26122232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2627f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element 2634f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// at IDX replaced with VAL. If the type of VAL is larger than the vector 2644f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// element type then VAL is truncated before replacement. 26522232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner INSERT_VECTOR_ELT, 2664b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner 2674b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR 2687f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// identified by the (potentially variable) element number IDX. 2694b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner EXTRACT_VECTOR_ELT, 27022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2717f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of 2727f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector type with the same length and element type, this produces a 2737f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// concatenated vector result value, with length equal to the sum of the 274b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman /// lengths of the input vectors. 2757f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman CONCAT_VECTORS, 2766595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman 2777f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an 2787f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector value) starting with the (potentially variable) element number 2797f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// IDX, which must be a multiple of the result vector length. 2807f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman EXTRACT_SUBVECTOR, 28159c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 28249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same 28349c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values 28459c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// (maybe of an illegal datatype) or undef that indicate which value each 28559c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// result element will get. The elements of VEC1/VEC2 are enumerated in 28659c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// order. This is quite similar to the Altivec 'vperm' instruction, except 28759c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// that the indices must be constants and are in terms of the element size 28859c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// of VEC1/VEC2, not in terms of bytes. 28949c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner VECTOR_SHUFFLE, 29059c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 291210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a 292a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// scalar value into element 0 of the resultant vector type. The top 293a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// elements 1 to N-1 of the N-element vector are undefined. 294210721aecc0916315f61660dc387a96b89ec423bChris Lattner SCALAR_TO_VECTOR, 295210721aecc0916315f61660dc387a96b89ec423bChris Lattner 296557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // EXTRACT_SUBREG - This node is used to extract a sub-register value. 297557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg and a constant sub-register index as operands. 298709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // Note sub-register indices must be increasing. That is, if the 299709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // sub-register index of a 8-bit sub-register is N, then the index for a 300709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // 16-bit sub-register must be at least N+1. 301557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb EXTRACT_SUBREG, 302557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 3034499e495eabe8de7d595416a03c56af4688df507Evan Cheng // INSERT_SUBREG - This node is used to insert a sub-register value. 304557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg, a subreg value, and a constant sub-register 3054499e495eabe8de7d595416a03c56af4688df507Evan Cheng // index as operands. 306557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb INSERT_SUBREG, 307557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 308bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing 309b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // an unsigned/signed value of type i[2*N], then return the top part. 310bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner MULHU, MULHS, 31163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 31235ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // Bitwise operators - logical and, logical or, logical xor, shift left, 31335ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // shift right algebraic (shift in sign bits), shift right logical (shift in 31435ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // zeroes), rotate left, rotate right, and byteswap. 31535ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP, 31663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 317691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth // Counting operators 318691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth CTTZ, CTLZ, CTPOP, 319691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth 320fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner // Select(COND, TRUEVAL, FALSEVAL) 3219373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT, 3229373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman 3239373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // Select with condition operator - This selects between a true value and 3249373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // a false value (ops #2 and #3) based on the boolean result of comparing 3259373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // the lhs and rhs (ops #0 and #1) of a conditional expression with the 3269373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // condition code in op #4, a CondCodeSDNode. 3279373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT_CC, 32863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 32963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SetCC operator - This evaluates to a boolean (i1) true value if the 3307cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // condition is true. The operands to this are the left and right operands 3317cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // to compare (ops #0, and #1) and the condition code to compare them with 3327cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner // (op #2) as a CondCodeSDNode. 33363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETCC, 33463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 335b43e9c196542acc80c9e4643809661065710848fNate Begeman // Vector SetCC operator - This evaluates to a vector of integer elements 336b43e9c196542acc80c9e4643809661065710848fNate Begeman // with the high bit in each element set to true if the comparison is true 337b43e9c196542acc80c9e4643809661065710848fNate Begeman // and false if the comparison is false. All other bits in each element 338b43e9c196542acc80c9e4643809661065710848fNate Begeman // are undefined. The operands to this are the left and right operands 339b43e9c196542acc80c9e4643809661065710848fNate Begeman // to compare (ops #0, and #1) and the condition code to compare them with 340b43e9c196542acc80c9e4643809661065710848fNate Begeman // (op #2) as a CondCodeSDNode. 341b43e9c196542acc80c9e4643809661065710848fNate Begeman VSETCC, 342b43e9c196542acc80c9e4643809661065710848fNate Begeman 34314c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded 34414c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // integer shift operations, just like ADD/SUB_PARTS. The operation 34514c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // ordering is: 3466b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner // [Lo,Hi] = op [LoLHS,HiLHS], Amt 34714c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner SHL_PARTS, SRA_PARTS, SRL_PARTS, 34814c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner 34963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Conversion operators. These are all single input single output 35063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operations. For all of these, the result type must be strictly 35163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // wider or narrower (depending on the operation) than the source 35263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // type. 35363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 35463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SIGN_EXTEND - Used for integer types, replicating the sign bit 35563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // into new bits. 35663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SIGN_EXTEND, 35763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 35863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // ZERO_EXTEND - Used for integer types, zeroing the new bits. 35963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ZERO_EXTEND, 36063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3617e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner // ANY_EXTEND - Used for integer types. The high bits are undefined. 3627e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner ANY_EXTEND, 3637e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner 36463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // TRUNCATE - Completely drop the high bits. 36563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner TRUNCATE, 36663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3671645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign 3681645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // depends on the first letter) to floating point. 3691645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner SINT_TO_FP, 3701645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner UINT_TO_FP, 3711645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 372ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to 373ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // sign extend a small value in a large integer register (e.g. sign 374ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // extending the low 8 bits of a 32-bit register to fill the top 24 bits 37515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // with the 7th bit). The size of the smaller type is indicated by the 1th 37615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // operand, a ValueType node. 377859157daee6a4b49e99921832e1dde065167b317Chris Lattner SIGN_EXTEND_INREG, 378859157daee6a4b49e99921832e1dde065167b317Chris Lattner 3790bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned 3800bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// integer. 3811645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_SINT, 3821645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_UINT, 3831645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 3840bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type 3850bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// down to the precision of the destination VT. TRUNC is a flag, which is 3860bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// always an integer that is zero or one. If TRUNC is 0, this is a 3870bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// normal rounding, if it is 1, this FP_ROUND is known to not change the 3880bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// value of Y. 3890bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// 3900bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// The TRUNC = 1 case is used in cases where we know that the value will 3910bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// not be modified by the node, because Y is not using any of the extra 3920bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// precision of source type. This allows certain transformations like 3930bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for 3940bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed. 39563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_ROUND, 3960bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner 3971a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman // FLT_ROUNDS_ - Returns current rounding mode: 398917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // -1 Undefined 399917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 0 Round to 0 400917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 1 Round to nearest 401917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 2 Round to +inf 402917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 3 Round to -inf 4031a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman FLT_ROUNDS_, 404917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov 4050bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and 4060bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// rounds it to a floating point value. It then promotes it and returns it 4070bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// in a register of the same size. This operation effectively just 4080bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// discards excess precision. The type to round down to is specified by 4090bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// the VT operand, a VTSDNode. 410859157daee6a4b49e99921832e1dde065167b317Chris Lattner FP_ROUND_INREG, 411859157daee6a4b49e99921832e1dde065167b317Chris Lattner 4120bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type. 41363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_EXTEND, 41463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4151ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // BIT_CONVERT - Theis operator converts between integer and FP values, as 4161ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // if one was stored to memory as integer and the other was loaded from the 41780f55abf009c86bc03821e10746832f88f8a735fChris Lattner // same address (or equivalently for vector format conversions, etc). The 41880f55abf009c86bc03821e10746832f88f8a735fChris Lattner // source and result are required to have the same bit size (e.g. 41980f55abf009c86bc03821e10746832f88f8a735fChris Lattner // f32 <-> i32). This can also be used for int-to-int or fp-to-fp 42080f55abf009c86bc03821e10746832f88f8a735fChris Lattner // conversions, but that is a noop, deleted by getNode(). 4211ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner BIT_CONVERT, 4221ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner 42307f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW - Perform unary floating point 42407f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman // negation, absolute value, square root, sine and cosine, powi, and pow 425dd2afb0e1f65bc41d2c0053468fcddfd696a8231Chris Lattner // operations. 42607f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, 42738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 4288862ef148100070b7bf28beead3951464250c926Evan Cheng // LOAD and STORE have token chains as their first operand, then the same 4298862ef148100070b7bf28beead3951464250c926Evan Cheng // operands as an LLVM load/store instruction, then an offset node that 4308862ef148100070b7bf28beead3951464250c926Evan Cheng // is added / subtracted from the base pointer to form the address (for 4318862ef148100070b7bf28beead3951464250c926Evan Cheng // indexed memory ops). 43263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner LOAD, STORE, 433ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 43463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned 43557fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // to a specified boundary. This node always has two return values: a new 43657fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // stack pointer value and a chain. The first operand is the token chain, 43757fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // the second is the number of bytes to allocate, and the third is the 43857fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment boundary. The size is guaranteed to be a multiple of the stack 43957fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment, and the alignment is guaranteed to be bigger than the stack 44074fe063e90045931eefaba561730e6a9175ced78Chris Lattner // alignment (if required) or 0 to get standard stack alignment. 44163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner DYNAMIC_STACKALLOC, 44263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 44363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Control flow instructions. These all have token chains. 444ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 44563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BR - Unconditional branch. The first operand is the chain 44663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operand, the second is the MBB to branch to. 44763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BR, 44863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 44937efe6764568a3829fee26aba532283131d1a104Nate Begeman // BRIND - Indirect branch. The first operand is the chain, the second 45037efe6764568a3829fee26aba532283131d1a104Nate Begeman // is the value to branch to, which must be of the same type as the target's 45137efe6764568a3829fee26aba532283131d1a104Nate Begeman // pointer type. 45237efe6764568a3829fee26aba532283131d1a104Nate Begeman BRIND, 453c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng 454c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // BR_JT - Jumptable branch. The first operand is the chain, the second 455c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // is the jumptable index, the last one is the jumptable entry index. 456c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng BR_JT, 45737efe6764568a3829fee26aba532283131d1a104Nate Begeman 45863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BRCOND - Conditional branch. The first operand is the chain, 45963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // the second is the condition, the third is the block to branch 46063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // to if the condition is true. 46163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BRCOND, 46263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4637cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in 4647cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // that the condition is represented as condition code, and two nodes to 4657cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // compare, rather than as a combined SetCC node. The operands in order are 4667cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // chain, cc, lhs, rhs, block to branch to if condition is true. 4677cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman BR_CC, 4687cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman 46963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // RET - Return from function. The first operand is the chain, 4708e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // and any subsequent operands are pairs of return value and return value 4718e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // signness for the function. This operation can have variable number of 4728e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // operands. 47363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner RET, 47463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4757572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // INLINEASM - Represents an inline asm block. This node always has two 4767572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // return values: a chain and a flag result. The inputs are as follows: 4777572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #0 : Input chain. 4787572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string. 4797572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+2: A RegisterNode. 4807572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def 4817572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #last: Optional, an incoming flag. 4827572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner INLINEASM, 4831ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey 4841ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // LABEL - Represents a label in mid basic block used to track 4851ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // locations needed for debug and exception handling tables. This node 4861ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // returns a chain. 4871ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // Operand #0 : input chain. 4881ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey // Operand #1 : module unique number use to identify the label. 489bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng // Operand #2 : 0 indicates a debug label (e.g. stoppoint), 1 indicates 490bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng // a EH label, 2 indicates unknown label type. 4911ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey LABEL, 492a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng 493a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track 494a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // local variable declarations for debugging information. First operand is 495a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // a chain, while the next two operands are first two arguments (address 496a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // and variable) of a llvm.dbg.declare instruction. 497a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng DECLARE, 498f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 4995a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a 5005a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // value, the same type as the pointer type for the system, and an output 5015a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // chain. 5025a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKSAVE, 5035a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 5045a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKRESTORE has two operands, an input chain and a pointer to restore to 5055a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // it returns an output chain. 5065a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKRESTORE, 5075a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 50816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of 50916cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // a call sequence, and carry arbitrary information that target might want 51016cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // to know. The first operand is a chain, the rest are specified by the 51116cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // target and not touched by the DAG optimizers. 5120ea0356dff38dfd0420b8c0a2fdf2fae7898c024Dale Johannesen // CALLSEQ_START..CALLSEQ_END pairs may not be nested. 51316cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_START, // Beginning of a call sequence 51416cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_END, // End of a call sequence 515acc398c195a697795bff3245943d104eb19192b9Nate Begeman 516acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAARG - VAARG has three operands: an input chain, a pointer, and a 517acc398c195a697795bff3245943d104eb19192b9Nate Begeman // SRCVALUE. It returns a pair of values: the vaarg value and a new chain. 518acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAARG, 519acc398c195a697795bff3245943d104eb19192b9Nate Begeman 520acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VACOPY - VACOPY has five operands: an input chain, a destination pointer, 521acc398c195a697795bff3245943d104eb19192b9Nate Begeman // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the 522acc398c195a697795bff3245943d104eb19192b9Nate Begeman // source. 523acc398c195a697795bff3245943d104eb19192b9Nate Begeman VACOPY, 524acc398c195a697795bff3245943d104eb19192b9Nate Begeman 525acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a 526acc398c195a697795bff3245943d104eb19192b9Nate Begeman // pointer, and a SRCVALUE. 527acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAEND, VASTART, 52863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 52969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // SRCVALUE - This is a node type that holds a Value* that is used to 53069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // make reference to a value in the LLVM IR. 53121074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner SRCVALUE, 53221074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner 53336b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // MEMOPERAND - This is a node that contains a MachineMemOperand which 53436b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // records information about a memory reference. This is used to make 53536b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // AliasAnalysis queries from the backend. 53669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman MEMOPERAND, 53769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 538e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman // PCMARKER - This corresponds to the pcmarker intrinsic. 53995762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth PCMARKER, 54063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 541aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic. 5428b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // The only operand is a chain and a value and a chain are produced. The 5438b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // value is the contents of the architecture specific cycle counter like 5448b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // register (or other high accuracy low latency clock source) 545aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth READCYCLECOUNTER, 546aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth 547d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner // HANDLENODE node - Used as a handle for various purposes. 548d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner HANDLENODE, 5492d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 55047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // LOCATION - This node is used to represent a source location for debug 55147725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // info. It takes token chain as input, then a line number, then a column 55247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // number, then a filename, then a working dir. It produces a token chain 55347725d059b259f8a0c145478300c9e9caa006b59Chris Lattner // as output. 55447725d059b259f8a0c145478300c9e9caa006b59Chris Lattner LOCATION, 55547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner 556f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey // DEBUG_LOC - This node is used to represent source line information 557abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // embedded in the code. It takes a token chain as input, then a line 55844c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey // number, then a column then a file id (provided by MachineModuleInfo.) It 559abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // produces a token chain as output. 560f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey DEBUG_LOC, 56136397f50343639ce9a25996f2d790c656791ab92Duncan Sands 56236397f50343639ce9a25996f2d790c656791ab92Duncan Sands // TRAMPOLINE - This corresponds to the init_trampoline intrinsic. 56336397f50343639ce9a25996f2d790c656791ab92Duncan Sands // It takes as input a token chain, the pointer to the trampoline, 56436397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the pointer to the nested function, the pointer to pass for the 56536397f50343639ce9a25996f2d790c656791ab92Duncan Sands // 'nest' parameter, a SRCVALUE for the trampoline and another for 56636397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the nested function (allowing targets to access the original 567f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // Function*). It produces the result of the intrinsic and a token 568f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // chain as output. 56936397f50343639ce9a25996f2d790c656791ab92Duncan Sands TRAMPOLINE, 57036397f50343639ce9a25996f2d790c656791ab92Duncan Sands 57166fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov // TRAP - Trapping instruction 57266fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov TRAP, 57366fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov 57427b7db549e4c5bff4579d209304de5628513edebEvan Cheng // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are 57527b7db549e4c5bff4579d209304de5628513edebEvan Cheng // their first operand. The other operands are the address to prefetch, 57627b7db549e4c5bff4579d209304de5628513edebEvan Cheng // read / write specifier, and locality specifier. 57727b7db549e4c5bff4579d209304de5628513edebEvan Cheng PREFETCH, 57827b7db549e4c5bff4579d209304de5628513edebEvan Cheng 57922c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load, 58022c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // store-store, device) 581ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // This corresponds to the memory.barrier intrinsic. 58222c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // it takes an input chain, 4 operands to specify the type of barrier, an 58322c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // operand specifying if the barrier applies to device and uncached memory 58422c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // and produces an output chain. 58522c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth MEMBARRIER, 58622c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth 587ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // Val, OUTCHAIN = ATOMIC_LCS(INCHAIN, ptr, cmp, swap) 588ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.lcs intrinsic. 589ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // cmp is compared to *ptr, and if equal, swap is stored in *ptr. 590ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 591ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth ATOMIC_LCS, 592ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 593ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // Val, OUTCHAIN = ATOMIC_LAS(INCHAIN, ptr, amt) 594ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.las intrinsic. 595ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // *ptr + amt is stored to *ptr atomically. 596ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 597ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth ATOMIC_LAS, 598ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 599ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) 600ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.swap intrinsic. 601ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // amt is stored to *ptr atomically. 602ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 603ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth ATOMIC_SWAP, 604ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 60563307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // Val, OUTCHAIN = ATOMIC_LSS(INCHAIN, ptr, amt) 60663307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // this corresponds to the atomic.lss intrinsic. 60763307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // *ptr - amt is stored to *ptr atomically. 60863307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // the return is always the original value in *ptr 60963307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang ATOMIC_LSS, 61063307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang 61163307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // Val, OUTCHAIN = ATOMIC_L[OpName]S(INCHAIN, ptr, amt) 61263307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // this corresponds to the atomic.[OpName] intrinsic. 61363307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // op(*ptr, amt) is stored to *ptr atomically. 61463307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // the return is always the original value in *ptr 61563307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang ATOMIC_LOAD_AND, 61663307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang ATOMIC_LOAD_OR, 61763307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang ATOMIC_LOAD_XOR, 618507a58ac9b20ddcea2e56a014be26b8f8cc0ecb8Andrew Lenharth ATOMIC_LOAD_NAND, 61963307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang ATOMIC_LOAD_MIN, 62063307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang ATOMIC_LOAD_MAX, 62163307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang ATOMIC_LOAD_UMIN, 62263307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang ATOMIC_LOAD_UMAX, 62363307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang 62463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILTIN_OP_END - This must be the last enum value in this list. 625410354fe0c052141dadeca939395743f8dd58e38Chris Lattner BUILTIN_OP_END 62663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 62763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 628322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// Node predicates 629322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 630a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng /// isBuildVectorAllOnes - Return true if the specified node is a 631322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// BUILD_VECTOR where all of the elements are ~0 or undef. 632a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng bool isBuildVectorAllOnes(const SDNode *N); 6334a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng 6344a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// isBuildVectorAllZeros - Return true if the specified node is a 6354a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// BUILD_VECTOR where all of the elements are 0 or undef. 6364a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng bool isBuildVectorAllZeros(const SDNode *N); 637bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng 638efec751a1b786724862ceff52748df94873a807eEvan Cheng /// isScalarToVector - Return true if the specified node is a 639efec751a1b786724862ceff52748df94873a807eEvan Cheng /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low 640efec751a1b786724862ceff52748df94873a807eEvan Cheng /// element is not an undef. 641efec751a1b786724862ceff52748df94873a807eEvan Cheng bool isScalarToVector(const SDNode *N); 642efec751a1b786724862ceff52748df94873a807eEvan Cheng 643bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// isDebugLabel - Return true if the specified node represents a debug 644fc718542a3e73558af9c0272b0eea67a189e5397Evan Cheng /// label (i.e. ISD::LABEL or TargetInstrInfo::LABEL node and third operand 645bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// is 0). 646bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng bool isDebugLabel(const SDNode *N); 647322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 64863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 649144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// MemIndexedMode enum - This enum defines the load / store indexed 650144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// addressing modes. 65124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 65224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// UNINDEXED "Normal" load / store. The effective address is already 65324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computed and is available in the base pointer. The offset 65481c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// operand is always undefined. In addition to producing a 65581c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// chain, an unindexed load produces one value (result of the 656276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// load); an unindexed store does not produce a value. 65724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 65835acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// PRE_INC Similar to the unindexed mode where the effective address is 6598862ef148100070b7bf28beead3951464250c926Evan Cheng /// PRE_DEC the value of the base pointer add / subtract the offset. 6608862ef148100070b7bf28beead3951464250c926Evan Cheng /// It considers the computation as being folded into the load / 66124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// store operation (i.e. the load / store does the address 66224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computation as well as performing the memory transaction). 66381c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// The base operand is always undefined. In addition to 66481c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// producing a chain, pre-indexed load produces two values 66581c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// (result of the load and the result of the address 66681c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// computation); a pre-indexed store produces one value (result 66781c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// of the address computation). 66824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 66935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// POST_INC The effective address is the value of the base pointer. The 6708862ef148100070b7bf28beead3951464250c926Evan Cheng /// POST_DEC value of the offset operand is then added to / subtracted 6718862ef148100070b7bf28beead3951464250c926Evan Cheng /// from the base after memory transaction. In addition to 6728862ef148100070b7bf28beead3951464250c926Evan Cheng /// producing a chain, post-indexed load produces two values 6738862ef148100070b7bf28beead3951464250c926Evan Cheng /// (the result of the load and the result of the base +/- offset 6748862ef148100070b7bf28beead3951464250c926Evan Cheng /// computation); a post-indexed store produces one value (the 6758862ef148100070b7bf28beead3951464250c926Evan Cheng /// the result of the base +/- offset computation). 67624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 677144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng enum MemIndexedMode { 67824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng UNINDEXED = 0, 67935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_INC, 68035acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_DEC, 68135acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng POST_INC, 682144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng POST_DEC, 683144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng LAST_INDEXED_MODE 68424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng }; 68524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 68624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng //===--------------------------------------------------------------------===// 687c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// LoadExtType enum - This enum defines the three variants of LOADEXT 688c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// (load with extension). 689c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 69024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// SEXTLOAD loads the integer operand and sign extends it to a larger 69124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 69224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// ZEXTLOAD loads the integer operand and zero extends it to a larger 69324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 69424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// EXTLOAD is used for three things: floating point extending loads, 69524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer extending loads [the top bits are undefined], and vector 69624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// extending loads [load into low elt]. 69724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 698c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng enum LoadExtType { 69924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng NON_EXTLOAD = 0, 700c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng EXTLOAD, 701c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng SEXTLOAD, 702c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng ZEXTLOAD, 703c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng LAST_LOADX_TYPE 704c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng }; 705c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 706c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng //===--------------------------------------------------------------------===// 70763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::CondCode enum - These are ordered carefully to make the bitfields 70863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// below work out, when considering SETFALSE (something that never exists 70963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered 71063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal 71163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to. If the "N" column is 1, the result of the comparison is undefined if 71263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the input is a NAN. 71363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 71463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// All of these (except for the 'always folded ops') should be handled for 71563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT, 71663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used. 71763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 71863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Note that these are laid out in a specific order to allow bit-twiddling 71963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to transform conditions. 72063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum CondCode { 72163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Opcode N U L G E Intuitive operation 72263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE, // 0 0 0 0 Always false (always folded) 72363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOEQ, // 0 0 0 1 True if ordered and equal 72463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGT, // 0 0 1 0 True if ordered and greater than 72563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGE, // 0 0 1 1 True if ordered and greater than or equal 72663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLT, // 0 1 0 0 True if ordered and less than 72763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLE, // 0 1 0 1 True if ordered and less than or equal 72863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETONE, // 0 1 1 0 True if ordered and operands are unequal 72963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETO, // 0 1 1 1 True if ordered (no nans) 73063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 73163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUEQ, // 1 0 0 1 True if unordered or equal 73263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGT, // 1 0 1 0 True if unordered or greater than 73363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGE, // 1 0 1 1 True if unordered, greater than, or equal 73463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETULT, // 1 1 0 0 True if unordered or less than 735ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETULE, // 1 1 0 1 True if unordered, less than, or equal 73663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUNE, // 1 1 1 0 True if unordered or not equal 73763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE, // 1 1 1 1 Always true (always folded) 73863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Don't care operations: undefined if the input is a nan. 73963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE2, // 1 X 0 0 0 Always false (always folded) 74063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETEQ, // 1 X 0 0 1 True if equal 74163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGT, // 1 X 0 1 0 True if greater than 74263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGE, // 1 X 0 1 1 True if greater than or equal 74363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETLT, // 1 X 1 0 0 True if less than 744ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETLE, // 1 X 1 0 1 True if less than or equal 74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETNE, // 1 X 1 1 0 True if not equal 74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE2, // 1 X 1 1 1 Always true (always folded) 74763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 748410354fe0c052141dadeca939395743f8dd58e38Chris Lattner SETCC_INVALID // Marker value. 74963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 75063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 75163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isSignedIntSetCC - Return true if this is a setcc instruction that 75263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs a signed comparison when used with integer operands. 75363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isSignedIntSetCC(CondCode Code) { 75463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE; 75563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 75663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isUnsignedIntSetCC - Return true if this is a setcc instruction that 75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs an unsigned comparison when used with integer operands. 75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isUnsignedIntSetCC(CondCode Code) { 76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE; 76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 76363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isTrueWhenEqual - Return true if the specified condition returns true if 76463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the two operands to the condition are equal. Note that if one of the two 76563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operands is a NaN, this value is meaningless. 76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isTrueWhenEqual(CondCode Cond) { 76763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond & 1) != 0; 76863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 76963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 77063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getUnorderedFlavor - This function returns 0 if the condition is always 77163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// false if an operand is a NaN, 1 if the condition is always true if the 77263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operand is a NaN, and 2 if the condition is undefined if the operand is a 77363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// NaN. 77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getUnorderedFlavor(CondCode Cond) { 77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond >> 3) & 3; 77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 77763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 77863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCInverse - Return the operation corresponding to !(X op Y), where 77963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 'op' is a valid SetCC operation. 78063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCInverse(CondCode Operation, bool isInteger); 78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 78263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) 78363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// when given the operation for (X op Y). 78463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCSwappedOperands(CondCode Operation); 78563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 78663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCOrOperation - Return the result of a logical OR between different 78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This 78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger); 79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCAndOperation - Return the result of a logical AND between 79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This 79463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 79563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger); 79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm::ISD namespace 79863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===// 8019cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// SDOperand - Unlike LLVM values, Selection DAG nodes may return multiple 80263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation. Many nodes return multiple values, 80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns 80463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number 80563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values). 80663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 80763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that 80863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node. This pair 8099cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// of information is represented with the SDOperand value type. 81063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 8119cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDOperand { 812f26bc8ef4827cf0023a7052b62b920b41813d473Chris Lattnerpublic: 81363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SDNode *Val; // The node defining the value we are using. 81463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned ResNo; // Which return value of the node we are using. 81563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 8169cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperand() : Val(0), ResNo(0) {} 8179cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperand(SDNode *val, unsigned resno) : Val(val), ResNo(resno) {} 81863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 8199cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein bool operator==(const SDOperand &O) const { 82063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val == O.Val && ResNo == O.ResNo; 82163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 8229cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein bool operator!=(const SDOperand &O) const { 82363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return !operator==(O); 82463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 8259cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein bool operator<(const SDOperand &O) const { 82663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val < O.Val || (Val == O.Val && ResNo < O.ResNo); 82763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 82863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 8299cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperand getValue(unsigned R) const { 8309cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return SDOperand(Val, R); 83163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 83263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 833917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng // isOperandOf - Return true if this node is an operand of N. 834917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOperandOf(SDNode *N) const; 835bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng 83663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the ValueType of the referenced return value. 83763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 83883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands inline MVT getValueType() const; 839ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 84083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands /// getValueSizeInBits - Returns the size of the value in bits. 8414fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// 8424fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman unsigned getValueSizeInBits() const { 84383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands return getValueType().getSizeInBits(); 8444fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman } 8454fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman 84663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Forwarding methods - These forward to the corresponding methods in SDNode. 84763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getOpcode() const; 84863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getNumOperands() const; 8499cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein inline const SDOperand &getOperand(unsigned i) const; 850c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline uint64_t getConstantOperandVal(unsigned i) const; 8510f66a9172175aa7c3055333358170581c999219bNate Begeman inline bool isTargetOpcode() const; 8520f66a9172175aa7c3055333358170581c999219bNate Begeman inline unsigned getTargetOpcode() const; 853a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner 854572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 855572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// reachesChainWithoutSideEffects - Return true if this operand (which must 856572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// be a chain) reaches the specified operand without crossing any 857572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// side-effecting instructions. In practice, this looks through token 858572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// factors and non-volatile loads. In order to remain efficient, this only 859572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// looks a couple of nodes in, it does not do an exhaustive search. 8609cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein bool reachesChainWithoutSideEffects(SDOperand Dest, 861dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein unsigned Depth = 2) const; 862572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 863a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner /// hasOneUse - Return true if there is exactly one operation using this 864a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner /// result value of the defining operator. 865a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner inline bool hasOneUse() const; 866e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman 867e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman /// use_empty - Return true if there are no operations using this 868e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman /// result value of the defining operator. 869e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman inline bool use_empty() const; 87063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 87163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 87263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 8739cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct DenseMapInfo<SDOperand> { 8749cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static inline SDOperand getEmptyKey() { 8759cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return SDOperand((SDNode*)-1, -1U); 876dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 8779cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static inline SDOperand getTombstoneKey() { 8789cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return SDOperand((SDNode*)-1, 0); 879dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 8809cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static unsigned getHashValue(const SDOperand &Val) { 881ae9f3a3b7c915f725aef5a7250e88eaeddda03c6Anton Korobeynikov return ((unsigned)((uintptr_t)Val.Val >> 4) ^ 882ae9f3a3b7c915f725aef5a7250e88eaeddda03c6Anton Korobeynikov (unsigned)((uintptr_t)Val.Val >> 9)) + Val.ResNo; 883c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng } 8849cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static bool isEqual(const SDOperand &LHS, const SDOperand &RHS) { 88576c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner return LHS == RHS; 88676c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner } 887c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static bool isPod() { return true; } 888c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng}; 889c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng 89063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on 89163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDOperands as if they were SDNode*'s. 8929cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<SDOperand> { 893dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein typedef SDNode* SimpleType; 8949cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static SimpleType getSimplifiedValue(const SDOperand &Val) { 895dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return static_cast<SimpleType>(Val.Val); 896dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 897dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 8989cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<const SDOperand> { 899dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein typedef SDNode* SimpleType; 9009cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static SimpleType getSimplifiedValue(const SDOperand &Val) { 901dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return static_cast<SimpleType>(Val.Val); 902dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 903dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 904dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 9059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// SDUse - Represents a use of the SDNode referred by 9069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// the SDOperand. 9079cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDUse { 9089cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperand Operand; 90902819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein /// User - Parent node of this operand. 91002819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein SDNode *User; 911dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// Prev, next - Pointers to the uses list of the SDNode referred by 912dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// this operand. 9139cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse **Prev, *Next; 914dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinpublic: 915dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein friend class SDNode; 91602819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein SDUse(): Operand(), User(NULL), Prev(NULL), Next(NULL) {} 917dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 9189cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse(SDNode *val, unsigned resno) : 91902819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein Operand(val,resno), User(NULL), Prev(NULL), Next(NULL) {} 920dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 9219cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse& operator= (const SDOperand& Op) { 9229cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Operand = Op; 923dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Next = NULL; 924dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Prev = NULL; 925dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return *this; 926dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 927dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 9289cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse& operator= (const SDUse& Op) { 9299cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Operand = Op; 930dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Next = NULL; 931dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Prev = NULL; 932dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return *this; 933dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 934dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 9359cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse * getNext() { return Next; } 936dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 93702819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein SDNode *getUser() { return User; } 9389cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 93902819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein void setUser(SDNode *p) { User = p; } 940dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 9419cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein operator SDOperand() const { return Operand; } 9429cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 9439cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein const SDOperand& getSDOperand() const { return Operand; } 9449cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 9459cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDNode* &getVal () { return Operand.Val; } 9469cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 9479cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein bool operator==(const SDOperand &O) const { 9489cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return Operand == O; 9499cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 9509cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 9519cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein bool operator!=(const SDOperand &O) const { 9529cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return !(Operand == O); 9539cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 9549cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 9559cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein bool operator<(const SDOperand &O) const { 9569cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return Operand < O; 9579cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 9589cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 959dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprotected: 9609cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein void addToList(SDUse **List) { 961dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Next = *List; 962dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein if (Next) Next->Prev = &Next; 963dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Prev = List; 964dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein *List = this; 965dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 966dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 967dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein void removeFromList() { 968dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein *Prev = Next; 969dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein if (Next) Next->Prev = Prev; 970dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 971dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 972dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 973dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 974dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein/// simplify_type specializations - Allow casting operators to work directly on 975dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein/// SDOperands as if they were SDNode*'s. 9769cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<SDUse> { 97763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 9789cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static SimpleType getSimplifiedValue(const SDUse &Val) { 9799cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return static_cast<SimpleType>(Val.getSDOperand().Val); 98063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 98163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 9829cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<const SDUse> { 98363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 9849cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static SimpleType getSimplifiedValue(const SDUse &Val) { 9859cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return static_cast<SimpleType>(Val.getSDOperand().Val); 98663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 98763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 98863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 98963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 99002819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein/// SDOperandPtr - A helper SDOperand pointer class, that can handle 9919cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// arrays of SDUse and arrays of SDOperand objects. This is required 9929cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// in many places inside the SelectionDAG. 9939cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// 9949cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDOperandPtr { 9959cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein const SDOperand *ptr; // The pointer to the SDOperand object 9969cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein int object_size; // The size of the object containg the SDOperand 9979cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinpublic: 99835b31bea0dc9e16d4c384a6a78404bdd791b6693Dan Gohman SDOperandPtr() : ptr(0), object_size(0) {} 99935b31bea0dc9e16d4c384a6a78404bdd791b6693Dan Gohman 10009cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr(SDUse * use_ptr) { 10019cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ptr = &use_ptr->getSDOperand(); 100234cd4a484e532cc463fd5a4bf59b88d13c5467c1Evan Cheng object_size = (int)sizeof(SDUse); 10039cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10049cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 10059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr(const SDOperand * op_ptr) { 10069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ptr = op_ptr; 100734cd4a484e532cc463fd5a4bf59b88d13c5467c1Evan Cheng object_size = (int)sizeof(SDOperand); 10089cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10099cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 10109cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein const SDOperand operator *() { return *ptr; } 10119cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein const SDOperand *operator ->() { return ptr; } 10129cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr operator ++ () { 10139cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ptr = (SDOperand*)((char *)ptr + object_size); 10149cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return *this; 10159cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10169cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 10179cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr operator ++ (int) { 10189cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr tmp = *this; 10199cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ptr = (SDOperand*)((char *)ptr + object_size); 10209cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return tmp; 10219cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10229cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 10239cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperand operator[] (int idx) const { 10249cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return *(SDOperand*)((char*) ptr + object_size * idx); 10259cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10269cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein}; 10279cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 102863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG. 102963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 1030583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskeyclass SDNode : public FoldingSetNode { 1031dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprivate: 10320442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// NodeType - The operation that this node performs. 10330442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 10340442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner unsigned short NodeType; 103563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 103663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true, 103763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// then they will be delete[]'d when the node is destroyed. 103863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner bool OperandsNeedDelete : 1; 10390442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 1040b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// NodeId - Unique id per SDNode in the DAG. 1041b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int NodeId; 10420442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 1043f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// OperandList - The values that are used by this operation. 10440442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 10459cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *OperandList; 1046f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 1047f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// ValueList - The types of the values this node defines. SDNode's may 1048f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// define multiple values simultaneously. 104983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *ValueList; 105063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1051f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// NumOperands/NumValues - The number of entries in the Operand/Value list. 1052f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned short NumOperands, NumValues; 1053b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1054b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner /// Prev/Next pointers - These pointers form the linked list of of the 1055b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner /// AllNodes list in the current DAG. 1056b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner SDNode *Prev, *Next; 1057b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner friend struct ilist_traits<SDNode>; 105863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1059dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// UsesSize - The size of the uses list. 1060dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein unsigned UsesSize; 1061dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1062dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// Uses - List of uses for this SDNode. 10639cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *Uses; 1064dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 10659cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein /// addUse - add SDUse to the list of uses. 10669cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein void addUse(SDUse &U) { U.addToList(&Uses); } 1067dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1068917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner // Out-of-line virtual method to give class a home. 1069917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner virtual void ANCHOR(); 107063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 1071b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner virtual ~SDNode() { 1072b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner assert(NumOperands == 0 && "Operand list not cleared before deletion"); 10733258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner NodeType = ISD::DELETED_NODE; 1074b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 1075b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 107663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 107763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Accessors 107863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // 107963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getOpcode() const { return NodeType; } 10800f66a9172175aa7c3055333358170581c999219bNate Begeman bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } 10810f66a9172175aa7c3055333358170581c999219bNate Begeman unsigned getTargetOpcode() const { 10820f66a9172175aa7c3055333358170581c999219bNate Begeman assert(isTargetOpcode() && "Not a target opcode!"); 10830f66a9172175aa7c3055333358170581c999219bNate Begeman return NodeType - ISD::BUILTIN_OP_END; 10840f66a9172175aa7c3055333358170581c999219bNate Begeman } 108563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1086dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein size_t use_size() const { return UsesSize; } 1087dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool use_empty() const { return Uses == NULL; } 1088dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool hasOneUse() const { return use_size() == 1; } 108963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1090b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// getNodeId - Return the unique node id. 1091b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// 1092b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int getNodeId() const { return NodeId; } 10930442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 10942e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng /// setNodeId - Set unique node id. 10952e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng void setNodeId(int Id) { NodeId = Id; } 10962e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng 10979cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein /// use_iterator - This class provides iterator support for SDUse 1098dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// operands that use a specific SDNode. 1099dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein class use_iterator 11009cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : public forward_iterator<SDUse, ptrdiff_t> { 11019cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *Op; 11029cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein explicit use_iterator(SDUse *op) : Op(op) { 1103dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1104dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein friend class SDNode; 1105dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein public: 11069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef forward_iterator<SDUse, ptrdiff_t>::reference reference; 11079cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer; 1108dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1109dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator(const use_iterator &I) : Op(I.Op) {} 1110dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator() : Op(0) {} 1111dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1112dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool operator==(const use_iterator &x) const { 1113dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return Op == x.Op; 1114dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1115dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool operator!=(const use_iterator &x) const { 1116dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return !operator==(x); 1117dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1118dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1119dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// atEnd - return true if this iterator is at the end of uses list. 1120dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool atEnd() const { return Op == 0; } 1121dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1122dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein // Iterator traversal: forward iteration only. 1123dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator &operator++() { // Preincrement 1124dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot increment end iterator!"); 1125dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Op = Op->getNext(); 1126dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return *this; 1127dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1128dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1129dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator operator++(int) { // Postincrement 1130dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator tmp = *this; ++*this; return tmp; 1131dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1132dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1133dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1134dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// getOperandNum - Retrive a number of a current operand. 1135dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein unsigned getOperandNum() const { 1136dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot dereference end iterator!"); 113734cd4a484e532cc463fd5a4bf59b88d13c5467c1Evan Cheng return (unsigned)(Op - Op->getUser()->OperandList); 1138dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1139dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1140dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// Retrieve a reference to the current operand. 11419cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse &operator*() const { 1142dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot dereference end iterator!"); 1143dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return *Op; 1144dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1145dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1146dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// Retrieve a pointer to the current operand. 11479cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *operator->() const { 1148dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot dereference end iterator!"); 1149dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return Op; 1150dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1151dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein }; 1152dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1153dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// use_begin/use_end - Provide iteration support to walk over all uses 1154dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// of an SDNode. 1155dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1156dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator use_begin(SDNode *node) const { 1157dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return use_iterator(node->Uses); 1158dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1159dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1160dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator use_begin() const { 1161dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return use_iterator(Uses); 1162dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1163dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1164dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein static use_iterator use_end() { return use_iterator(0); } 1165dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 11667ece380440238ad0630a225b85a09a2dbed1165aChris Lattner 1167b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the 1168b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// indicated value. This method ignores uses of other values defined by this 1169b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// operation. 11704ee621125876cc954cba5280dd9395552755a871Evan Cheng bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; 11714ee621125876cc954cba5280dd9395552755a871Evan Cheng 117233d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// hasAnyUseOfValue - Return true if there are any use of the indicated 117333d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// value. This method ignores uses of other values defined by this operation. 117433d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng bool hasAnyUseOfValue(unsigned Value) const; 117533d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng 1176917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isOnlyUseOf - Return true if this node is the only use of N. 1177e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 1178917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOnlyUseOf(SDNode *N) const; 1179b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner 1180917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isOperandOf - Return true if this node is an operand of N. 1181e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 1182917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOperandOf(SDNode *N) const; 118380d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng 1184917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isPredecessorOf - Return true if this node is a predecessor of N. This 1185917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// node is either an operand of N or it can be reached by recursively 1186917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// traversing up the operands. 1187e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// NOTE: this is an expensive method. Use it carefully. 1188917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isPredecessorOf(SDNode *N) const; 11897ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng 119063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumOperands - Return the number of values used by this operation. 119163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 1192f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumOperands() const { return NumOperands; } 119363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1194c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// getConstantOperandVal - Helper method returns the integer value of a 1195c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// ConstantSDNode operand. 1196c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng uint64_t getConstantOperandVal(unsigned Num) const; 1197c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 119863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const SDOperand &getOperand(unsigned Num) const { 1199f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(Num < NumOperands && "Invalid child # of SDNode!"); 12009cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return OperandList[Num].getSDOperand(); 120163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 1202c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 12039cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef SDUse* op_iterator; 1204f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_begin() const { return OperandList; } 1205f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_end() const { return OperandList+NumOperands; } 120650f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner 120763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 12080b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList getVTList() const { 12090b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList X = { ValueList, NumValues }; 12100b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner return X; 12110b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner }; 12120b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 121363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumValues - Return the number of values defined/returned by this 121463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operator. 121563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 1216f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumValues() const { return NumValues; } 121763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 121863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the type of a specified result. 121963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 122083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getValueType(unsigned ResNo) const { 1221f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(ResNo < NumValues && "Illegal result number!"); 1222f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return ValueList[ResNo]; 122363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 12249eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen 12254fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)). 12264fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// 12274fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman unsigned getValueSizeInBits(unsigned ResNo) const { 122883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands return getValueType(ResNo).getSizeInBits(); 12294fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman } 12304fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman 123183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands typedef const MVT* value_iterator; 1232f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_begin() const { return ValueList; } 1233f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_end() const { return ValueList+NumValues; } 123463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 12356e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// getOperationName - Return the opcode of this operation for printing. 12366e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// 1237ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer std::string getOperationName(const SelectionDAG *G = 0) const; 1238144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng static const char* getIndexedModeName(ISD::MemIndexedMode AM); 123963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner void dump() const; 1240efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner void dump(const SelectionDAG *G) const; 124163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 124263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *) { return true; } 124363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1244583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// Profile - Gather unique data for the node. 1245583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// 1246583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey void Profile(FoldingSetNodeID &ID); 1247583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey 124863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 124963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1250109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner 1251109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// getValueTypeList - Return a pointer to the specified value type. 1252109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// 125383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands static const MVT *getValueTypeList(MVT VT); 125483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands static SDVTList getSDVTList(MVT VT) { 125563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner SDVTList Ret = { getValueTypeList(VT), 1 }; 125663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner return Ret; 12572d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 125863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 1259ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner SDNode(unsigned Opc, SDVTList VTs, const SDOperand *Ops, unsigned NumOps) 1260dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { 126163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner OperandsNeedDelete = true; 1262f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner NumOperands = NumOps; 12639cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList = NumOps ? new SDUse[NumOperands] : 0; 12649cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 12659cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein for (unsigned i = 0; i != NumOps; ++i) { 12669cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList[i] = Ops[i]; 12679cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList[i].setUser(this); 12689cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Ops[i].Val->addUse(OperandList[i]); 12699cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ++Ops[i].Val->UsesSize; 12709cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 12719cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 12729cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ValueList = VTs.VTs; 12739cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein NumValues = VTs.NumVTs; 12749cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Prev = 0; Next = 0; 12759cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 12769cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 12779cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDNode(unsigned Opc, SDVTList VTs, SDOperandPtr Ops, unsigned NumOps) 12789cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { 12799cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandsNeedDelete = true; 12809cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein NumOperands = NumOps; 12819cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList = NumOps ? new SDUse[NumOperands] : 0; 1282f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 1283bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner for (unsigned i = 0; i != NumOps; ++i) { 1284f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner OperandList[i] = Ops[i]; 1285dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein OperandList[i].setUser(this); 1286dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Ops[i].Val->addUse(OperandList[i]); 1287dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein ++Ops[i].Val->UsesSize; 12880442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner } 1289bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1290ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner ValueList = VTs.VTs; 1291ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner NumValues = VTs.NumVTs; 1292b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner Prev = 0; Next = 0; 1293f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner } 1294dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1295dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein SDNode(unsigned Opc, SDVTList VTs) 1296dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein : NodeType(Opc), NodeId(-1), UsesSize(0), Uses(NULL) { 1297bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandsNeedDelete = false; // Operands set with InitOperands. 1298bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = 0; 1299bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = 0; 1300bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner ValueList = VTs.VTs; 1301bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumValues = VTs.NumVTs; 1302bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Prev = 0; Next = 0; 1303bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 1304bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1305bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// InitOperands - Initialize the operands list of this node with the 1306bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// specified values, which are part of the node (thus they don't need to be 1307bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// copied in or allocated). 13089cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein void InitOperands(SDUse *Ops, unsigned NumOps) { 1309bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner assert(OperandList == 0 && "Operands already set!"); 1310bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = NumOps; 1311bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = Ops; 1312dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein UsesSize = 0; 1313dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Uses = NULL; 1314bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1315dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein for (unsigned i = 0; i != NumOps; ++i) { 1316dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein OperandList[i].setUser(this); 13179cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Ops[i].getVal()->addUse(OperandList[i]); 13189cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ++Ops[i].getVal()->UsesSize; 1319dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1320bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 1321bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1322d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// MorphNodeTo - This frees the operands of the current node, resets the 1323d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// opcode, types, and operands to the specified value. This should only be 1324d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner /// used by the SelectionDAG class. 1325d429bcd4ac734540ebbc15a0ee37d154ae1daf73Chris Lattner void MorphNodeTo(unsigned Opc, SDVTList L, 132635b31bea0dc9e16d4c384a6a78404bdd791b6693Dan Gohman SDOperandPtr Ops, unsigned NumOps); 13271b95095857b78e12138c22e76c7936611c51355bChris Lattner 1328dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein void addUser(unsigned i, SDNode *User) { 1329dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(User->OperandList[i].getUser() && "Node without parent"); 1330dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein addUse(User->OperandList[i]); 1331dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein ++UsesSize; 13321b95095857b78e12138c22e76c7936611c51355bChris Lattner } 1333dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1334dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein void removeUser(unsigned i, SDNode *User) { 1335dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(User->OperandList[i].getUser() && "Node without parent"); 13369cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse &Op = User->OperandList[i]; 1337dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Op.removeFromList(); 1338dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein --UsesSize; 1339d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 134063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 134163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 134263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13439cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein// Define inline functions from the SDOperand class. 134463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13459cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteininline unsigned SDOperand::getOpcode() const { 134663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getOpcode(); 134763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 134883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sandsinline MVT SDOperand::getValueType() const { 134963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getValueType(ResNo); 135063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 13519cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteininline unsigned SDOperand::getNumOperands() const { 135263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getNumOperands(); 135363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 13549cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteininline const SDOperand &SDOperand::getOperand(unsigned i) const { 135563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Val->getOperand(i); 135663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 13579cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteininline uint64_t SDOperand::getConstantOperandVal(unsigned i) const { 1358c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng return Val->getConstantOperandVal(i); 1359c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 13609cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteininline bool SDOperand::isTargetOpcode() const { 13610f66a9172175aa7c3055333358170581c999219bNate Begeman return Val->isTargetOpcode(); 13620f66a9172175aa7c3055333358170581c999219bNate Begeman} 13639cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteininline unsigned SDOperand::getTargetOpcode() const { 13640f66a9172175aa7c3055333358170581c999219bNate Begeman return Val->getTargetOpcode(); 13650f66a9172175aa7c3055333358170581c999219bNate Begeman} 13669cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteininline bool SDOperand::hasOneUse() const { 1367a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner return Val->hasNUsesOfValue(1, ResNo); 1368a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner} 13699cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteininline bool SDOperand::use_empty() const { 1370e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman return !Val->hasAnyUseOfValue(ResNo); 1371e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman} 137263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13733f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes. This is solely 13743f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 13753f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode { 13763f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 13779cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Op; 13783f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 13793f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner UnarySDNode(unsigned Opc, SDVTList VTs, SDOperand X) 13809cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : SDNode(Opc, VTs) { 13819cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Op = X; 13823f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(&Op, 1); 13833f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 13843f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 13853f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 13863f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes. This is solely 13873f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 13883f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode { 13893f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 13909cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[2]; 13913f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 13923f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner BinarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y) 13933f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 13943f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 13953f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 13963f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 2); 13973f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 13983f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 13993f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 14003f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely 14013f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 14023f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode { 14033f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 14049cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[3]; 14053f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 14063f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner TernarySDNode(unsigned Opc, SDVTList VTs, SDOperand X, SDOperand Y, 14073f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner SDOperand Z) 14083f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 14093f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 14103f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 14113f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[2] = Z; 14123f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 3); 14133f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 14143f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 14153f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 14163f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 1417d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that 1418d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its 1419d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand. This node should be directly created by end-users and not added to 1420d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list. 1421d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode { 1422c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 14239cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Op; 1424d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic: 1425ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is 1426ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling // fixed. 142769cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#ifdef __GNUC__ 1428ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling explicit __attribute__((__noinline__)) HandleSDNode(SDOperand X) 142969cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#else 143069cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling explicit HandleSDNode(SDOperand X) 143169cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#endif 14329cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) { 14339cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Op = X; 1434bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner InitOperands(&Op, 1); 1435bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 143648b85926524f9d29ae600123c90194cd73fd629eChris Lattner ~HandleSDNode(); 14379cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse getValue() const { return Op; } 1438d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner}; 1439d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner 1440ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharthclass AtomicSDNode : public SDNode { 1441ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 14429cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[4]; 144383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT OrigVT; 1444ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharthpublic: 1445c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, 144683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDOperand Cmp, SDOperand Swp, MVT VT) 1447ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth : SDNode(Opc, VTL) { 1448ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth Ops[0] = Chain; 1449c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[1] = Ptr; 1450c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[2] = Swp; 1451c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[3] = Cmp; 1452ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth InitOperands(Ops, 4); 1453ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth OrigVT=VT; 1454ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth } 1455c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand Ptr, 145683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDOperand Val, MVT VT) 1457ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth : SDNode(Opc, VTL) { 1458ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth Ops[0] = Chain; 1459c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[1] = Ptr; 1460c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[2] = Val; 1461ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth InitOperands(Ops, 3); 1462ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth OrigVT=VT; 1463ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth } 146483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getVT() const { return OrigVT; } 1465c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth bool isCompareAndSwap() const { return getOpcode() == ISD::ATOMIC_LCS; } 1466ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth}; 1467ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 146847725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerclass StringSDNode : public SDNode { 146947725d059b259f8a0c145478300c9e9caa006b59Chris Lattner std::string Value; 1470c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 147147725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerprotected: 147247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner friend class SelectionDAG; 1473423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit StringSDNode(const std::string &val) 1474bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::STRING, getSDVTList(MVT::Other)), Value(val) { 147547725d059b259f8a0c145478300c9e9caa006b59Chris Lattner } 147647725d059b259f8a0c145478300c9e9caa006b59Chris Lattnerpublic: 147747725d059b259f8a0c145478300c9e9caa006b59Chris Lattner const std::string &getValue() const { return Value; } 147847725d059b259f8a0c145478300c9e9caa006b59Chris Lattner static bool classof(const StringSDNode *) { return true; } 147947725d059b259f8a0c145478300c9e9caa006b59Chris Lattner static bool classof(const SDNode *N) { 148047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner return N->getOpcode() == ISD::STRING; 148147725d059b259f8a0c145478300c9e9caa006b59Chris Lattner } 148247725d059b259f8a0c145478300c9e9caa006b59Chris Lattner}; 148363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 148463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode { 14856394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman APInt Value; 1486c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 148763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 148863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 148983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ConstantSDNode(bool isTarget, const APInt &val, MVT VT) 1490bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)), 1491bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Value(val) { 149263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 149363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 149463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 14956394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman const APInt &getAPIntValue() const { return Value; } 14966394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman uint64_t getValue() const { return Value.getZExtValue(); } 149763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 149863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int64_t getSignExtended() const { 149983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands unsigned Bits = getValueType(0).getSizeInBits(); 15006394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman return ((int64_t)Value.getZExtValue() << (64-Bits)) >> (64-Bits); 150163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 150263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 150363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool isNullValue() const { return Value == 0; } 150463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner bool isAllOnesValue() const { 150583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands return Value == getValueType(0).getIntegerVTBitMask(); 150663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 150763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 150863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantSDNode *) { return true; } 150963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1510056f9f61d071c6c583951678f2bf543a1316efccChris Lattner return N->getOpcode() == ISD::Constant || 1511056f9f61d071c6c583951678f2bf543a1316efccChris Lattner N->getOpcode() == ISD::TargetConstant; 151263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 151363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 151463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 151563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode { 15168bb369b8072c919ef5802f639a52b17620201190Dale Johannesen APFloat Value; 1517c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 151863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 151963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 152083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ConstantFPSDNode(bool isTarget, const APFloat& val, MVT VT) 152187503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 152287503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen getSDVTList(VT)), Value(val) { 152363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 152463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 152563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1526e6c1742914149d44360fbf05a653041a672282afDale Johannesen const APFloat& getValueAPF() const { return Value; } 152763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 152863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isExactlyValue - We don't rely on operator== working on double values, as 152963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 153063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// As such, this method can be used to do an exact bit-for-bit comparison of 153163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// two floating point values. 1532c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen 1533c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// We leave the version with the double argument here because it's just so 1534c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// convenient to write "2.0" and the like. Without this function we'd 1535c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// have to duplicate its logic everywhere it's called. 15369dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen bool isExactlyValue(double V) const { 15379dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen // convert is not supported on this type 15389dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen if (&Value.getSemantics() == &APFloat::PPCDoubleDouble) 15399dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen return false; 154084cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner APFloat Tmp(V); 154184cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven); 154284cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner return isExactlyValue(Tmp); 154387503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen } 1544e6c1742914149d44360fbf05a653041a672282afDale Johannesen bool isExactlyValue(const APFloat& V) const; 154563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 154683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands bool isValueValidForType(MVT VT, const APFloat& Val); 1547f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen 154863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantFPSDNode *) { return true; } 154963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1550ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner return N->getOpcode() == ISD::ConstantFP || 1551ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner N->getOpcode() == ISD::TargetConstantFP; 155263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 155363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 155463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 155563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode { 155663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *TheGlobal; 1557404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int Offset; 1558c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 155963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 156063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 156183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT, int o = 0); 156263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 156363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 156463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *getGlobal() const { return TheGlobal; } 1565404cb4f9fa2df50eac4d84b8a77c84a92188c6d5Evan Cheng int getOffset() const { return Offset; } 156663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 156763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const GlobalAddressSDNode *) { return true; } 156863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1569f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner return N->getOpcode() == ISD::GlobalAddress || 1570b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalAddress || 1571b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::GlobalTLSAddress || 1572b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalTLSAddress; 157363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 157463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 157563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 157663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode { 157763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int FI; 1578c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 157963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 158063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 158183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands FrameIndexSDNode(int fi, MVT VT, bool isTarg) 1582bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)), 1583bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner FI(fi) { 158463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 158563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 158663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 158763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int getIndex() const { return FI; } 158863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 158963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const FrameIndexSDNode *) { return true; } 159063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1591afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner return N->getOpcode() == ISD::FrameIndex || 1592afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner N->getOpcode() == ISD::TargetFrameIndex; 159363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 159463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 159563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 159637efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode { 159737efe6764568a3829fee26aba532283131d1a104Nate Begeman int JTI; 1598c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 159937efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected: 160037efe6764568a3829fee26aba532283131d1a104Nate Begeman friend class SelectionDAG; 160183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands JumpTableSDNode(int jti, MVT VT, bool isTarg) 1602bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)), 1603bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner JTI(jti) { 160463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 160537efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic: 160637efe6764568a3829fee26aba532283131d1a104Nate Begeman 160759a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner int getIndex() const { return JTI; } 160837efe6764568a3829fee26aba532283131d1a104Nate Begeman 160937efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const JumpTableSDNode *) { return true; } 161037efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const SDNode *N) { 161137efe6764568a3829fee26aba532283131d1a104Nate Begeman return N->getOpcode() == ISD::JumpTable || 161237efe6764568a3829fee26aba532283131d1a104Nate Begeman N->getOpcode() == ISD::TargetJumpTable; 161337efe6764568a3829fee26aba532283131d1a104Nate Begeman } 161437efe6764568a3829fee26aba532283131d1a104Nate Begeman}; 161537efe6764568a3829fee26aba532283131d1a104Nate Begeman 161663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode { 1617d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng union { 1618d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *ConstVal; 1619d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *MachineCPVal; 1620d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } Val; 1621baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int Offset; // It's a MachineConstantPoolValue if top bit is set. 1622b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned Alignment; 1623c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 162463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 162563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 162683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0) 1627ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1628bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1629d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1630d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1631d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 163283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align) 1633ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1634bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1635d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1636d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1637d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1638d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 163983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT VT, int o=0) 1640ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1641bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1642d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1643d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1644d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1645d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1646d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 164783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT VT, int o, unsigned Align) 1648ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1649bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1650d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1651d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1652d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1653d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 165463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 165563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1656d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng bool isMachineConstantPoolEntry() const { 1657d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return (int)Offset < 0; 1658d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1659d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1660d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *getConstVal() const { 1661d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1662d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.ConstVal; 1663d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1664d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1665d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *getMachineCPVal() const { 1666d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1667d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.MachineCPVal; 1668d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1669d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1670baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int getOffset() const { 1671baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng return Offset & ~(1 << (sizeof(unsigned)*8-1)); 1672baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng } 1673ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner 1674ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // Return the alignment of this constant pool object, which is either 0 (for 1675ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // default alignment) or log2 of the desired value. 1676b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned getAlignment() const { return Alignment; } 167763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1678d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng const Type *getType() const; 1679d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 168063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantPoolSDNode *) { return true; } 168163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1682aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner return N->getOpcode() == ISD::ConstantPool || 1683aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner N->getOpcode() == ISD::TargetConstantPool; 168463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 168563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 168663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 168763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode { 168863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *MBB; 1689c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 169063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 169163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1692423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit BasicBlockSDNode(MachineBasicBlock *mbb) 1693bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) { 169463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 169563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 169663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 169763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *getBasicBlock() const { return MBB; } 169863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 169963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const BasicBlockSDNode *) { return true; } 170063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 170163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return N->getOpcode() == ISD::BasicBlock; 170263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 170363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 170463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 170514471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is 170614471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// used when the SelectionDAG needs to make a simple reference to something 170714471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// in the LLVM IR representation. 170814471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 170914471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// Note that this is not used for carrying alias information; that is done 171014471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// with MemOperandSDNode, which includes a Value which is required to be a 171114471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// pointer, and several other fields specific to memory references. 171214471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 17132d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode { 17142d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *V; 1715c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 17162d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected: 17172d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth friend class SelectionDAG; 171869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// Create a SrcValue for a general value. 171969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman explicit SrcValueSDNode(const Value *v) 172069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {} 17212d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 17222d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic: 172369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// getValue - return the contained Value. 17242d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *getValue() const { return V; } 17252d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 17262d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SrcValueSDNode *) { return true; } 17272d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SDNode *N) { 17282d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth return N->getOpcode() == ISD::SRCVALUE; 17292d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 17302d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth}; 17312d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 173263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 173336b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is 173469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// used to represent a reference to memory after ISD::LOAD 173569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// and ISD::STORE have been lowered. 173669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// 173769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanclass MemOperandSDNode : public SDNode { 173869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 173969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanprotected: 174069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman friend class SelectionDAG; 174136b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// Create a MachineMemOperand node 174236b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman explicit MemOperandSDNode(const MachineMemOperand &mo) 174369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {} 174469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 174569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanpublic: 174636b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// MO - The contained MachineMemOperand. 174736b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman const MachineMemOperand MO; 174869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 174969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const MemOperandSDNode *) { return true; } 175069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const SDNode *N) { 175169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman return N->getOpcode() == ISD::MEMOPERAND; 175269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman } 175369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman}; 175469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 175569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 1756d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode { 175763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Reg; 1758c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 175963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 176063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 176183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands RegisterSDNode(unsigned reg, MVT VT) 1762bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) { 176363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 176463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 176563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 176663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getReg() const { return Reg; } 176763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1768d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner static bool classof(const RegisterSDNode *) { return true; } 176963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1770d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner return N->getOpcode() == ISD::Register; 177163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 177263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 177363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 177463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ExternalSymbolSDNode : public SDNode { 177563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *Symbol; 1776c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 177763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 177863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 177983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT) 1780ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 1781bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Symbol(Sym) { 178263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 178363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 178463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 178563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *getSymbol() const { return Symbol; } 178663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 178763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ExternalSymbolSDNode *) { return true; } 178863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 17892a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth return N->getOpcode() == ISD::ExternalSymbol || 17902a2de66db2093a5bc1fd620d1b6ae7992a552b24Andrew Lenharth N->getOpcode() == ISD::TargetExternalSymbol; 179163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 179263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 179363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17947cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode { 179563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ISD::CondCode Condition; 1796c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 179763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 179863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1799423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit CondCodeSDNode(ISD::CondCode Cond) 1800bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) { 180163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 180263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 180363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 18047cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner ISD::CondCode get() const { return Condition; } 180563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 18067cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner static bool classof(const CondCodeSDNode *) { return true; } 180763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 18087cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner return N->getOpcode() == ISD::CONDCODE; 180963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 181063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 181163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1812276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsnamespace ISD { 1813276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands struct ArgFlagsTy { 1814276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands private: 1815276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t NoFlagSet = 0ULL; 1816276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ZExt = 1ULL<<0; ///< Zero extended 1817276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ZExtOffs = 0; 1818276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SExt = 1ULL<<1; ///< Sign extended 1819276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SExtOffs = 1; 1820276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t InReg = 1ULL<<2; ///< Passed in register 1821276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t InRegOffs = 2; 1822276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr 1823276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SRetOffs = 3; 1824276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value 1825276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValOffs = 4; 1826276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain 1827276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t NestOffs = 5; 1828276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment 1829276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValAlignOffs = 6; 18306ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray static const uint64_t Split = 1ULL << 10; 18316ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray static const uint64_t SplitOffs = 10; 1832276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t OrigAlign = 0x1FULL<<27; 1833276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t OrigAlignOffs = 27; 1834276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size 1835276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValSizeOffs = 32; 1836276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1837276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t One = 1ULL; //< 1 of this type, for shifts 1838276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1839276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands uint64_t Flags; 1840276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands public: 1841276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ArgFlagsTy() : Flags(0) { } 1842276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1843276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isZExt() const { return Flags & ZExt; } 1844276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setZExt() { Flags |= One << ZExtOffs; } 1845276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1846276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isSExt() const { return Flags & SExt; } 1847276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setSExt() { Flags |= One << SExtOffs; } 1848276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1849276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isInReg() const { return Flags & InReg; } 1850276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setInReg() { Flags |= One << InRegOffs; } 1851276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1852276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isSRet() const { return Flags & SRet; } 1853276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setSRet() { Flags |= One << SRetOffs; } 1854276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1855276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isByVal() const { return Flags & ByVal; } 1856276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByVal() { Flags |= One << ByValOffs; } 1857276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1858276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isNest() const { return Flags & Nest; } 1859276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setNest() { Flags |= One << NestOffs; } 1860276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1861276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getByValAlign() const { 186294bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned) 186394bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2); 1864276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 1865276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByValAlign(unsigned A) { 1866276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~ByValAlign) | 1867276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands (uint64_t(Log2_32(A) + 1) << ByValAlignOffs); 1868276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 1869c0cb28fd3abee9a8b40856990e04f1af2f9bd7b8Nicolas Geoffray 18706ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray bool isSplit() const { return Flags & Split; } 18716ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray void setSplit() { Flags |= One << SplitOffs; } 1872276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1873276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getOrigAlign() const { 187494bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned) 187594bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2); 1876276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 1877276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setOrigAlign(unsigned A) { 1878276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~OrigAlign) | 1879276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands (uint64_t(Log2_32(A) + 1) << OrigAlignOffs); 1880276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 1881276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1882276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getByValSize() const { 188394bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned)((Flags & ByValSize) >> ByValSizeOffs); 1884276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 1885276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByValSize(unsigned S) { 1886276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs); 1887276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 1888276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1889276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4". 1890276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands std::string getArgFlagsString(); 1891276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1892276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// getRawBits - Represent the flags as a bunch of bits. 1893276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands uint64_t getRawBits() const { return Flags; } 1894276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands }; 1895276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands} 1896276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1897276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands/// ARG_FLAGSSDNode - Leaf node holding parameter flags. 1898276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsclass ARG_FLAGSSDNode : public SDNode { 1899276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ISD::ArgFlagsTy TheFlags; 1900276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1901276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsprotected: 1902276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands friend class SelectionDAG; 1903276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags) 1904276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) { 1905276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 1906276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandspublic: 1907276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ISD::ArgFlagsTy getArgFlags() const { return TheFlags; } 1908276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 1909276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static bool classof(const ARG_FLAGSSDNode *) { return true; } 1910276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static bool classof(const SDNode *N) { 1911276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands return N->getOpcode() == ISD::ARG_FLAGS; 1912276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 1913276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands}; 1914276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 191583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands/// VTSDNode - This class is used to represent MVT's, which are used 191615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations. 191715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode { 191883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT ValueType; 1919c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 192015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected: 192115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner friend class SelectionDAG; 192283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands explicit VTSDNode(MVT VT) 1923bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) { 192463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 192515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic: 192615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 192783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getVT() const { return ValueType; } 192815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 192915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const VTSDNode *) { return true; } 193015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const SDNode *N) { 193115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner return N->getOpcode() == ISD::VALUETYPE; 193215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner } 193315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner}; 193415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 19359de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode 19369de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// 19379de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LSBaseSDNode : public SDNode { 19389de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprivate: 1939b625f2f8960de32bc973092aaee8ac62863006feDan Gohman // AddrMode - unindexed, pre-indexed, post-indexed. 1940b625f2f8960de32bc973092aaee8ac62863006feDan Gohman ISD::MemIndexedMode AddrMode; 1941b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1942b625f2f8960de32bc973092aaee8ac62863006feDan Gohman // MemoryVT - VT of in-memory value. 194383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT MemoryVT; 1944b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 19459de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! SrcValue - Memory location for alias analysis. 19469de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const Value *SrcValue; 19479de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 19489de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! SVOffset - Memory location offset. 19499de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel int SVOffset; 19509de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 19519de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Alignment - Alignment of memory location in bytes. 19529de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel unsigned Alignment; 19539de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 19549de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! IsVolatile - True if the store is volatile. 19559de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel bool IsVolatile; 19569de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprotected: 19579de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Operand array for load and store 19589de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel /*! 19599de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel \note Moving this array to the base class captures more 19609de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel common functionality shared between LoadSDNode and 19619de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel StoreSDNode 19629de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel */ 19639cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[4]; 19649de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic: 196513d57320bd212483463d4f8992d5787b29eda5dfBill Wendling LSBaseSDNode(ISD::NodeType NodeTy, SDOperand *Operands, unsigned numOperands, 196683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDVTList VTs, ISD::MemIndexedMode AM, MVT VT, 1967b625f2f8960de32bc973092aaee8ac62863006feDan Gohman const Value *SV, int SVO, unsigned Align, bool Vol) 19689de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel : SDNode(NodeTy, VTs), 1969b625f2f8960de32bc973092aaee8ac62863006feDan Gohman AddrMode(AM), MemoryVT(VT), 197059a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner SrcValue(SV), SVOffset(SVO), Alignment(Align), IsVolatile(Vol) { 197113d57320bd212483463d4f8992d5787b29eda5dfBill Wendling for (unsigned i = 0; i != numOperands; ++i) 1972b625f2f8960de32bc973092aaee8ac62863006feDan Gohman Ops[i] = Operands[i]; 197313d57320bd212483463d4f8992d5787b29eda5dfBill Wendling InitOperands(Ops, numOperands); 1974b625f2f8960de32bc973092aaee8ac62863006feDan Gohman assert(Align != 0 && "Loads and stores should have non-zero aligment"); 1975437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) && 1976437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman "Only indexed loads and stores have a non-undef offset operand"); 1977b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 19789de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 197959a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getChain() const { return getOperand(0); } 198059a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getBasePtr() const { 19819de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel return getOperand(getOpcode() == ISD::LOAD ? 1 : 2); 19829de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel } 198363602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner const SDOperand &getOffset() const { 198463602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); 198563602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner } 19869de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 19879de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel const Value *getSrcValue() const { return SrcValue; } 19889de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel int getSrcValueOffset() const { return SVOffset; } 19899de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel unsigned getAlignment() const { return Alignment; } 199083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getMemoryVT() const { return MemoryVT; } 19919de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel bool isVolatile() const { return IsVolatile; } 19929de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 1993b625f2f8960de32bc973092aaee8ac62863006feDan Gohman ISD::MemIndexedMode getAddressingMode() const { return AddrMode; } 1994b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1995b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isIndexed - Return true if this is a pre/post inc/dec load/store. 1996b625f2f8960de32bc973092aaee8ac62863006feDan Gohman bool isIndexed() const { return AddrMode != ISD::UNINDEXED; } 1997b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 1998b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. 1999b625f2f8960de32bc973092aaee8ac62863006feDan Gohman bool isUnindexed() const { return AddrMode == ISD::UNINDEXED; } 2000b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 200136b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// getMemOperand - Return a MachineMemOperand object describing the memory 200269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// reference performed by this load or store. 200336b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman MachineMemOperand getMemOperand() const; 200469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 200513d57320bd212483463d4f8992d5787b29eda5dfBill Wendling static bool classof(const LSBaseSDNode *) { return true; } 2006b625f2f8960de32bc973092aaee8ac62863006feDan Gohman static bool classof(const SDNode *N) { 2007b625f2f8960de32bc973092aaee8ac62863006feDan Gohman return N->getOpcode() == ISD::LOAD || 2008b625f2f8960de32bc973092aaee8ac62863006feDan Gohman N->getOpcode() == ISD::STORE; 2009b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 20109de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel}; 20119de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 201224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes. 201324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 20149de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode { 2015c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 2016bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 201781c384578828dde08f63a4f030f4860a92391cddEvan Cheng // ExtType - non-ext, anyext, sext, zext. 201881c384578828dde08f63a4f030f4860a92391cddEvan Cheng ISD::LoadExtType ExtType; 201981c384578828dde08f63a4f030f4860a92391cddEvan Cheng 202024446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 202124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 2022ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner LoadSDNode(SDOperand *ChainPtrOff, SDVTList VTs, 202383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT, 202495c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 2025b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3, 2026b625f2f8960de32bc973092aaee8ac62863006feDan Gohman VTs, AM, LVT, SV, O, Align, Vol), 2027437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman ExtType(ETy) {} 202824446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 202924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 203024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng ISD::LoadExtType getExtensionType() const { return ExtType; } 203159a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getBasePtr() const { return getOperand(1); } 203259a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getOffset() const { return getOperand(2); } 203339354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 203424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const LoadSDNode *) { return true; } 203524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 203624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD; 203724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 203824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 203924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 204024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes. 204124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 20429de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode { 2043c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 2044bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 20453ec81c0ee73462b7b9acd355b0013827d06ad93cDuncan Sands // IsTruncStore - True if the op does a truncation before store. 204681c384578828dde08f63a4f030f4860a92391cddEvan Cheng bool IsTruncStore; 204724446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 204824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 2049ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner StoreSDNode(SDOperand *ChainValuePtrOff, SDVTList VTs, 205083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ISD::MemIndexedMode AM, bool isTrunc, MVT SVT, 205124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 2052b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4, 2053b625f2f8960de32bc973092aaee8ac62863006feDan Gohman VTs, AM, SVT, SV, O, Align, Vol), 2054437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman IsTruncStore(isTrunc) {} 205524446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 205624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 205724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng bool isTruncatingStore() const { return IsTruncStore; } 205859a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getValue() const { return getOperand(1); } 205959a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getBasePtr() const { return getOperand(2); } 206059a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner const SDOperand &getOffset() const { return getOperand(3); } 206139354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 20626d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng static bool classof(const StoreSDNode *) { return true; } 206324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 206424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::STORE; 206524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 206624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 206724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 206815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 20691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { 20701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNode *Node; 20711080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned Operand; 2072ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 20731080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 20741080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic: 20751080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator==(const SDNodeIterator& x) const { 20761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Operand == x.Operand; 20771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 20781080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 20791080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 20801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNodeIterator &operator=(const SDNodeIterator &I) { 20811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 20821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner Operand = I.Operand; 20831080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 20841080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 2085ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 20861080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator*() const { 20871080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Node->getOperand(Operand).Val; 20881080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 20891080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator->() const { return operator*(); } 2090ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 20911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator& operator++() { // Preincrement 20921080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner ++Operand; 20931080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 20941080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 20951080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator operator++(int) { // Postincrement 2096ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SDNodeIterator tmp = *this; ++*this; return tmp; 20971080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 20981080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 20991080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 21001080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator end (SDNode *N) { 21011080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator(N, N->getNumOperands()); 21021080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 21031080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 21041080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned getOperand() const { return Operand; } 21051080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNode *getNode() const { return Node; } 21061080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 21071080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 21081080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> { 21091080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNode NodeType; 21101080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNodeIterator ChildIteratorType; 21111080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static inline NodeType *getEntryNode(SDNode *N) { return N; } 2112ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_begin(NodeType *N) { 21131080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::begin(N); 21141080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 2115ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_end(NodeType *N) { 21161080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::end(N); 21171080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 21181080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 21191080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 2120b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnertemplate<> 2121b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattnerstruct ilist_traits<SDNode> { 2122b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *getPrev(const SDNode *N) { return N->Prev; } 2123b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *getNext(const SDNode *N) { return N->Next; } 2124b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 2125b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void setPrev(SDNode *N, SDNode *Prev) { N->Prev = Prev; } 2126b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void setNext(SDNode *N, SDNode *Next) { N->Next = Next; } 2127b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 2128b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static SDNode *createSentinel() { 2129bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner return new SDNode(ISD::EntryToken, SDNode::getSDVTList(MVT::Other)); 2130b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 2131b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner static void destroySentinel(SDNode *N) { delete N; } 2132b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner //static SDNode *createNode(const SDNode &V) { return new SDNode(V); } 2133b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 2134b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 213513d57320bd212483463d4f8992d5787b29eda5dfBill Wendling void addNodeToList(SDNode *) {} 213613d57320bd212483463d4f8992d5787b29eda5dfBill Wendling void removeNodeFromList(SDNode *) {} 213713d57320bd212483463d4f8992d5787b29eda5dfBill Wendling void transferNodesFromList(iplist<SDNode, ilist_traits> &, 213813d57320bd212483463d4f8992d5787b29eda5dfBill Wendling const ilist_iterator<SDNode> &, 213913d57320bd212483463d4f8992d5787b29eda5dfBill Wendling const ilist_iterator<SDNode> &) {} 2140b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner}; 2141b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 2142c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD { 2143186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// isNormalLoad - Returns true if the specified node is a non-extending 2144186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// and unindexed load. 2145186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng inline bool isNormalLoad(const SDNode *N) { 2146c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N); 2147c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD && 2148186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng Ld->getAddressingMode() == ISD::UNINDEXED; 2149186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng } 2150186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng 215124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// isNON_EXTLoad - Returns true if the specified node is a non-extending 215224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// load. 215324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng inline bool isNON_EXTLoad(const SDNode *N) { 2154c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 215524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 215624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 215724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2158c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 2159c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2160c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isEXTLoad(const SDNode *N) { 2161c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 216224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 2163c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 2164c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2165c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 2166c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2167c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isSEXTLoad(const SDNode *N) { 2168c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 216924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 2170c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 2171c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2172c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 2173c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2174c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isZEXTLoad(const SDNode *N) { 2175c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 217624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 2177c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 21788b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 2179c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load. 218002c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// 218102c50e4891841c28b2a743731dfc60744bb78879Evan Cheng inline bool isUNINDEXEDLoad(const SDNode *N) { 2182c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 218302c50e4891841c28b2a743731dfc60744bb78879Evan Cheng cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 218402c50e4891841c28b2a743731dfc60744bb78879Evan Cheng } 218502c50e4891841c28b2a743731dfc60744bb78879Evan Cheng 2186c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isNormalStore - Returns true if the specified node is a non-truncating 2187c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// and unindexed store. 2188c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands inline bool isNormalStore(const SDNode *N) { 2189c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands const StoreSDNode *St = dyn_cast<StoreSDNode>(N); 2190c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return St && !St->isTruncatingStore() && 2191c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands St->getAddressingMode() == ISD::UNINDEXED; 2192c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands } 2193c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands 21948b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 21958b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 21968b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isNON_TRUNCStore(const SDNode *N) { 2197c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore(); 21988b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 21998b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 22008b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isTRUNCStore - Returns true if the specified node is a truncating 22018b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 22028b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isTRUNCStore(const SDNode *N) { 2203c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore(); 2204c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands } 2205c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands 2206c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isUNINDEXEDStore - Returns true if the specified node is an 2207c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// unindexed store. 2208c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands inline bool isUNINDEXEDStore(const SDNode *N) { 2209c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && 2210c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 22118b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 2212c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 2213c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2214c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 221563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace 221663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 221763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif 2218