SelectionDAGNodes.h revision 00ec49b6bafc33ee17d97ec1c723e1edb41d4c97
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" 234fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman#include "llvm/Constants.h" 24583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/ADT/FoldingSet.h" 251080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/GraphTraits.h" 2643d1fd449f1a0ac9d9dafa0b9569bb6b2e976198Anton Korobeynikov#include "llvm/ADT/iterator.h" 27fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/ilist_node.h" 28fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/STLExtras.h" 29d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h" 3036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman#include "llvm/CodeGen/MachineMemOperand.h" 310e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/Allocator.h" 320e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/RecyclingAllocator.h" 3339931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h" 3463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert> 3563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm { 3763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG; 3963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue; 4063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock; 41d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue; 4263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode; 437f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanclass CompileUnitDesc; 4476c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate <typename T> struct DenseMapInfo; 4563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type; 468e4018e2de52c534405d7155c7009d0b35afb861Cedric Venettemplate <typename T> struct ilist_traits; 4763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 480b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by 490b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG. Instances of this simple value class are returned by 500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...). 510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// 520b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList { 5383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *VTs; 540b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner unsigned short NumVTs; 550b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner}; 560b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 5763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the 5863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types. 5963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 60e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen/// If you add new elements here you should increase OpActionsCapacity in 61e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen/// TargetLowering.h by the number of new elements. 6263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD { 63d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov 6463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 6563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::NodeType enum - This enum defines all of the operators valid in a 6663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SelectionDAG. 6763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 6863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum NodeType { 693258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // DELETED_NODE - This is an illegal flag value that is used to catch 703258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // errors. This opcode is not a legal opcode for any node. 713258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner DELETED_NODE, 723258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner 738a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // EntryToken - This is the marker used to indicate the start of the region. 748a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner EntryToken, 758a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner 76b2ab0e7471df7126a5b63fe8414b95c9584a0214Bill Wendling // TokenFactor - This node takes multiple tokens as input and produces a 778a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // single token result. This is used to represent the fact that the operand 788a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // operators are independent of each other. 798a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner TokenFactor, 80f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman 81f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // AssertSext, AssertZext - These nodes record if a register contains a 82f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // value that has already been zero or sign extended from a narrower type. 83f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // These nodes take two operands. The first is the node that has already 84f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // been extended, and the second is a value type node indicating the width 85f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // of the extension 86f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman AssertSext, AssertZext, 87ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 888a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // Various leaf nodes. 897f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register, 901ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng Constant, ConstantFP, 91b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio GlobalAddress, GlobalTLSAddress, FrameIndex, 92056292fd738924f3f7703725d8f630983794b5a5Bill Wendling JumpTable, ConstantPool, ExternalSymbol, 931ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng 9482c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth // The address of the GOT 9582c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth GLOBAL_OFFSET_TABLE, 96bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman 97bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and 98bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // llvm.returnaddress on the DAG. These nodes take one operand, the index 99bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // of the frame or return address to return. An index of zero corresponds 100bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // to the current function's frame or return address, an index of one to the 101bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // parent's frame or return address, and so on. 102bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman FRAMEADDR, RETURNADDR, 1032365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 1042365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to 1052365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // first (possible) on-stack argument. This is needed for correct stack 1062365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // adjustment during unwind. 1072365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov FRAME_TO_ARGS_OFFSET, 108f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 109f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the 110f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // address of the exception block on entry to an landing pad block. 111f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EXCEPTIONADDR, 112f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 113f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents 114f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // the selection index of the exception thrown. 115f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EHSELECTION, 116beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth 1172365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 1182365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // 'eh_return' gcc dwarf builtin, which is used to return from 1192365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // exception. The general meaning is: adjust stack by OFFSET and pass 1202365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // execution to HANDLER. Many platform-related details also :) 1212365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov EH_RETURN, 1222365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 123ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // TargetConstant* - Like Constant*, but the DAG does not do any folding or 124ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // simplification of the constant. 125056f9f61d071c6c583951678f2bf543a1316efccChris Lattner TargetConstant, 126ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner TargetConstantFP, 127f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner 128f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or 129f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // anything else with this node, and this is valid in the target-specific 130f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // dag, turning into a GlobalAddress operand. 131f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner TargetGlobalAddress, 132b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio TargetGlobalTLSAddress, 133afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner TargetFrameIndex, 13437efe6764568a3829fee26aba532283131d1a104Nate Begeman TargetJumpTable, 135aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner TargetConstantPool, 136056292fd738924f3f7703725d8f630983794b5a5Bill Wendling TargetExternalSymbol, 13772601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner 138ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) 139ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with no side effects. 140ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// The first operand is the ID number of the intrinsic from the 141ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The 142ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// node has returns the result of the intrinsic. 143ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_WO_CHAIN, 144ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 145ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) 146ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 147ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// returns a result. The first operand is a chain pointer. The second is 148ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The 149ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// operands to the intrinsic follow. The node has two results, the result 150ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// of the intrinsic and an output chain. 151ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_W_CHAIN, 15263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 153ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) 154ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 155ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// does not return a result. The first operand is a chain pointer. The 156ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// second is the ID number of the intrinsic from the llvm::Intrinsic 157ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// namespace. The operands to the intrinsic follow. 158ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_VOID, 159ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 160d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // CopyToReg - This node has three operands: a chain, a register number to 161d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // set to this value, and a value. 16263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyToReg, 16363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 16463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // CopyFromReg - This node indicates that the input value is a virtual or 16563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // physical register that is defined outside of the scope of this 166ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman // SelectionDAG. The register is available from the RegisterSDNode object. 16763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyFromReg, 16863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 169fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman // UNDEF - An undefined node 170fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman UNDEF, 171681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner 172b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node 173b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// represents the formal arguments for a function. CC# is a Constant value 174b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// indicating the calling convention of the function, and ISVARARG is a 175b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// flag that indicates whether the function is varargs or not. This node 176b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// has one result value for each incoming argument, plus one for the output 177b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// chain. It must be custom legalized. See description of CALL node for 178b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FLAG argument contents explanation. 179c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner /// 180681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner FORMAL_ARGUMENTS, 1816c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner 182095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CALLEE, 183b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn) 1846c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// This node represents a fully general function call, before the legalizer 185b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// runs. This has one result value for each argument / flag pair, plus 186b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// a chain result. It must be custom legalized. Flag argument indicates 187b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// misc. argument attributes. Currently: 188b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 0 - signness 189b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 1 - 'inreg' attribute 190b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 2 - 'sret' attribute 191594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 4 - 'byval' attribute 192594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 5 - 'nest' attribute 193594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 6-9 - alignment of byval structures 194594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 10-26 - size of byval structures 19513a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// Bits 31:27 - argument ABI alignment in the first argument piece and 19613a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// alignment '1' in other argument pieces. 197095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// 198095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// CALL nodes use the CallSDNode subclass of SDNode, which 199095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// additionally carries information about the calling convention, 200095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// whether the call is varargs, and if it's marked as a tail call. 201095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// 2026c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner CALL, 203fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman 20425eb043759c23b61769108f78382eb9701c41db2Duncan Sands // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by 205041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // a Constant, which is required to be operand #1) half of the integer or 206041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // float value specified as operand #0. This is only for use before 207041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // legalization, for values that will be broken into multiple registers. 20863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner EXTRACT_ELEMENT, 20963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 21063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given 21163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // two values of the same integer value type, this produces a value twice as 21263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // big. Like EXTRACT_ELEMENT, this can only be used before legalization. 21363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BUILD_PAIR, 214041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands 215006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // MERGE_VALUES - This node takes multiple discrete operands and returns 216006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // them all as its individual results. This nodes has exactly the same 217006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // number of inputs and outputs, and is only valid before legalization. 218006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // This node is useful for some pieces of the code generator that want to 219006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // think about a single node with multiple results, not multiple nodes. 220006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner MERGE_VALUES, 22163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 222615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple integer binary arithmetic operators. 223bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, 224fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 225fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing 226b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // a signed/unsigned value of type i[2*N], and return the full value as 227fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // two results, each of type iN. 228fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SMUL_LOHI, UMUL_LOHI, 229fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 230fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and 231fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // remainder result. 232fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SDIVREM, UDIVREM, 233615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner 23455e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // CARRY_FALSE - This node is used when folding other nodes, 23555e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // like ADDC/SUBC, which indicate the carry result is always false. 23655e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner CARRY_FALSE, 23755e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner 238551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-setting nodes for multiple precision addition and subtraction. 239551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // These nodes take two operands of the same value type, and produce two 240551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // results. The first result is the normal add or sub result, the second 241551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // result is the carry flag result. 242551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDC, SUBC, 243551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 244551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-using nodes for multiple precision addition and subtraction. These 245551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // nodes take three operands: The first two are the normal lhs and rhs to 246551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // the add or sub, and the third is the input carry flag. These nodes 247551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // produce two results; the normal result of the add or sub, and the output 248551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // carry flag. These nodes both read and write a carry flag to allow them 249551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // to them to be chained together for add and sub of arbitrarily large 250551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // values. 251551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDE, SUBE, 252551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 253615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple binary floating point operators. 254615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner FADD, FSUB, FMUL, FDIV, FREM, 25538bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 25638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This 25738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // DAG node does not require that X and Y have the same type, just that they 25838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // are both floating point. X and the result must have the same type. 25938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(f32, f64) is allowed. 26038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner FCOPYSIGN, 261fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner 2621a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point 2631a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // value as an integer 0/1 value. 2641a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner FGETSIGN, 2651a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner 266664e9546d674096c5a012536f1a424b1681ece51Dan Gohman /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector 26722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// with the specified, possibly variable, elements. The number of elements 26822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// is required to be a power of two. 26922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner BUILD_VECTOR, 27022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2717f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element 2724f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// at IDX replaced with VAL. If the type of VAL is larger than the vector 2734f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// element type then VAL is truncated before replacement. 27422232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner INSERT_VECTOR_ELT, 2754b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner 2764b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR 2777f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// identified by the (potentially variable) element number IDX. 2784b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner EXTRACT_VECTOR_ELT, 27922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2807f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of 2817f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector type with the same length and element type, this produces a 2827f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// concatenated vector result value, with length equal to the sum of the 283b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman /// lengths of the input vectors. 2847f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman CONCAT_VECTORS, 2856595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman 2867f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an 2877f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector value) starting with the (potentially variable) element number 2887f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// IDX, which must be a multiple of the result vector length. 2897f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman EXTRACT_SUBVECTOR, 29059c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 29149c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same 29249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values 29359c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// (maybe of an illegal datatype) or undef that indicate which value each 29459c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// result element will get. The elements of VEC1/VEC2 are enumerated in 29559c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// order. This is quite similar to the Altivec 'vperm' instruction, except 29659c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// that the indices must be constants and are in terms of the element size 29759c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// of VEC1/VEC2, not in terms of bytes. 29849c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner VECTOR_SHUFFLE, 29959c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 300210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a 301a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// scalar value into element 0 of the resultant vector type. The top 302a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// elements 1 to N-1 of the N-element vector are undefined. 303210721aecc0916315f61660dc387a96b89ec423bChris Lattner SCALAR_TO_VECTOR, 304210721aecc0916315f61660dc387a96b89ec423bChris Lattner 305557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // EXTRACT_SUBREG - This node is used to extract a sub-register value. 306557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg and a constant sub-register index as operands. 307709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // Note sub-register indices must be increasing. That is, if the 308709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // sub-register index of a 8-bit sub-register is N, then the index for a 309709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // 16-bit sub-register must be at least N+1. 310557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb EXTRACT_SUBREG, 311557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 3124499e495eabe8de7d595416a03c56af4688df507Evan Cheng // INSERT_SUBREG - This node is used to insert a sub-register value. 313557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg, a subreg value, and a constant sub-register 3144499e495eabe8de7d595416a03c56af4688df507Evan Cheng // index as operands. 315557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb INSERT_SUBREG, 316557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 317bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing 318b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // an unsigned/signed value of type i[2*N], then return the top part. 319bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner MULHU, MULHS, 32063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 32135ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // Bitwise operators - logical and, logical or, logical xor, shift left, 32235ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // shift right algebraic (shift in sign bits), shift right logical (shift in 32335ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // zeroes), rotate left, rotate right, and byteswap. 32435ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP, 32563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 326691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth // Counting operators 327691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth CTTZ, CTLZ, CTPOP, 328691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth 3293b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not 3303b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // i1 then the high bits must conform to getSetCCResultContents. 3313b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands SELECT, 3323b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands 3339373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // Select with condition operator - This selects between a true value and 3349373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // a false value (ops #2 and #3) based on the boolean result of comparing 3359373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // the lhs and rhs (ops #0 and #1) of a conditional expression with the 3369373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // condition code in op #4, a CondCodeSDNode. 3379373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT_CC, 33863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3393b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // SetCC operator - This evaluates to a true value iff the condition is 3403b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // true. If the result value type is not i1 then the high bits conform 3413b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // to getSetCCResultContents. The operands to this are the left and right 3423b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // operands to compare (ops #0, and #1) and the condition code to compare 3433b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // them with (op #2) as a CondCodeSDNode. 34463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETCC, 34563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 346b43e9c196542acc80c9e4643809661065710848fNate Begeman // Vector SetCC operator - This evaluates to a vector of integer elements 347b43e9c196542acc80c9e4643809661065710848fNate Begeman // with the high bit in each element set to true if the comparison is true 348b43e9c196542acc80c9e4643809661065710848fNate Begeman // and false if the comparison is false. All other bits in each element 349b43e9c196542acc80c9e4643809661065710848fNate Begeman // are undefined. The operands to this are the left and right operands 350b43e9c196542acc80c9e4643809661065710848fNate Begeman // to compare (ops #0, and #1) and the condition code to compare them with 351b43e9c196542acc80c9e4643809661065710848fNate Begeman // (op #2) as a CondCodeSDNode. 352b43e9c196542acc80c9e4643809661065710848fNate Begeman VSETCC, 353b43e9c196542acc80c9e4643809661065710848fNate Begeman 35414c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded 35514c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // integer shift operations, just like ADD/SUB_PARTS. The operation 35614c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // ordering is: 3576b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner // [Lo,Hi] = op [LoLHS,HiLHS], Amt 35814c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner SHL_PARTS, SRA_PARTS, SRL_PARTS, 35914c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner 36063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Conversion operators. These are all single input single output 36163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operations. For all of these, the result type must be strictly 36263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // wider or narrower (depending on the operation) than the source 36363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // type. 36463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 36563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SIGN_EXTEND - Used for integer types, replicating the sign bit 36663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // into new bits. 36763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SIGN_EXTEND, 36863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 36963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // ZERO_EXTEND - Used for integer types, zeroing the new bits. 37063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ZERO_EXTEND, 37163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3727e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner // ANY_EXTEND - Used for integer types. The high bits are undefined. 3737e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner ANY_EXTEND, 3747e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner 37563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // TRUNCATE - Completely drop the high bits. 37663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner TRUNCATE, 37763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3781645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign 3791645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // depends on the first letter) to floating point. 3801645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner SINT_TO_FP, 3811645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner UINT_TO_FP, 3821645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 383ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to 384ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // sign extend a small value in a large integer register (e.g. sign 385ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // extending the low 8 bits of a 32-bit register to fill the top 24 bits 38615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // with the 7th bit). The size of the smaller type is indicated by the 1th 38715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // operand, a ValueType node. 388859157daee6a4b49e99921832e1dde065167b317Chris Lattner SIGN_EXTEND_INREG, 389859157daee6a4b49e99921832e1dde065167b317Chris Lattner 3900bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned 3910bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// integer. 3921645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_SINT, 3931645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_UINT, 3941645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 3950bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type 3960bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// down to the precision of the destination VT. TRUNC is a flag, which is 3970bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// always an integer that is zero or one. If TRUNC is 0, this is a 3980bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// normal rounding, if it is 1, this FP_ROUND is known to not change the 3990bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// value of Y. 4000bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// 4010bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// The TRUNC = 1 case is used in cases where we know that the value will 4020bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// not be modified by the node, because Y is not using any of the extra 4030bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// precision of source type. This allows certain transformations like 4040bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for 4050bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed. 40663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_ROUND, 4070bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner 4081a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman // FLT_ROUNDS_ - Returns current rounding mode: 409917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // -1 Undefined 410917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 0 Round to 0 411917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 1 Round to nearest 412917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 2 Round to +inf 413917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 3 Round to -inf 4141a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman FLT_ROUNDS_, 415917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov 4160bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and 4170bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// rounds it to a floating point value. It then promotes it and returns it 4180bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// in a register of the same size. This operation effectively just 4190bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// discards excess precision. The type to round down to is specified by 4200bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// the VT operand, a VTSDNode. 421859157daee6a4b49e99921832e1dde065167b317Chris Lattner FP_ROUND_INREG, 422859157daee6a4b49e99921832e1dde065167b317Chris Lattner 4230bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type. 42463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_EXTEND, 42563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4261ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // BIT_CONVERT - Theis operator converts between integer and FP values, as 4271ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // if one was stored to memory as integer and the other was loaded from the 42880f55abf009c86bc03821e10746832f88f8a735fChris Lattner // same address (or equivalently for vector format conversions, etc). The 42980f55abf009c86bc03821e10746832f88f8a735fChris Lattner // source and result are required to have the same bit size (e.g. 43080f55abf009c86bc03821e10746832f88f8a735fChris Lattner // f32 <-> i32). This can also be used for int-to-int or fp-to-fp 43180f55abf009c86bc03821e10746832f88f8a735fChris Lattner // conversions, but that is a noop, deleted by getNode(). 4321ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner BIT_CONVERT, 4331ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner 43477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // CONVERT_RNDSAT - This operator is used to support various conversions 43500ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang // between various types (float, signed, unsigned and vectors of those 43600ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang // types) with rounding and saturation. NOTE: Avoid using this operator as 43700ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang // most target don't support it and the operator might be removed in the 43800ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang // future. It takes the following arguments: 43977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 0) value 44077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 1) dest type (type to convert to) 44177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 2) src type (type to convert from) 44277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 3) rounding imm 44377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 4) saturation imm 44477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 5) ISD::CvtCode indicating the type of conversion to do 44577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CONVERT_RNDSAT, 44677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 447509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, 4487794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen // FLOG, FLOG2, FLOG10, FEXP, FEXP2, 4498471ef5f4e79fbe4d7021e91d45e39fdbf8783fcDan Gohman // FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR - Perform various unary floating 450509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman // point operations. These are inspired by libm. 45107f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, 4527794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen FLOG, FLOG2, FLOG10, FEXP, FEXP2, 453509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR, 45438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 4558862ef148100070b7bf28beead3951464250c926Evan Cheng // LOAD and STORE have token chains as their first operand, then the same 4568862ef148100070b7bf28beead3951464250c926Evan Cheng // operands as an LLVM load/store instruction, then an offset node that 4578862ef148100070b7bf28beead3951464250c926Evan Cheng // is added / subtracted from the base pointer to form the address (for 4588862ef148100070b7bf28beead3951464250c926Evan Cheng // indexed memory ops). 45963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner LOAD, STORE, 460ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 46163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned 46257fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // to a specified boundary. This node always has two return values: a new 46357fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // stack pointer value and a chain. The first operand is the token chain, 46457fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // the second is the number of bytes to allocate, and the third is the 46557fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment boundary. The size is guaranteed to be a multiple of the stack 46657fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment, and the alignment is guaranteed to be bigger than the stack 46774fe063e90045931eefaba561730e6a9175ced78Chris Lattner // alignment (if required) or 0 to get standard stack alignment. 46863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner DYNAMIC_STACKALLOC, 46963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 47063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Control flow instructions. These all have token chains. 471ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 47263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BR - Unconditional branch. The first operand is the chain 47363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operand, the second is the MBB to branch to. 47463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BR, 47563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 47637efe6764568a3829fee26aba532283131d1a104Nate Begeman // BRIND - Indirect branch. The first operand is the chain, the second 47737efe6764568a3829fee26aba532283131d1a104Nate Begeman // is the value to branch to, which must be of the same type as the target's 47837efe6764568a3829fee26aba532283131d1a104Nate Begeman // pointer type. 47937efe6764568a3829fee26aba532283131d1a104Nate Begeman BRIND, 480c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng 481c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // BR_JT - Jumptable branch. The first operand is the chain, the second 482c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // is the jumptable index, the last one is the jumptable entry index. 483c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng BR_JT, 48447b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands 48547b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands // BRCOND - Conditional branch. The first operand is the chain, the 48647b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands // second is the condition, the third is the block to branch to if the 48747b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands // condition is true. If the type of the condition is not i1, then the 48847b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands // high bits must conform to getSetCCResultContents. 48963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BRCOND, 49063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4917cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in 4927cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // that the condition is represented as condition code, and two nodes to 4937cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // compare, rather than as a combined SetCC node. The operands in order are 4947cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // chain, cc, lhs, rhs, block to branch to if condition is true. 4957cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman BR_CC, 4967cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman 49763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // RET - Return from function. The first operand is the chain, 4988e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // and any subsequent operands are pairs of return value and return value 499c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen // attributes (see CALL for description of attributes) for the function. 500c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen // This operation can have variable number of operands. 50163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner RET, 50263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 5037572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // INLINEASM - Represents an inline asm block. This node always has two 5047572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // return values: a chain and a flag result. The inputs are as follows: 5057572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #0 : Input chain. 506056292fd738924f3f7703725d8f630983794b5a5Bill Wendling // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string. 5077572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+2: A RegisterNode. 5087572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def 5097572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #last: Optional, an incoming flag. 5107572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner INLINEASM, 5111ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey 5124406604047423576e36657c7ede266ca42e79642Dan Gohman // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track 5134406604047423576e36657c7ede266ca42e79642Dan Gohman // locations needed for debug and exception handling tables. These nodes 5144406604047423576e36657c7ede266ca42e79642Dan Gohman // take a chain as input and return a chain. 5154406604047423576e36657c7ede266ca42e79642Dan Gohman DBG_LABEL, 5164406604047423576e36657c7ede266ca42e79642Dan Gohman EH_LABEL, 517a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng 518a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track 519a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // local variable declarations for debugging information. First operand is 520a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // a chain, while the next two operands are first two arguments (address 521a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // and variable) of a llvm.dbg.declare instruction. 522a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng DECLARE, 523f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 5245a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a 5255a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // value, the same type as the pointer type for the system, and an output 5265a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // chain. 5275a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKSAVE, 5285a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 5295a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKRESTORE has two operands, an input chain and a pointer to restore to 5305a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // it returns an output chain. 5315a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKRESTORE, 5325a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 53316cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of 53416cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // a call sequence, and carry arbitrary information that target might want 53516cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // to know. The first operand is a chain, the rest are specified by the 53616cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // target and not touched by the DAG optimizers. 5370ea0356dff38dfd0420b8c0a2fdf2fae7898c024Dale Johannesen // CALLSEQ_START..CALLSEQ_END pairs may not be nested. 53816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_START, // Beginning of a call sequence 53916cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_END, // End of a call sequence 540acc398c195a697795bff3245943d104eb19192b9Nate Begeman 541acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAARG - VAARG has three operands: an input chain, a pointer, and a 542acc398c195a697795bff3245943d104eb19192b9Nate Begeman // SRCVALUE. It returns a pair of values: the vaarg value and a new chain. 543acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAARG, 544acc398c195a697795bff3245943d104eb19192b9Nate Begeman 545acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VACOPY - VACOPY has five operands: an input chain, a destination pointer, 546acc398c195a697795bff3245943d104eb19192b9Nate Begeman // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the 547acc398c195a697795bff3245943d104eb19192b9Nate Begeman // source. 548acc398c195a697795bff3245943d104eb19192b9Nate Begeman VACOPY, 549acc398c195a697795bff3245943d104eb19192b9Nate Begeman 550acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a 551acc398c195a697795bff3245943d104eb19192b9Nate Begeman // pointer, and a SRCVALUE. 552acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAEND, VASTART, 55363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 55469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // SRCVALUE - This is a node type that holds a Value* that is used to 55569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // make reference to a value in the LLVM IR. 55621074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner SRCVALUE, 55721074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner 55836b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // MEMOPERAND - This is a node that contains a MachineMemOperand which 55936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // records information about a memory reference. This is used to make 56036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // AliasAnalysis queries from the backend. 56169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman MEMOPERAND, 56269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 563e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman // PCMARKER - This corresponds to the pcmarker intrinsic. 56495762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth PCMARKER, 56563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 566aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic. 5678b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // The only operand is a chain and a value and a chain are produced. The 5688b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // value is the contents of the architecture specific cycle counter like 5698b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // register (or other high accuracy low latency clock source) 570aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth READCYCLECOUNTER, 571aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth 572d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner // HANDLENODE node - Used as a handle for various purposes. 573d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner HANDLENODE, 5742d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 5757f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman // DBG_STOPPOINT - This node is used to represent a source location for 5767f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman // debug info. It takes token chain as input, and carries a line number, 5777f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman // column number, and a pointer to a CompileUnitDesc object identifying 5787f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman // the containing compilation unit. It produces a token chain as output. 5797f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman DBG_STOPPOINT, 58047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner 581f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey // DEBUG_LOC - This node is used to represent source line information 582abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // embedded in the code. It takes a token chain as input, then a line 58344c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey // number, then a column then a file id (provided by MachineModuleInfo.) It 584abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // produces a token chain as output. 585f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey DEBUG_LOC, 58636397f50343639ce9a25996f2d790c656791ab92Duncan Sands 58736397f50343639ce9a25996f2d790c656791ab92Duncan Sands // TRAMPOLINE - This corresponds to the init_trampoline intrinsic. 58836397f50343639ce9a25996f2d790c656791ab92Duncan Sands // It takes as input a token chain, the pointer to the trampoline, 58936397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the pointer to the nested function, the pointer to pass for the 59036397f50343639ce9a25996f2d790c656791ab92Duncan Sands // 'nest' parameter, a SRCVALUE for the trampoline and another for 59136397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the nested function (allowing targets to access the original 592f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // Function*). It produces the result of the intrinsic and a token 593f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // chain as output. 59436397f50343639ce9a25996f2d790c656791ab92Duncan Sands TRAMPOLINE, 59536397f50343639ce9a25996f2d790c656791ab92Duncan Sands 59666fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov // TRAP - Trapping instruction 59766fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov TRAP, 59866fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov 59927b7db549e4c5bff4579d209304de5628513edebEvan Cheng // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are 60027b7db549e4c5bff4579d209304de5628513edebEvan Cheng // their first operand. The other operands are the address to prefetch, 60127b7db549e4c5bff4579d209304de5628513edebEvan Cheng // read / write specifier, and locality specifier. 60227b7db549e4c5bff4579d209304de5628513edebEvan Cheng PREFETCH, 60327b7db549e4c5bff4579d209304de5628513edebEvan Cheng 60422c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load, 60522c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // store-store, device) 606ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // This corresponds to the memory.barrier intrinsic. 60722c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // it takes an input chain, 4 operands to specify the type of barrier, an 60822c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // operand specifying if the barrier applies to device and uncached memory 60922c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // and produces an output chain. 61022c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth MEMBARRIER, 61122c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth 61228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) 613ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.lcs intrinsic. 614ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // cmp is compared to *ptr, and if equal, swap is stored in *ptr. 615ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 616e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_CMP_SWAP_8, 617e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_CMP_SWAP_16, 618e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_CMP_SWAP_32, 619e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_CMP_SWAP_64, 620ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 621ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) 622ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.swap intrinsic. 623ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // amt is stored to *ptr atomically. 624ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 625e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_SWAP_8, 626e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_SWAP_16, 627e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_SWAP_32, 628e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_SWAP_64, 629ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 63063307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // Val, OUTCHAIN = ATOMIC_L[OpName]S(INCHAIN, ptr, amt) 63163307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // this corresponds to the atomic.[OpName] intrinsic. 63263307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // op(*ptr, amt) is stored to *ptr atomically. 63363307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // the return is always the original value in *ptr 634e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_ADD_8, 635e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_SUB_8, 636e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_AND_8, 637e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_OR_8, 638e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_XOR_8, 639e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_NAND_8, 640e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_MIN_8, 641e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_MAX_8, 642e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_UMIN_8, 643e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_UMAX_8, 644e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_ADD_16, 645e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_SUB_16, 646e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_AND_16, 647e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_OR_16, 648e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_XOR_16, 649e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_NAND_16, 650e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_MIN_16, 651e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_MAX_16, 652e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_UMIN_16, 653e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_UMAX_16, 654e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_ADD_32, 655e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_SUB_32, 656e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_AND_32, 657e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_OR_32, 658e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_XOR_32, 659e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_NAND_32, 660e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_MIN_32, 661e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_MAX_32, 662e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_UMIN_32, 663e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_UMAX_32, 664e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_ADD_64, 665e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_SUB_64, 666e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_AND_64, 667e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_OR_64, 668e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_XOR_64, 669e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_NAND_64, 670e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_MIN_64, 671e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_MAX_64, 672e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_UMIN_64, 673e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen ATOMIC_LOAD_UMAX_64, 67463307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang 67563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILTIN_OP_END - This must be the last enum value in this list. 676410354fe0c052141dadeca939395743f8dd58e38Chris Lattner BUILTIN_OP_END 67763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 67863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 679322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// Node predicates 680322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 681a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng /// isBuildVectorAllOnes - Return true if the specified node is a 682322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// BUILD_VECTOR where all of the elements are ~0 or undef. 683a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng bool isBuildVectorAllOnes(const SDNode *N); 6844a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng 6854a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// isBuildVectorAllZeros - Return true if the specified node is a 6864a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// BUILD_VECTOR where all of the elements are 0 or undef. 6874a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng bool isBuildVectorAllZeros(const SDNode *N); 688bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng 689efec751a1b786724862ceff52748df94873a807eEvan Cheng /// isScalarToVector - Return true if the specified node is a 690efec751a1b786724862ceff52748df94873a807eEvan Cheng /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low 691efec751a1b786724862ceff52748df94873a807eEvan Cheng /// element is not an undef. 692efec751a1b786724862ceff52748df94873a807eEvan Cheng bool isScalarToVector(const SDNode *N); 693efec751a1b786724862ceff52748df94873a807eEvan Cheng 694bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// isDebugLabel - Return true if the specified node represents a debug 6954406604047423576e36657c7ede266ca42e79642Dan Gohman /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node). 696bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng bool isDebugLabel(const SDNode *N); 697322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 69863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 699144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// MemIndexedMode enum - This enum defines the load / store indexed 700144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// addressing modes. 70124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 70224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// UNINDEXED "Normal" load / store. The effective address is already 70324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computed and is available in the base pointer. The offset 70481c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// operand is always undefined. In addition to producing a 70581c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// chain, an unindexed load produces one value (result of the 706276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// load); an unindexed store does not produce a value. 70724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 70835acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// PRE_INC Similar to the unindexed mode where the effective address is 7098862ef148100070b7bf28beead3951464250c926Evan Cheng /// PRE_DEC the value of the base pointer add / subtract the offset. 7108862ef148100070b7bf28beead3951464250c926Evan Cheng /// It considers the computation as being folded into the load / 71124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// store operation (i.e. the load / store does the address 71224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computation as well as performing the memory transaction). 71381c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// The base operand is always undefined. In addition to 71481c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// producing a chain, pre-indexed load produces two values 71581c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// (result of the load and the result of the address 71681c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// computation); a pre-indexed store produces one value (result 71781c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// of the address computation). 71824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 71935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// POST_INC The effective address is the value of the base pointer. The 7208862ef148100070b7bf28beead3951464250c926Evan Cheng /// POST_DEC value of the offset operand is then added to / subtracted 7218862ef148100070b7bf28beead3951464250c926Evan Cheng /// from the base after memory transaction. In addition to 7228862ef148100070b7bf28beead3951464250c926Evan Cheng /// producing a chain, post-indexed load produces two values 7238862ef148100070b7bf28beead3951464250c926Evan Cheng /// (the result of the load and the result of the base +/- offset 7248862ef148100070b7bf28beead3951464250c926Evan Cheng /// computation); a post-indexed store produces one value (the 7258862ef148100070b7bf28beead3951464250c926Evan Cheng /// the result of the base +/- offset computation). 72624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 727144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng enum MemIndexedMode { 72824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng UNINDEXED = 0, 72935acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_INC, 73035acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_DEC, 73135acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng POST_INC, 732144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng POST_DEC, 733144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng LAST_INDEXED_MODE 73424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng }; 73524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 73624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng //===--------------------------------------------------------------------===// 737c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// LoadExtType enum - This enum defines the three variants of LOADEXT 738c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// (load with extension). 739c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 74024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// SEXTLOAD loads the integer operand and sign extends it to a larger 74124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 74224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// ZEXTLOAD loads the integer operand and zero extends it to a larger 74324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 74424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// EXTLOAD is used for three things: floating point extending loads, 74524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer extending loads [the top bits are undefined], and vector 74624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// extending loads [load into low elt]. 74724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 748c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng enum LoadExtType { 74924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng NON_EXTLOAD = 0, 750c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng EXTLOAD, 751c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng SEXTLOAD, 752c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng ZEXTLOAD, 7530329466b6b4927f4e6f5d144891fef06a027fec5Evan Cheng LAST_LOADEXT_TYPE 754c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng }; 755c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 756c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng //===--------------------------------------------------------------------===// 75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::CondCode enum - These are ordered carefully to make the bitfields 75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// below work out, when considering SETFALSE (something that never exists 75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered 76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal 76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to. If the "N" column is 1, the result of the comparison is undefined if 76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the input is a NAN. 76363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 76463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// All of these (except for the 'always folded ops') should be handled for 76563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT, 76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used. 76763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 76863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Note that these are laid out in a specific order to allow bit-twiddling 76963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to transform conditions. 77063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum CondCode { 77163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Opcode N U L G E Intuitive operation 77263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE, // 0 0 0 0 Always false (always folded) 77363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOEQ, // 0 0 0 1 True if ordered and equal 77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGT, // 0 0 1 0 True if ordered and greater than 77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGE, // 0 0 1 1 True if ordered and greater than or equal 77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLT, // 0 1 0 0 True if ordered and less than 77763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLE, // 0 1 0 1 True if ordered and less than or equal 77863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETONE, // 0 1 1 0 True if ordered and operands are unequal 77963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETO, // 0 1 1 1 True if ordered (no nans) 78063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUEQ, // 1 0 0 1 True if unordered or equal 78263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGT, // 1 0 1 0 True if unordered or greater than 78363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGE, // 1 0 1 1 True if unordered, greater than, or equal 78463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETULT, // 1 1 0 0 True if unordered or less than 785ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETULE, // 1 1 0 1 True if unordered, less than, or equal 78663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUNE, // 1 1 1 0 True if unordered or not equal 78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE, // 1 1 1 1 Always true (always folded) 78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Don't care operations: undefined if the input is a nan. 78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE2, // 1 X 0 0 0 Always false (always folded) 79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETEQ, // 1 X 0 0 1 True if equal 79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGT, // 1 X 0 1 0 True if greater than 79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGE, // 1 X 0 1 1 True if greater than or equal 79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETLT, // 1 X 1 0 0 True if less than 794ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETLE, // 1 X 1 0 1 True if less than or equal 79563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETNE, // 1 X 1 1 0 True if not equal 79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE2, // 1 X 1 1 1 Always true (always folded) 79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 798410354fe0c052141dadeca939395743f8dd58e38Chris Lattner SETCC_INVALID // Marker value. 79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 80163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isSignedIntSetCC - Return true if this is a setcc instruction that 80263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs a signed comparison when used with integer operands. 80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isSignedIntSetCC(CondCode Code) { 80463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE; 80563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 80663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 80763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isUnsignedIntSetCC - Return true if this is a setcc instruction that 80863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs an unsigned comparison when used with integer operands. 80963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isUnsignedIntSetCC(CondCode Code) { 81063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE; 81163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 81263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 81363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isTrueWhenEqual - Return true if the specified condition returns true if 81463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the two operands to the condition are equal. Note that if one of the two 81563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operands is a NaN, this value is meaningless. 81663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isTrueWhenEqual(CondCode Cond) { 81763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond & 1) != 0; 81863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 81963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 82063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getUnorderedFlavor - This function returns 0 if the condition is always 82163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// false if an operand is a NaN, 1 if the condition is always true if the 82263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operand is a NaN, and 2 if the condition is undefined if the operand is a 82363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// NaN. 82463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getUnorderedFlavor(CondCode Cond) { 82563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond >> 3) & 3; 82663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 82763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 82863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCInverse - Return the operation corresponding to !(X op Y), where 82963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 'op' is a valid SetCC operation. 83063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCInverse(CondCode Operation, bool isInteger); 83163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 83263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) 83363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// when given the operation for (X op Y). 83463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCSwappedOperands(CondCode Operation); 83563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 83663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCOrOperation - Return the result of a logical OR between different 83763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This 83863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 83963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 84063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger); 84163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 84263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCAndOperation - Return the result of a logical AND between 84363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This 84463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 84563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 84663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger); 84777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 84877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang //===--------------------------------------------------------------------===// 84977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang /// CvtCode enum - This enum defines the various converts CONVERT_RNDSAT 85077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang /// supports. 85177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang enum CvtCode { 85277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_FF, // Float from Float 85377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_FS, // Float from Signed 85477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_FU, // Float from Unsigned 85577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_SF, // Signed from Float 85677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_UF, // Unsigned from Float 85777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_SS, // Signed from Signed 85877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_SU, // Signed from Unsigned 85977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_US, // Unsigned from Signed 86077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_UU, // Unsigned from Unsigned 86177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_INVALID // Marker - Invalid opcode 86277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang }; 86363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm::ISD namespace 86463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 86563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 86663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===// 867475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple 86863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation. Many nodes return multiple values, 86963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns 87063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number 87163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values). 87263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 87363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that 87463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node. This pair 875475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// of information is represented with the SDValue value type. 87663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 877475871a144eb604ddaf37503397ba0941442e5fbDan Gohmanclass SDValue { 878ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDNode *Node; // The node defining the value we are using. 87963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned ResNo; // Which return value of the node we are using. 88099a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greifpublic: 881ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDValue() : Node(0), ResNo(0) {} 882ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {} 88363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 88499a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif /// get the index which selects a specific result in the SDNode 88599a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif unsigned getResNo() const { return ResNo; } 88699a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif 887ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif /// get the SDNode which holds the desired result 888ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDNode *getNode() const { return Node; } 889ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif 890ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif /// set the SDNode 891ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif void setNode(SDNode *N) { Node = N; } 892ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif 893475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator==(const SDValue &O) const { 894ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node == O.Node && ResNo == O.ResNo; 89563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 896475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator!=(const SDValue &O) const { 89763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return !operator==(O); 89863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 899475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator<(const SDValue &O) const { 900ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node < O.Node || (Node == O.Node && ResNo < O.ResNo); 90163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 90263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 903475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getValue(unsigned R) const { 904ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return SDValue(Node, R); 90563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 90663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 907917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng // isOperandOf - Return true if this node is an operand of N. 908917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOperandOf(SDNode *N) const; 909bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng 91063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the ValueType of the referenced return value. 91163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 91283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands inline MVT getValueType() const; 913ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 91483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands /// getValueSizeInBits - Returns the size of the value in bits. 9154fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// 9164fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman unsigned getValueSizeInBits() const { 91783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands return getValueType().getSizeInBits(); 9184fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman } 9194fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman 92063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Forwarding methods - These forward to the corresponding methods in SDNode. 92163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getOpcode() const; 92263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getNumOperands() const; 923475871a144eb604ddaf37503397ba0941442e5fbDan Gohman inline const SDValue &getOperand(unsigned i) const; 924c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline uint64_t getConstantOperandVal(unsigned i) const; 9250f66a9172175aa7c3055333358170581c999219bNate Begeman inline bool isTargetOpcode() const; 926e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman inline bool isMachineOpcode() const; 927e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman inline unsigned getMachineOpcode() const; 928a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner 929572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 930572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// reachesChainWithoutSideEffects - Return true if this operand (which must 931572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// be a chain) reaches the specified operand without crossing any 932572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// side-effecting instructions. In practice, this looks through token 933572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// factors and non-volatile loads. In order to remain efficient, this only 934572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// looks a couple of nodes in, it does not do an exhaustive search. 935475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool reachesChainWithoutSideEffects(SDValue Dest, 936dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein unsigned Depth = 2) const; 937572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 9387a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// use_empty - Return true if there are no nodes using value ResNo 939ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif /// of Node. 9407a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 941e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman inline bool use_empty() const; 9427a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman 943231fe7054160d2953e0cc6635f9a171a4b311af2Gabor Greif /// hasOneUse - Return true if there is exactly one node using value 944ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif /// ResNo of Node. 9457a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 9467a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman inline bool hasOneUse() const; 94763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 94863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 94963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 950475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct DenseMapInfo<SDValue> { 951475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static inline SDValue getEmptyKey() { 952475871a144eb604ddaf37503397ba0941442e5fbDan Gohman return SDValue((SDNode*)-1, -1U); 953dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 954475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static inline SDValue getTombstoneKey() { 955475871a144eb604ddaf37503397ba0941442e5fbDan Gohman return SDValue((SDNode*)-1, 0); 956dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 957475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static unsigned getHashValue(const SDValue &Val) { 958ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^ 959ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo(); 960c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng } 961475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static bool isEqual(const SDValue &LHS, const SDValue &RHS) { 96276c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner return LHS == RHS; 96376c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner } 964c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static bool isPod() { return true; } 965c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng}; 966c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng 96763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on 968475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s. 969475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<SDValue> { 970dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein typedef SDNode* SimpleType; 971475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static SimpleType getSimplifiedValue(const SDValue &Val) { 972ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return static_cast<SimpleType>(Val.getNode()); 973dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 974dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 975475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<const SDValue> { 976dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein typedef SDNode* SimpleType; 977475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static SimpleType getSimplifiedValue(const SDValue &Val) { 978ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return static_cast<SimpleType>(Val.getNode()); 979dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 980dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 981dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 9829cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// SDUse - Represents a use of the SDNode referred by 983475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// the SDValue. 9849cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDUse { 985475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Operand; 98602819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein /// User - Parent node of this operand. 98702819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein SDNode *User; 988dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// Prev, next - Pointers to the uses list of the SDNode referred by 989dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// this operand. 9909cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse **Prev, *Next; 991dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinpublic: 992dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein friend class SDNode; 99302819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein SDUse(): Operand(), User(NULL), Prev(NULL), Next(NULL) {} 994dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 9959cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse(SDNode *val, unsigned resno) : 99602819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein Operand(val,resno), User(NULL), Prev(NULL), Next(NULL) {} 997dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 998475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDUse& operator= (const SDValue& Op) { 9999cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Operand = Op; 1000dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Next = NULL; 1001dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Prev = NULL; 1002dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return *this; 1003dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1004dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 10059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse& operator= (const SDUse& Op) { 10069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Operand = Op; 1007dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Next = NULL; 1008dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Prev = NULL; 1009dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return *this; 1010dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1011dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 10128968450305c28444edc3c272d8752a8db0c2f34aDan Gohman SDUse *getNext() { return Next; } 1013dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 101402819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein SDNode *getUser() { return User; } 10159cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 101602819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein void setUser(SDNode *p) { User = p; } 1017dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1018475871a144eb604ddaf37503397ba0941442e5fbDan Gohman operator SDValue() const { return Operand; } 10199cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1020475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue& getSDValue() const { return Operand; } 10219cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1022ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDValue &getSDValue() { return Operand; } 1023ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDNode *getVal() { return Operand.getNode(); } 1024ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDNode *getVal() const { return Operand.getNode(); } // FIXME: const correct? 10259cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1026475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator==(const SDValue &O) const { 10279cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return Operand == O; 10289cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10299cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1030475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator!=(const SDValue &O) const { 10319cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return !(Operand == O); 10329cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10339cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1034475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator<(const SDValue &O) const { 10359cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return Operand < O; 10369cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10379cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1038dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprotected: 10399cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein void addToList(SDUse **List) { 1040dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Next = *List; 1041dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein if (Next) Next->Prev = &Next; 1042dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Prev = List; 1043dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein *List = this; 1044dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1045dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1046dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein void removeFromList() { 1047dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein *Prev = Next; 1048dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein if (Next) Next->Prev = Prev; 1049dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1050dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 1051dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1052dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1053dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein/// simplify_type specializations - Allow casting operators to work directly on 1054475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s. 10559cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<SDUse> { 105663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 10579cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static SimpleType getSimplifiedValue(const SDUse &Val) { 1058475871a144eb604ddaf37503397ba0941442e5fbDan Gohman return static_cast<SimpleType>(Val.getVal()); 105963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 106063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 10619cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<const SDUse> { 106263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 10639cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static SimpleType getSimplifiedValue(const SDUse &Val) { 1064475871a144eb604ddaf37503397ba0941442e5fbDan Gohman return static_cast<SimpleType>(Val.getVal()); 106563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 106663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 106763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 106863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1069475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDOperandPtr - A helper SDValue pointer class, that can handle 1070475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// arrays of SDUse and arrays of SDValue objects. This is required 10719cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// in many places inside the SelectionDAG. 10729cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein/// 10739cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDOperandPtr { 1074475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *ptr; // The pointer to the SDValue object 1075475871a144eb604ddaf37503397ba0941442e5fbDan Gohman int object_size; // The size of the object containg the SDValue 10769cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinpublic: 107735b31bea0dc9e16d4c384a6a78404bdd791b6693Dan Gohman SDOperandPtr() : ptr(0), object_size(0) {} 107835b31bea0dc9e16d4c384a6a78404bdd791b6693Dan Gohman 10799cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr(SDUse * use_ptr) { 1080475871a144eb604ddaf37503397ba0941442e5fbDan Gohman ptr = &use_ptr->getSDValue(); 108134cd4a484e532cc463fd5a4bf59b88d13c5467c1Evan Cheng object_size = (int)sizeof(SDUse); 10829cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10839cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1084475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDOperandPtr(const SDValue * op_ptr) { 10859cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ptr = op_ptr; 1086475871a144eb604ddaf37503397ba0941442e5fbDan Gohman object_size = (int)sizeof(SDValue); 10879cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10889cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1089475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue operator *() { return *ptr; } 1090475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *operator ->() { return ptr; } 10919cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr operator ++ () { 1092475871a144eb604ddaf37503397ba0941442e5fbDan Gohman ptr = (SDValue*)((char *)ptr + object_size); 10939cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return *this; 10949cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10959cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 10969cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr operator ++ (int) { 10979cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDOperandPtr tmp = *this; 1098475871a144eb604ddaf37503397ba0941442e5fbDan Gohman ptr = (SDValue*)((char *)ptr + object_size); 10999cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein return tmp; 11009cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 11019cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1102475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue operator[] (int idx) const { 1103475871a144eb604ddaf37503397ba0941442e5fbDan Gohman return *(SDValue*)((char*) ptr + object_size * idx); 11049cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 11059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein}; 11069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 110763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG. 110863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 1109fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass SDNode : public FoldingSetNode, public ilist_node<SDNode> { 1110dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprivate: 11110442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// NodeType - The operation that this node performs. 11120442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 1113e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman short NodeType; 111463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 111563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true, 111663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// then they will be delete[]'d when the node is destroyed. 1117ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman unsigned short OperandsNeedDelete : 1; 11180442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 1119ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprotected: 1120ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// SubclassData - This member is defined by this class, but is not used for 1121ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// anything. Subclasses can use it to hold whatever state they find useful. 1122ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// This field is initialized to zero by the ctor. 1123ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman unsigned short SubclassData : 15; 1124ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman 1125ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprivate: 1126b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// NodeId - Unique id per SDNode in the DAG. 1127b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int NodeId; 11280442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 1129f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// OperandList - The values that are used by this operation. 11300442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 11319cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *OperandList; 1132f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 1133f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// ValueList - The types of the values this node defines. SDNode's may 1134f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// define multiple values simultaneously. 113583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *ValueList; 113663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1137f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// NumOperands/NumValues - The number of entries in the Operand/Value list. 1138f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned short NumOperands, NumValues; 1139b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1140dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// Uses - List of uses for this SDNode. 11419cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *Uses; 1142dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 11439cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein /// addUse - add SDUse to the list of uses. 11449cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein void addUse(SDUse &U) { U.addToList(&Uses); } 1145dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1146917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner // Out-of-line virtual method to give class a home. 1147917d2c9dc2cc8879ed97533e7f75f3f92fa26b61Chris Lattner virtual void ANCHOR(); 114863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 1149b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner virtual ~SDNode() { 1150b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner assert(NumOperands == 0 && "Operand list not cleared before deletion"); 11513258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner NodeType = ISD::DELETED_NODE; 1152b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner } 1153b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 115463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 115563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Accessors 115663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // 1157e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 1158e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// getOpcode - Return the SelectionDAG opcode value for this node. For 1159e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// pre-isel nodes (those for which isMachineOpcode returns false), these 1160e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// are the opcode values in the ISD and <target>ISD namespaces. For 1161e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// post-isel opcodes, see getMachineOpcode. 1162e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman unsigned getOpcode() const { return (unsigned short)NodeType; } 1163e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 1164e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// isTargetOpcode - Test if this node has a target-specific opcode (in the 1165e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// <target>ISD namespace). 11660f66a9172175aa7c3055333358170581c999219bNate Begeman bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } 1167e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 1168e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// isMachineOpcode - Test if this node has a post-isel opcode, directly 1169e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// corresponding to a MachineInstr opcode. 1170e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman bool isMachineOpcode() const { return NodeType < 0; } 1171e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 1172e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// getMachineOpcode - This may only be called if isMachineOpcode returns 1173e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// true. It returns the MachineInstr opcode value that the node's opcode 1174e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// corresponds to. 1175e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman unsigned getMachineOpcode() const { 1176ec89a364b86ccd943fc6cf3ad8f84825ba1550fdDan Gohman assert(isMachineOpcode() && "Not a MachineInstr opcode!"); 1177e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman return ~NodeType; 11780f66a9172175aa7c3055333358170581c999219bNate Begeman } 117963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 11806da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman /// use_empty - Return true if there are no uses of this node. 11817a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 1182dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool use_empty() const { return Uses == NULL; } 11837a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman 11846da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman /// hasOneUse - Return true if there is exactly one use of this node. 11857a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 1186b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman bool hasOneUse() const { 1187b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman return !use_empty() && next(use_begin()) == use_end(); 1188b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman } 118963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 11906da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman /// use_size - Return the number of uses of this node. This method takes 11917a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// time proportional to the number of uses. 11927a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 11937a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman size_t use_size() const { return std::distance(use_begin(), use_end()); } 11947a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman 1195b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// getNodeId - Return the unique node id. 1196b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// 1197b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int getNodeId() const { return NodeId; } 11980442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 11992e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng /// setNodeId - Set unique node id. 12002e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng void setNodeId(int Id) { NodeId = Id; } 12012e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng 12029cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein /// use_iterator - This class provides iterator support for SDUse 1203dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// operands that use a specific SDNode. 1204dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein class use_iterator 12059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : public forward_iterator<SDUse, ptrdiff_t> { 12069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *Op; 12079cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein explicit use_iterator(SDUse *op) : Op(op) { 1208dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1209dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein friend class SDNode; 1210dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein public: 12119cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef forward_iterator<SDUse, ptrdiff_t>::reference reference; 12129cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer; 1213dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1214dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator(const use_iterator &I) : Op(I.Op) {} 1215dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator() : Op(0) {} 1216dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1217dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool operator==(const use_iterator &x) const { 1218dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return Op == x.Op; 1219dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1220dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool operator!=(const use_iterator &x) const { 1221dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return !operator==(x); 1222dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1223dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1224dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// atEnd - return true if this iterator is at the end of uses list. 1225dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool atEnd() const { return Op == 0; } 1226dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1227dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein // Iterator traversal: forward iteration only. 1228dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator &operator++() { // Preincrement 1229dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot increment end iterator!"); 1230dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Op = Op->getNext(); 1231dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return *this; 1232dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1233dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1234dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator operator++(int) { // Postincrement 1235dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator tmp = *this; ++*this; return tmp; 1236dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1237dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 12388968450305c28444edc3c272d8752a8db0c2f34aDan Gohman /// Retrieve a pointer to the current user node. 12398968450305c28444edc3c272d8752a8db0c2f34aDan Gohman SDNode *operator*() const { 1240dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot dereference end iterator!"); 12418968450305c28444edc3c272d8752a8db0c2f34aDan Gohman return Op->getUser(); 1242dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1243dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 12448968450305c28444edc3c272d8752a8db0c2f34aDan Gohman SDNode *operator->() const { return operator*(); } 12458968450305c28444edc3c272d8752a8db0c2f34aDan Gohman 12468968450305c28444edc3c272d8752a8db0c2f34aDan Gohman SDUse &getUse() const { return *Op; } 1247dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 12488968450305c28444edc3c272d8752a8db0c2f34aDan Gohman /// getOperandNo - Retrive the operand # of this use in its user. 12498968450305c28444edc3c272d8752a8db0c2f34aDan Gohman /// 12508968450305c28444edc3c272d8752a8db0c2f34aDan Gohman unsigned getOperandNo() const { 1251dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot dereference end iterator!"); 12528968450305c28444edc3c272d8752a8db0c2f34aDan Gohman return (unsigned)(Op - Op->getUser()->OperandList); 1253dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1254dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein }; 1255dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1256dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// use_begin/use_end - Provide iteration support to walk over all uses 1257dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// of an SDNode. 1258dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1259dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator use_begin() const { 1260dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return use_iterator(Uses); 1261dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1262dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1263dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein static use_iterator use_end() { return use_iterator(0); } 1264dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 12657ece380440238ad0630a225b85a09a2dbed1165aChris Lattner 1266b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the 1267b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// indicated value. This method ignores uses of other values defined by this 1268b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// operation. 12694ee621125876cc954cba5280dd9395552755a871Evan Cheng bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; 12704ee621125876cc954cba5280dd9395552755a871Evan Cheng 127133d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// hasAnyUseOfValue - Return true if there are any use of the indicated 127233d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// value. This method ignores uses of other values defined by this operation. 127333d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng bool hasAnyUseOfValue(unsigned Value) const; 127433d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng 12752a6299543fa22f389158409e897fe7099fda3812Dan Gohman /// isOnlyUserOf - Return true if this node is the only use of N. 1276e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 12772a6299543fa22f389158409e897fe7099fda3812Dan Gohman bool isOnlyUserOf(SDNode *N) const; 1278b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner 1279917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isOperandOf - Return true if this node is an operand of N. 1280e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 1281917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOperandOf(SDNode *N) const; 128280d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng 1283917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isPredecessorOf - Return true if this node is a predecessor of N. This 1284917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// node is either an operand of N or it can be reached by recursively 1285917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// traversing up the operands. 1286e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// NOTE: this is an expensive method. Use it carefully. 1287917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isPredecessorOf(SDNode *N) const; 12887ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng 128963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumOperands - Return the number of values used by this operation. 129063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 1291f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumOperands() const { return NumOperands; } 129263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1293c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// getConstantOperandVal - Helper method returns the integer value of a 1294c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// ConstantSDNode operand. 1295c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng uint64_t getConstantOperandVal(unsigned Num) const; 1296c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1297475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOperand(unsigned Num) const { 1298f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(Num < NumOperands && "Invalid child # of SDNode!"); 1299475871a144eb604ddaf37503397ba0941442e5fbDan Gohman return OperandList[Num].getSDValue(); 130063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 1301c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 13029cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef SDUse* op_iterator; 1303f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_begin() const { return OperandList; } 1304f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_end() const { return OperandList+NumOperands; } 130550f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner 130663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13070b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList getVTList() const { 13080b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList X = { ValueList, NumValues }; 13090b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner return X; 13100b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner }; 13110b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 131263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumValues - Return the number of values defined/returned by this 131363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operator. 131463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 1315f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumValues() const { return NumValues; } 131663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 131763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the type of a specified result. 131863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 131983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getValueType(unsigned ResNo) const { 1320f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(ResNo < NumValues && "Illegal result number!"); 1321f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return ValueList[ResNo]; 132263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 13239eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen 13244fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)). 13254fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// 13264fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman unsigned getValueSizeInBits(unsigned ResNo) const { 132783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands return getValueType(ResNo).getSizeInBits(); 13284fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman } 13294fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman 133083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands typedef const MVT* value_iterator; 1331f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_begin() const { return ValueList; } 1332f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_end() const { return ValueList+NumValues; } 133363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13346e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// getOperationName - Return the opcode of this operation for printing. 13356e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// 1336ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer std::string getOperationName(const SelectionDAG *G = 0) const; 1337144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng static const char* getIndexedModeName(ISD::MemIndexedMode AM); 1338944fac71e082cc2664cc71b4d3f6c72bab7143fbChris Lattner void print(raw_ostream &OS, const SelectionDAG *G = 0) const; 133963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner void dump() const; 1340efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner void dump(const SelectionDAG *G) const; 134163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 134263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *) { return true; } 134363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1344583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// Profile - Gather unique data for the node. 1345583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// 1346b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman void Profile(FoldingSetNodeID &ID) const; 1347583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey 134863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 134963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 13508e4018e2de52c534405d7155c7009d0b35afb861Cedric Venet friend struct ilist_traits<SDNode>; 1351109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner 1352109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// getValueTypeList - Return a pointer to the specified value type. 1353109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// 135483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands static const MVT *getValueTypeList(MVT VT); 135583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands static SDVTList getSDVTList(MVT VT) { 135663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner SDVTList Ret = { getValueTypeList(VT), 1 }; 135763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner return Ret; 13582d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 135963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 1360475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps) 1361ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0), 1362ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman NodeId(-1), Uses(NULL) { 1363f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner NumOperands = NumOps; 13649cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList = NumOps ? new SDUse[NumOperands] : 0; 13659cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 13669cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein for (unsigned i = 0; i != NumOps; ++i) { 13679cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList[i] = Ops[i]; 13689cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList[i].setUser(this); 1369ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif Ops[i].getNode()->addUse(OperandList[i]); 13709cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 13719cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 13729cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein ValueList = VTs.VTs; 13739cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein NumValues = VTs.NumVTs; 13749cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 13759cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 13766d9cdd56173fb915a9e3a8f0f6b5a8ed9bed1098Dan Gohman SDNode(unsigned Opc, SDVTList VTs, const SDUse *Ops, unsigned NumOps) 1377ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0), 1378ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman NodeId(-1), Uses(NULL) { 13799cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandsNeedDelete = true; 13809cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein NumOperands = NumOps; 13819cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList = NumOps ? new SDUse[NumOperands] : 0; 1382f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 1383bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner for (unsigned i = 0; i != NumOps; ++i) { 1384f06f35e30b4c4d7db304f717a3d4dc6595fbd078Chris Lattner OperandList[i] = Ops[i]; 1385dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein OperandList[i].setUser(this); 1386475871a144eb604ddaf37503397ba0941442e5fbDan Gohman Ops[i].getVal()->addUse(OperandList[i]); 13870442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner } 1388bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1389ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner ValueList = VTs.VTs; 1390ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner NumValues = VTs.NumVTs; 1391f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner } 1392dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1393ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// This constructor adds no operands itself; operands can be 1394ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// set later with InitOperands. 1395dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein SDNode(unsigned Opc, SDVTList VTs) 1396ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0), 1397ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman NodeId(-1), Uses(NULL) { 1398bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = 0; 1399bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = 0; 1400bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner ValueList = VTs.VTs; 1401bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumValues = VTs.NumVTs; 1402bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 1403bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1404bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// InitOperands - Initialize the operands list of this node with the 1405bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// specified values, which are part of the node (thus they don't need to be 1406bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner /// copied in or allocated). 14079cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein void InitOperands(SDUse *Ops, unsigned NumOps) { 1408bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner assert(OperandList == 0 && "Operands already set!"); 1409bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner NumOperands = NumOps; 1410bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = Ops; 1411dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Uses = NULL; 1412bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1413dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein for (unsigned i = 0; i != NumOps; ++i) { 1414dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein OperandList[i].setUser(this); 14159cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Ops[i].getVal()->addUse(OperandList[i]); 1416dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1417bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 14180fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman 14190fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman /// DropOperands - Release the operands and set this node to have 1420e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// zero operands. 14210fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman void DropOperands(); 1422bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1423dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein void addUser(unsigned i, SDNode *User) { 1424dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(User->OperandList[i].getUser() && "Node without parent"); 1425dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein addUse(User->OperandList[i]); 14261b95095857b78e12138c22e76c7936611c51355bChris Lattner } 1427dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1428dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein void removeUser(unsigned i, SDNode *User) { 1429dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(User->OperandList[i].getUser() && "Node without parent"); 14309cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse &Op = User->OperandList[i]; 1431dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Op.removeFromList(); 1432d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner } 143363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 143463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 143563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1436475871a144eb604ddaf37503397ba0941442e5fbDan Gohman// Define inline functions from the SDValue class. 143763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1438475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getOpcode() const { 1439ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOpcode(); 144063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1441475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline MVT SDValue::getValueType() const { 1442ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getValueType(ResNo); 144363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1444475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getNumOperands() const { 1445ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getNumOperands(); 144663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1447475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline const SDValue &SDValue::getOperand(unsigned i) const { 1448ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOperand(i); 144963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1450475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline uint64_t SDValue::getConstantOperandVal(unsigned i) const { 1451ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getConstantOperandVal(i); 1452c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 1453475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isTargetOpcode() const { 1454ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->isTargetOpcode(); 14550f66a9172175aa7c3055333358170581c999219bNate Begeman} 1456475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isMachineOpcode() const { 1457ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->isMachineOpcode(); 1458e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman} 1459475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getMachineOpcode() const { 1460ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getMachineOpcode(); 14610f66a9172175aa7c3055333358170581c999219bNate Begeman} 1462475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::use_empty() const { 1463ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return !Node->hasAnyUseOfValue(ResNo); 1464e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman} 1465475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::hasOneUse() const { 1466ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->hasNUsesOfValue(1, ResNo); 14677a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman} 146863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 14693f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes. This is solely 14703f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 14713f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode { 14723f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 14739cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Op; 14743f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 1475475871a144eb604ddaf37503397ba0941442e5fbDan Gohman UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X) 14769cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : SDNode(Opc, VTs) { 14779cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Op = X; 14783f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(&Op, 1); 14793f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 14803f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 14813f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 14823f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes. This is solely 14833f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 14843f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode { 14853f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 14869cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[2]; 14873f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 1488475871a144eb604ddaf37503397ba0941442e5fbDan Gohman BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y) 14893f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 14903f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 14913f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 14923f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 2); 14933f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 14943f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 14953f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 14963f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely 14973f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 14983f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode { 14993f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 15009cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[3]; 15013f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 1502475871a144eb604ddaf37503397ba0941442e5fbDan Gohman TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y, 1503475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Z) 15043f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 15053f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[0] = X; 15063f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[1] = Y; 15073f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner Ops[2] = Z; 15083f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner InitOperands(Ops, 3); 15093f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 15103f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 15113f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 15123f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 1513d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that 1514d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its 1515d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand. This node should be directly created by end-users and not added to 1516d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list. 1517d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode { 1518c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 15199cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Op; 1520d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic: 1521ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is 1522ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling // fixed. 152369cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#ifdef __GNUC__ 1524475871a144eb604ddaf37503397ba0941442e5fbDan Gohman explicit __attribute__((__noinline__)) HandleSDNode(SDValue X) 152569cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#else 1526475871a144eb604ddaf37503397ba0941442e5fbDan Gohman explicit HandleSDNode(SDValue X) 152769cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#endif 15289cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) { 15299cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein Op = X; 1530bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner InitOperands(&Op, 1); 1531bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 153248b85926524f9d29ae600123c90194cd73fd629eChris Lattner ~HandleSDNode(); 1533ec20183c35f1a8d308b619dbe580d0ed0db21d12Dan Gohman const SDValue &getValue() const { return Op.getSDValue(); } 1534d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner}; 1535d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner 153628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang/// Abstact virtual class for operations for memory operations 153728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass MemSDNode : public SDNode { 153828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 153928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 154028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangprivate: 15411ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman // MemoryVT - VT of in-memory value. 15421ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MVT MemoryVT; 15431ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman 154428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang //! SrcValue - Memory location for alias analysis. 154528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang const Value *SrcValue; 154628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1547492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman //! SVOffset - Memory location offset. Note that base is defined in MemSDNode 1548492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman int SVOffset; 1549492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman 1550492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman /// Flags - the low bit indicates whether this is a volatile reference; 1551492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman /// the remainder is a log2 encoding of the alignment in bytes. 1552492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman unsigned Flags; 155328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 155428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangpublic: 15551ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT, 1556492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman const Value *srcValue, int SVOff, 1557492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman unsigned alignment, bool isvolatile); 155828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1559c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MemSDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps, 1560c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MVT MemoryVT, const Value *srcValue, int SVOff, 1561c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang unsigned alignment, bool isvolatile); 1562c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 156328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// Returns alignment and volatility of the memory access 1564492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman unsigned getAlignment() const { return (1u << (Flags >> 1)) >> 1; } 1565492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman bool isVolatile() const { return Flags & 1; } 156628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 156728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// Returns the SrcValue and offset that describes the location of the access 156828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang const Value *getSrcValue() const { return SrcValue; } 1569492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman int getSrcValueOffset() const { return SVOffset; } 157028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 15711ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman /// getMemoryVT - Return the type of the in-memory value. 15721ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MVT getMemoryVT() const { return MemoryVT; } 15731ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman 157428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// getMemOperand - Return a MachineMemOperand object describing the memory 157528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// reference performed by operation. 15761ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MachineMemOperand getMemOperand() const; 15771ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman 1578475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getChain() const { return getOperand(0); } 1579475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { 15801ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman return getOperand(getOpcode() == ISD::STORE ? 2 : 1); 15811ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman } 158228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1583b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman /// getRawFlags - Represent the flags as a bunch of bits. 1584b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman /// 1585b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman unsigned getRawFlags() const { return Flags; } 1586b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman 158728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Methods to support isa and dyn_cast 158828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const MemSDNode *) { return true; } 158928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const SDNode *N) { 1590c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // For some targets, we lower some target intrinsics to a MemIntrinsicNode 1591c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // with either an intrinsic or a target opcode. 1592e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen return N->getOpcode() == ISD::LOAD || 1593e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::STORE || 1594e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_CMP_SWAP_8 || 1595e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_SWAP_8 || 1596e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_ADD_8 || 1597e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_SUB_8 || 1598e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_AND_8 || 1599e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_OR_8 || 1600e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_XOR_8 || 1601e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_NAND_8 || 1602e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MIN_8 || 1603e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MAX_8 || 1604e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_8 || 1605e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_8 || 1606e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen 1607e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_CMP_SWAP_16 || 1608e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_SWAP_16 || 1609e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_ADD_16 || 1610e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_SUB_16 || 1611e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_AND_16 || 1612e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_OR_16 || 1613e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_XOR_16 || 1614e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_NAND_16 || 1615e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MIN_16 || 1616e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MAX_16 || 1617e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_16 || 1618e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_16 || 1619e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen 1620e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_CMP_SWAP_32 || 1621e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_SWAP_32 || 1622e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_ADD_32 || 1623e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_SUB_32 || 1624e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_AND_32 || 1625e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_OR_32 || 1626e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_XOR_32 || 1627e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_NAND_32 || 1628e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MIN_32 || 1629e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MAX_32 || 1630e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_32 || 1631e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_32 || 1632e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen 1633e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_CMP_SWAP_64 || 1634e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_SWAP_64 || 1635e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_ADD_64 || 1636e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_SUB_64 || 1637e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_AND_64 || 1638e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_OR_64 || 1639e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_XOR_64 || 1640e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_NAND_64 || 1641e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MIN_64 || 1642e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MAX_64 || 1643e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_64 || 1644c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_64 || 1645c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 1646c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_W_CHAIN || 1647c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_VOID || 1648c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->isTargetOpcode(); 164928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang } 165028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang}; 165128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1652c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// AtomicSDNode - A SDNode reprenting atomic operations. 1653c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// 165428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass AtomicSDNode : public MemSDNode { 1655ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 16569cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[4]; 165728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 165828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang public: 165928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Opc: opcode for atomic 166028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // VTL: value type list 166128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Chain: memory chain for operaand 1662475871a144eb604ddaf37503397ba0941442e5fbDan Gohman // Ptr: address to update as a SDValue 166328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Cmp: compare value 166428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Swp: swap value 166528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // SrcVal: address to update as a Value (used for MemOperand) 166628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Align: alignment of memory 1667475871a144eb604ddaf37503397ba0941442e5fbDan Gohman AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr, 1668475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Cmp, SDValue Swp, const Value* SrcVal, 166928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang unsigned Align=0) 16701ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman : MemSDNode(Opc, VTL, Cmp.getValueType(), SrcVal, /*SVOffset=*/0, 1671492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman Align, /*isVolatile=*/true) { 1672ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth Ops[0] = Chain; 1673c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[1] = Ptr; 1674d18a462bdd8ba6a7dd14e40ff0ebaedf9c46de26Dale Johannesen Ops[2] = Cmp; 1675d18a462bdd8ba6a7dd14e40ff0ebaedf9c46de26Dale Johannesen Ops[3] = Swp; 1676ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth InitOperands(Ops, 4); 1677ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth } 1678475871a144eb604ddaf37503397ba0941442e5fbDan Gohman AtomicSDNode(unsigned Opc, SDVTList VTL, SDValue Chain, SDValue Ptr, 1679475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Val, const Value* SrcVal, unsigned Align=0) 16801ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman : MemSDNode(Opc, VTL, Val.getValueType(), SrcVal, /*SVOffset=*/0, 1681492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman Align, /*isVolatile=*/true) { 1682ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth Ops[0] = Chain; 1683c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[1] = Ptr; 1684c1c7bd610a1647d8e7eaeb4cc38ca1a85ae5e271Andrew Lenharth Ops[2] = Val; 1685ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth InitOperands(Ops, 3); 1686ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth } 168728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1688475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(1); } 1689475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getVal() const { return getOperand(2); } 169028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1691e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen bool isCompareAndSwap() const { 1692e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen unsigned Op = getOpcode(); 1693e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen return Op == ISD::ATOMIC_CMP_SWAP_8 || 1694e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen Op == ISD::ATOMIC_CMP_SWAP_16 || 1695e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen Op == ISD::ATOMIC_CMP_SWAP_32 || 1696e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen Op == ISD::ATOMIC_CMP_SWAP_64; 1697e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen } 169828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 169928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Methods to support isa and dyn_cast 170028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const AtomicSDNode *) { return true; } 170128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const SDNode *N) { 1702e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen return N->getOpcode() == ISD::ATOMIC_CMP_SWAP_8 || 1703e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_SWAP_8 || 1704e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_ADD_8 || 1705e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_SUB_8 || 1706e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_AND_8 || 1707e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_OR_8 || 1708e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_XOR_8 || 1709e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_NAND_8 || 1710e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MIN_8 || 1711e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MAX_8 || 1712e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_8 || 1713e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_8 || 1714e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_CMP_SWAP_16 || 1715e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_SWAP_16 || 1716e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_ADD_16 || 1717e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_SUB_16 || 1718e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_AND_16 || 1719e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_OR_16 || 1720e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_XOR_16 || 1721e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_NAND_16 || 1722e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MIN_16 || 1723e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MAX_16 || 1724e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_16 || 1725e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_16 || 1726e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_CMP_SWAP_32 || 1727e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_SWAP_32 || 1728e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_ADD_32 || 1729e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_SUB_32 || 1730e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_AND_32 || 1731e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_OR_32 || 1732e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_XOR_32 || 1733e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_NAND_32 || 1734e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MIN_32 || 1735e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MAX_32 || 1736e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_32 || 1737e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_32 || 1738e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_CMP_SWAP_64 || 1739e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_SWAP_64 || 1740e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_ADD_64 || 1741e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_SUB_64 || 1742e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_AND_64 || 1743e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_OR_64 || 1744e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_XOR_64 || 1745e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_NAND_64 || 1746e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MIN_64 || 1747e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_MAX_64 || 1748e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMIN_64 || 1749e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::ATOMIC_LOAD_UMAX_64; 175028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang } 1751ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth}; 1752ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 1753c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// MemIntrinsicSDNode - This SDNode is used for target intrinsic that touches 1754c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// memory and need an associated memory operand. 1755c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// 1756c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wangclass MemIntrinsicSDNode : public MemSDNode { 1757c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 1758c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool ReadMem; // Intrinsic reads memory 1759c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool WriteMem; // Intrinsic writes memory 1760c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang public: 1761c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MemIntrinsicSDNode(unsigned Opc, SDVTList VTs, 1762c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang const SDValue *Ops, unsigned NumOps, 1763c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MVT MemoryVT, const Value *srcValue, int SVO, 1764c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang unsigned Align, bool Vol, bool ReadMem, bool WriteMem) 1765c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang : MemSDNode(Opc, VTs, Ops, NumOps, MemoryVT, srcValue, SVO, Align, Vol), 1766c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang ReadMem(ReadMem), WriteMem(WriteMem) { 1767c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang } 1768c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 1769c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool readMem() const { return ReadMem; } 1770c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool writeMem() const { return WriteMem; } 1771c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 1772c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // Methods to support isa and dyn_cast 1773c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang static bool classof(const MemIntrinsicSDNode *) { return true; } 1774c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang static bool classof(const SDNode *N) { 1775c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // We lower some target intrinsics to their target opcode 1776c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // early a node with a target opcode can be of this class 1777c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang return N->getOpcode() == ISD::INTRINSIC_W_CHAIN || 1778c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_VOID || 1779c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->isTargetOpcode(); 1780c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang } 1781c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang}; 1782c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 178363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode { 17844fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantInt *Value; 1785c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 178663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 178763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 17884fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT) 1789bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)), 1790bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Value(val) { 179163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 179263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 179363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17944fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantInt *getConstantIntValue() const { return Value; } 17954fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const APInt &getAPIntValue() const { return Value->getValue(); } 17964fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman uint64_t getZExtValue() const { return Value->getZExtValue(); } 17977810bfed5570c192e0714a8fd0e5130a0c38dd2eDan Gohman int64_t getSExtValue() const { return Value->getSExtValue(); } 179863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17994fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman bool isNullValue() const { return Value->isNullValue(); } 18004fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman bool isAllOnesValue() const { return Value->isAllOnesValue(); } 180163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 180263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantSDNode *) { return true; } 180363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1804056f9f61d071c6c583951678f2bf543a1316efccChris Lattner return N->getOpcode() == ISD::Constant || 1805056f9f61d071c6c583951678f2bf543a1316efccChris Lattner N->getOpcode() == ISD::TargetConstant; 180663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 180763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 180863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 180963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode { 18104fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantFP *Value; 1811c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 181263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 181363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 18144fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT) 181587503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 181687503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen getSDVTList(VT)), Value(val) { 181763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 181863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 181963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 18204fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const APFloat& getValueAPF() const { return Value->getValueAPF(); } 18214fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantFP *getConstantFPValue() const { return Value; } 182263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 182363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isExactlyValue - We don't rely on operator== working on double values, as 182463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 182563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// As such, this method can be used to do an exact bit-for-bit comparison of 182663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// two floating point values. 1827c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen 1828c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// We leave the version with the double argument here because it's just so 1829c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// convenient to write "2.0" and the like. Without this function we'd 1830c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// have to duplicate its logic everywhere it's called. 18319dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen bool isExactlyValue(double V) const { 183223a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen bool ignored; 18339dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen // convert is not supported on this type 18344fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) 18359dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen return false; 183684cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner APFloat Tmp(V); 18374fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman Tmp.convert(Value->getValueAPF().getSemantics(), 183823a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen APFloat::rmNearestTiesToEven, &ignored); 183984cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner return isExactlyValue(Tmp); 184087503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen } 1841e6c1742914149d44360fbf05a653041a672282afDale Johannesen bool isExactlyValue(const APFloat& V) const; 184263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 184383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands bool isValueValidForType(MVT VT, const APFloat& Val); 1844f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen 184563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantFPSDNode *) { return true; } 184663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1847ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner return N->getOpcode() == ISD::ConstantFP || 1848ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner N->getOpcode() == ISD::TargetConstantFP; 184963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 185063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 185163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 185263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode { 185363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *TheGlobal; 18546520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t Offset; 1855c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 185663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 185763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 18586520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT, 18596520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t o = 0); 186063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 186163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 186263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *getGlobal() const { return TheGlobal; } 18636520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t getOffset() const { return Offset; } 186463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 186563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const GlobalAddressSDNode *) { return true; } 186663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1867f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner return N->getOpcode() == ISD::GlobalAddress || 1868b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalAddress || 1869b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::GlobalTLSAddress || 1870b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalTLSAddress; 187163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 187263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 187363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 187463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode { 187563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int FI; 1876c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 187763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 187863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 187983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands FrameIndexSDNode(int fi, MVT VT, bool isTarg) 1880bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)), 1881bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner FI(fi) { 188263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 188363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 188463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 188563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int getIndex() const { return FI; } 188663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 188763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const FrameIndexSDNode *) { return true; } 188863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1889afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner return N->getOpcode() == ISD::FrameIndex || 1890afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner N->getOpcode() == ISD::TargetFrameIndex; 189163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 189263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 189363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 189437efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode { 189537efe6764568a3829fee26aba532283131d1a104Nate Begeman int JTI; 1896c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 189737efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected: 189837efe6764568a3829fee26aba532283131d1a104Nate Begeman friend class SelectionDAG; 189983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands JumpTableSDNode(int jti, MVT VT, bool isTarg) 1900bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)), 1901bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner JTI(jti) { 190263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 190337efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic: 190437efe6764568a3829fee26aba532283131d1a104Nate Begeman 190559a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner int getIndex() const { return JTI; } 190637efe6764568a3829fee26aba532283131d1a104Nate Begeman 190737efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const JumpTableSDNode *) { return true; } 190837efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const SDNode *N) { 190937efe6764568a3829fee26aba532283131d1a104Nate Begeman return N->getOpcode() == ISD::JumpTable || 191037efe6764568a3829fee26aba532283131d1a104Nate Begeman N->getOpcode() == ISD::TargetJumpTable; 191137efe6764568a3829fee26aba532283131d1a104Nate Begeman } 191237efe6764568a3829fee26aba532283131d1a104Nate Begeman}; 191337efe6764568a3829fee26aba532283131d1a104Nate Begeman 191463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode { 1915d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng union { 1916d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *ConstVal; 1917d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *MachineCPVal; 1918d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } Val; 1919baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int Offset; // It's a MachineConstantPoolValue if top bit is set. 1920b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned Alignment; 1921c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 192263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 192363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 192483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0) 1925ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1926bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1927d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1928d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1929d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 193083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align) 1931ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1932bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1933d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1934d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1935d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1936d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 193783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT VT, int o=0) 1938ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1939bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1940d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1941d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1942d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1943d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1944d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 194583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT VT, int o, unsigned Align) 1946ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1947bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1948d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1949d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1950d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1951d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 195263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 195363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1954d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng bool isMachineConstantPoolEntry() const { 1955d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return (int)Offset < 0; 1956d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1957d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1958d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *getConstVal() const { 1959d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1960d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.ConstVal; 1961d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1962d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1963d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *getMachineCPVal() const { 1964d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1965d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.MachineCPVal; 1966d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1967d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1968baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int getOffset() const { 1969baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng return Offset & ~(1 << (sizeof(unsigned)*8-1)); 1970baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng } 1971ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner 1972ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // Return the alignment of this constant pool object, which is either 0 (for 1973ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // default alignment) or log2 of the desired value. 1974b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned getAlignment() const { return Alignment; } 197563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1976d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng const Type *getType() const; 1977d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 197863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantPoolSDNode *) { return true; } 197963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1980aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner return N->getOpcode() == ISD::ConstantPool || 1981aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner N->getOpcode() == ISD::TargetConstantPool; 198263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 198363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 198463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 198563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode { 198663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *MBB; 1987c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 198863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 198963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1990423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit BasicBlockSDNode(MachineBasicBlock *mbb) 1991bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) { 199263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 199363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 199463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 199563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *getBasicBlock() const { return MBB; } 199663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 199763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const BasicBlockSDNode *) { return true; } 199863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 199963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return N->getOpcode() == ISD::BasicBlock; 200063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 200163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 200263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 200314471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is 200414471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// used when the SelectionDAG needs to make a simple reference to something 200514471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// in the LLVM IR representation. 200614471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 200714471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// Note that this is not used for carrying alias information; that is done 200814471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// with MemOperandSDNode, which includes a Value which is required to be a 200914471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// pointer, and several other fields specific to memory references. 201014471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 20112d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode { 20122d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *V; 2013c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 20142d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected: 20152d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth friend class SelectionDAG; 201669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// Create a SrcValue for a general value. 201769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman explicit SrcValueSDNode(const Value *v) 201869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {} 20192d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 20202d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic: 202169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// getValue - return the contained Value. 20222d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *getValue() const { return V; } 20232d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 20242d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SrcValueSDNode *) { return true; } 20252d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SDNode *N) { 20262d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth return N->getOpcode() == ISD::SRCVALUE; 20272d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 20282d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth}; 20292d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 203063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 203136b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is 203269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// used to represent a reference to memory after ISD::LOAD 203369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// and ISD::STORE have been lowered. 203469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// 203569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanclass MemOperandSDNode : public SDNode { 203669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 203769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanprotected: 203869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman friend class SelectionDAG; 203936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// Create a MachineMemOperand node 204036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman explicit MemOperandSDNode(const MachineMemOperand &mo) 204169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {} 204269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 204369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanpublic: 204436b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// MO - The contained MachineMemOperand. 204536b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman const MachineMemOperand MO; 204669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 204769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const MemOperandSDNode *) { return true; } 204869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const SDNode *N) { 204969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman return N->getOpcode() == ISD::MEMOPERAND; 205069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman } 205169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman}; 205269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 205369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 2054d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode { 205563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Reg; 2056c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 205763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 205863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 205983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands RegisterSDNode(unsigned reg, MVT VT) 2060bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) { 206163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 206263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 206363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 206463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getReg() const { return Reg; } 206563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 2066d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner static bool classof(const RegisterSDNode *) { return true; } 206763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 2068d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner return N->getOpcode() == ISD::Register; 206963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 207063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 207163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 20727f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanclass DbgStopPointSDNode : public SDNode { 20737f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman SDUse Chain; 20747f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned Line; 20757f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned Column; 20767f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman const CompileUnitDesc *CU; 20777f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 20787f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanprotected: 20797f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman friend class SelectionDAG; 2080475871a144eb604ddaf37503397ba0941442e5fbDan Gohman DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c, 20817f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman const CompileUnitDesc *cu) 20827f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)), 20837f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman Line(l), Column(c), CU(cu) { 20847f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman Chain = ch; 20857f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman InitOperands(&Chain, 1); 20867f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman } 20877f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanpublic: 20887f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned getLine() const { return Line; } 20897f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned getColumn() const { return Column; } 20907f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman const CompileUnitDesc *getCompileUnit() const { return CU; } 20917f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman 20927f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman static bool classof(const DbgStopPointSDNode *) { return true; } 20937f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman static bool classof(const SDNode *N) { 20947f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman return N->getOpcode() == ISD::DBG_STOPPOINT; 20957f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman } 20967f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman}; 20977f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman 20984406604047423576e36657c7ede266ca42e79642Dan Gohmanclass LabelSDNode : public SDNode { 20994406604047423576e36657c7ede266ca42e79642Dan Gohman SDUse Chain; 21004406604047423576e36657c7ede266ca42e79642Dan Gohman unsigned LabelID; 21014406604047423576e36657c7ede266ca42e79642Dan Gohman virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 21024406604047423576e36657c7ede266ca42e79642Dan Gohmanprotected: 21034406604047423576e36657c7ede266ca42e79642Dan Gohman friend class SelectionDAG; 2104475871a144eb604ddaf37503397ba0941442e5fbDan Gohman LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id) 21054406604047423576e36657c7ede266ca42e79642Dan Gohman : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) { 21064406604047423576e36657c7ede266ca42e79642Dan Gohman Chain = ch; 21074406604047423576e36657c7ede266ca42e79642Dan Gohman InitOperands(&Chain, 1); 21084406604047423576e36657c7ede266ca42e79642Dan Gohman } 21094406604047423576e36657c7ede266ca42e79642Dan Gohmanpublic: 21104406604047423576e36657c7ede266ca42e79642Dan Gohman unsigned getLabelID() const { return LabelID; } 21114406604047423576e36657c7ede266ca42e79642Dan Gohman 21124406604047423576e36657c7ede266ca42e79642Dan Gohman static bool classof(const LabelSDNode *) { return true; } 21134406604047423576e36657c7ede266ca42e79642Dan Gohman static bool classof(const SDNode *N) { 21144406604047423576e36657c7ede266ca42e79642Dan Gohman return N->getOpcode() == ISD::DBG_LABEL || 21154406604047423576e36657c7ede266ca42e79642Dan Gohman N->getOpcode() == ISD::EH_LABEL; 21164406604047423576e36657c7ede266ca42e79642Dan Gohman } 21174406604047423576e36657c7ede266ca42e79642Dan Gohman}; 21184406604047423576e36657c7ede266ca42e79642Dan Gohman 2119056292fd738924f3f7703725d8f630983794b5a5Bill Wendlingclass ExternalSymbolSDNode : public SDNode { 212063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *Symbol; 2121c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 212263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 212363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 2124056292fd738924f3f7703725d8f630983794b5a5Bill Wendling ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT) 2125056292fd738924f3f7703725d8f630983794b5a5Bill Wendling : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 2126056292fd738924f3f7703725d8f630983794b5a5Bill Wendling getSDVTList(VT)), Symbol(Sym) { 2127056292fd738924f3f7703725d8f630983794b5a5Bill Wendling } 212863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 2129056292fd738924f3f7703725d8f630983794b5a5Bill Wendling 213063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *getSymbol() const { return Symbol; } 213163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 2132056292fd738924f3f7703725d8f630983794b5a5Bill Wendling static bool classof(const ExternalSymbolSDNode *) { return true; } 213363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 2134056292fd738924f3f7703725d8f630983794b5a5Bill Wendling return N->getOpcode() == ISD::ExternalSymbol || 2135056292fd738924f3f7703725d8f630983794b5a5Bill Wendling N->getOpcode() == ISD::TargetExternalSymbol; 213663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 213763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 213863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 21397cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode { 214063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ISD::CondCode Condition; 2141c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 214263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 214363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 2144423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit CondCodeSDNode(ISD::CondCode Cond) 2145bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) { 214663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 214763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 214863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 21497cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner ISD::CondCode get() const { return Condition; } 215063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 21517cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner static bool classof(const CondCodeSDNode *) { return true; } 215263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 21537cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner return N->getOpcode() == ISD::CONDCODE; 215463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 215563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 215663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 215777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the 215877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// future and most targets don't support it. 215977cdf30742284a173fe818417eb482224cdee8d4Mon P Wangclass CvtRndSatSDNode : public SDNode { 216077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang ISD::CvtCode CvtCode; 216177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 216277cdf30742284a173fe818417eb482224cdee8d4Mon P Wangprotected: 216377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang friend class SelectionDAG; 216477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang explicit CvtRndSatSDNode(MVT VT, const SDValue *Ops, unsigned NumOps, 216577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang ISD::CvtCode Code) 216677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang : SDNode(ISD::CONVERT_RNDSAT, getSDVTList(VT), Ops, NumOps), CvtCode(Code) { 216777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang assert(NumOps == 5 && "wrong number of operations"); 216877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang } 216977cdf30742284a173fe818417eb482224cdee8d4Mon P Wangpublic: 217077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang ISD::CvtCode getCvtCode() const { return CvtCode; } 217177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 217277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang static bool classof(const CvtRndSatSDNode *) { return true; } 217377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang static bool classof(const SDNode *N) { 217477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang return N->getOpcode() == ISD::CONVERT_RNDSAT; 217577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang } 217677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang}; 217777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 2178276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsnamespace ISD { 2179276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands struct ArgFlagsTy { 2180276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands private: 2181276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t NoFlagSet = 0ULL; 2182276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ZExt = 1ULL<<0; ///< Zero extended 2183276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ZExtOffs = 0; 2184276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SExt = 1ULL<<1; ///< Sign extended 2185276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SExtOffs = 1; 2186276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t InReg = 1ULL<<2; ///< Passed in register 2187276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t InRegOffs = 2; 2188276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr 2189276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SRetOffs = 3; 2190276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value 2191276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValOffs = 4; 2192276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain 2193276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t NestOffs = 5; 2194276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment 2195276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValAlignOffs = 6; 21966ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray static const uint64_t Split = 1ULL << 10; 21976ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray static const uint64_t SplitOffs = 10; 2198276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t OrigAlign = 0x1FULL<<27; 2199276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t OrigAlignOffs = 27; 2200276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size 2201276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValSizeOffs = 32; 2202276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2203276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t One = 1ULL; //< 1 of this type, for shifts 2204276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2205276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands uint64_t Flags; 2206276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands public: 2207276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ArgFlagsTy() : Flags(0) { } 2208276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2209276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isZExt() const { return Flags & ZExt; } 2210276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setZExt() { Flags |= One << ZExtOffs; } 2211276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2212276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isSExt() const { return Flags & SExt; } 2213276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setSExt() { Flags |= One << SExtOffs; } 2214276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2215276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isInReg() const { return Flags & InReg; } 2216276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setInReg() { Flags |= One << InRegOffs; } 2217276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2218276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isSRet() const { return Flags & SRet; } 2219276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setSRet() { Flags |= One << SRetOffs; } 2220276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2221276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isByVal() const { return Flags & ByVal; } 2222276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByVal() { Flags |= One << ByValOffs; } 2223276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2224276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isNest() const { return Flags & Nest; } 2225276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setNest() { Flags |= One << NestOffs; } 2226276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2227276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getByValAlign() const { 222894bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned) 222994bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2); 2230276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2231276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByValAlign(unsigned A) { 2232276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~ByValAlign) | 2233276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands (uint64_t(Log2_32(A) + 1) << ByValAlignOffs); 2234276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2235c0cb28fd3abee9a8b40856990e04f1af2f9bd7b8Nicolas Geoffray 22366ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray bool isSplit() const { return Flags & Split; } 22376ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray void setSplit() { Flags |= One << SplitOffs; } 2238276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2239276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getOrigAlign() const { 224094bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned) 224194bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2); 2242276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2243276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setOrigAlign(unsigned A) { 2244276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~OrigAlign) | 2245276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands (uint64_t(Log2_32(A) + 1) << OrigAlignOffs); 2246276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2247276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2248276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getByValSize() const { 224994bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned)((Flags & ByValSize) >> ByValSizeOffs); 2250276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2251276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByValSize(unsigned S) { 2252276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs); 2253276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2254276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2255276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4". 2256276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands std::string getArgFlagsString(); 2257276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2258276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// getRawBits - Represent the flags as a bunch of bits. 2259276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands uint64_t getRawBits() const { return Flags; } 2260276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands }; 2261276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands} 2262276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2263276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands/// ARG_FLAGSSDNode - Leaf node holding parameter flags. 2264276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsclass ARG_FLAGSSDNode : public SDNode { 2265276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ISD::ArgFlagsTy TheFlags; 2266276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 2267276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsprotected: 2268276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands friend class SelectionDAG; 2269276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags) 2270276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) { 2271276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2272276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandspublic: 2273276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ISD::ArgFlagsTy getArgFlags() const { return TheFlags; } 2274276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2275276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static bool classof(const ARG_FLAGSSDNode *) { return true; } 2276276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static bool classof(const SDNode *N) { 2277276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands return N->getOpcode() == ISD::ARG_FLAGS; 2278276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2279276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands}; 2280276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2281095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman/// CallSDNode - Node for calls -- ISD::CALL. 2282095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanclass CallSDNode : public SDNode { 2283095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned CallingConv; 2284095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman bool IsVarArg; 2285095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman bool IsTailCall; 228686098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // We might eventually want a full-blown Attributes for the result; that 228786098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // will expand the size of the representation. At the moment we only 228886098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // need Inreg. 228986098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen bool Inreg; 2290095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 2291095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanprotected: 2292095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman friend class SelectionDAG; 229386098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen CallSDNode(unsigned cc, bool isvararg, bool istailcall, bool isinreg, 2294095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDVTList VTs, const SDValue *Operands, unsigned numOperands) 2295095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman : SDNode(ISD::CALL, VTs, Operands, numOperands), 229686098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall), 229786098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen Inreg(isinreg) {} 2298095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanpublic: 2299095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getCallingConv() const { return CallingConv; } 2300095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned isVarArg() const { return IsVarArg; } 2301095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned isTailCall() const { return IsTailCall; } 230286098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen unsigned isInreg() const { return Inreg; } 2303095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2304095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// Set this call to not be marked as a tail call. Normally setter 2305095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// methods in SDNodes are unsafe because it breaks the CSE map, 23065eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman /// but we don't include the tail call flag for calls so it's ok 23075eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman /// in this case. 2308095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman void setNotTailCall() { IsTailCall = false; } 2309095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2310095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getChain() const { return getOperand(0); } 2311095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getCallee() const { return getOperand(1); } 2312095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2313095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getNumArgs() const { return (getNumOperands() - 2) / 2; } 2314095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getArg(unsigned i) const { return getOperand(2+2*i); } 2315095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getArgFlagsVal(unsigned i) const { 2316095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return getOperand(3+2*i); 2317095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2318095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman ISD::ArgFlagsTy getArgFlags(unsigned i) const { 2319095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return cast<ARG_FLAGSSDNode>(getArgFlagsVal(i).getNode())->getArgFlags(); 2320095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2321095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2322095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getNumRetVals() const { return getNumValues() - 1; } 2323095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman MVT getRetValType(unsigned i) const { return getValueType(i); } 2324095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2325095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman static bool classof(const CallSDNode *) { return true; } 2326095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman static bool classof(const SDNode *N) { 2327095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return N->getOpcode() == ISD::CALL; 2328095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2329095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman}; 2330095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 233183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands/// VTSDNode - This class is used to represent MVT's, which are used 233215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations. 233315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode { 233483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT ValueType; 2335c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 233615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected: 233715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner friend class SelectionDAG; 233883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands explicit VTSDNode(MVT VT) 2339bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) { 234063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 234115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic: 234215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 234383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getVT() const { return ValueType; } 234415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 234515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const VTSDNode *) { return true; } 234615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const SDNode *N) { 234715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner return N->getOpcode() == ISD::VALUETYPE; 234815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner } 234915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner}; 235015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 23519de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode 23529de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// 235328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass LSBaseSDNode : public MemSDNode { 23549de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprotected: 23559de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Operand array for load and store 23569de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel /*! 23579de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel \note Moving this array to the base class captures more 23589de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel common functionality shared between LoadSDNode and 23599de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel StoreSDNode 23609de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel */ 23619cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[4]; 23629de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic: 2363475871a144eb604ddaf37503397ba0941442e5fbDan Gohman LSBaseSDNode(ISD::NodeType NodeTy, SDValue *Operands, unsigned numOperands, 236483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDVTList VTs, ISD::MemIndexedMode AM, MVT VT, 2365b625f2f8960de32bc973092aaee8ac62863006feDan Gohman const Value *SV, int SVO, unsigned Align, bool Vol) 2366ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol) { 2367ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman SubclassData = AM; 236813d57320bd212483463d4f8992d5787b29eda5dfBill Wendling for (unsigned i = 0; i != numOperands; ++i) 2369b625f2f8960de32bc973092aaee8ac62863006feDan Gohman Ops[i] = Operands[i]; 237013d57320bd212483463d4f8992d5787b29eda5dfBill Wendling InitOperands(Ops, numOperands); 2371b625f2f8960de32bc973092aaee8ac62863006feDan Gohman assert(Align != 0 && "Loads and stores should have non-zero aligment"); 2372437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) && 2373437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman "Only indexed loads and stores have a non-undef offset operand"); 2374b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 23759de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 2376475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { 237763602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); 237863602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner } 23799de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 2380ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// getAddressingMode - Return the addressing mode for this load or store: 2381ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// unindexed, pre-inc, pre-dec, post-inc, or post-dec. 2382ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman ISD::MemIndexedMode getAddressingMode() const { 2383ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman return ISD::MemIndexedMode(SubclassData & 7); 2384ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 2385b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 2386b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isIndexed - Return true if this is a pre/post inc/dec load/store. 2387ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; } 2388b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 2389b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. 2390ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; } 2391b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 239213d57320bd212483463d4f8992d5787b29eda5dfBill Wendling static bool classof(const LSBaseSDNode *) { return true; } 2393b625f2f8960de32bc973092aaee8ac62863006feDan Gohman static bool classof(const SDNode *N) { 2394b625f2f8960de32bc973092aaee8ac62863006feDan Gohman return N->getOpcode() == ISD::LOAD || 2395b625f2f8960de32bc973092aaee8ac62863006feDan Gohman N->getOpcode() == ISD::STORE; 2396b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 23979de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel}; 23989de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 239924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes. 240024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 24019de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode { 2402c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 240324446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 240424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 2405475871a144eb604ddaf37503397ba0941442e5fbDan Gohman LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs, 240683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT, 240795c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 2408b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3, 2409ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman VTs, AM, LVT, SV, O, Align, Vol) { 2410ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman SubclassData |= (unsigned short)ETy << 3; 2411ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 241224446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 241324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2414ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// getExtensionType - Return whether this is a plain node, 2415ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// or one of the varieties of value-extending loads. 2416ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman ISD::LoadExtType getExtensionType() const { 2417ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman return ISD::LoadExtType((SubclassData >> 3) & 3); 2418ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 2419ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman 2420475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(1); } 2421475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { return getOperand(2); } 242239354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 242324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const LoadSDNode *) { return true; } 242424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 242524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD; 242624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 242724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 242824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 242924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes. 243024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 24319de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode { 2432c76e3c86026b9fa44bfbb0888881b52955078011Chris Lattner virtual void ANCHOR(); // Out-of-line virtual method to give class a home. 243324446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 243424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 2435475871a144eb604ddaf37503397ba0941442e5fbDan Gohman StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs, 243683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ISD::MemIndexedMode AM, bool isTrunc, MVT SVT, 243724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 2438b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4, 2439ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman VTs, AM, SVT, SV, O, Align, Vol) { 2440ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman SubclassData |= (unsigned short)isTrunc << 3; 2441ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 244224446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 244324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2444ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// isTruncatingStore - Return true if the op does a truncation before store. 2445ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// For integers this is the same as doing a TRUNCATE and storing the result. 2446ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// For floats, it is the same as doing an FP_ROUND and storing the result. 2447ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman bool isTruncatingStore() const { return (SubclassData >> 3) & 1; } 2448ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman 2449475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getValue() const { return getOperand(1); } 2450475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(2); } 2451475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { return getOperand(3); } 245239354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 24536d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng static bool classof(const StoreSDNode *) { return true; } 245424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 245524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::STORE; 245624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 245724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 245824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 245915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 24601080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { 24611080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNode *Node; 24621080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned Operand; 2463ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 24641080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 24651080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic: 24661080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator==(const SDNodeIterator& x) const { 24671080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Operand == x.Operand; 24681080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 24701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24711080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNodeIterator &operator=(const SDNodeIterator &I) { 24721080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 24731080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner Operand = I.Operand; 24741080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 24751080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 2476ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 24771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator*() const { 2478ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOperand(Operand).getNode(); 24791080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24801080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator->() const { return operator*(); } 2481ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 24821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator& operator++() { // Preincrement 24831080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner ++Operand; 24841080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 24851080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24861080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator operator++(int) { // Postincrement 2487ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SDNodeIterator tmp = *this; ++*this; return tmp; 24881080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24891080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24901080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 24911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator end (SDNode *N) { 24921080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator(N, N->getNumOperands()); 24931080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24941080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24951080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned getOperand() const { return Operand; } 24961080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNode *getNode() const { return Node; } 24971080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 24981080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24991080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> { 25001080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNode NodeType; 25011080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNodeIterator ChildIteratorType; 25021080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static inline NodeType *getEntryNode(SDNode *N) { return N; } 2503ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_begin(NodeType *N) { 25041080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::begin(N); 25051080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 2506ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_end(NodeType *N) { 25071080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::end(N); 25081080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 25091080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 25101080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 25110e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// LargestSDNode - The largest SDNode class. 25120e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// 25130e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohmantypedef LoadSDNode LargestSDNode; 25140e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman 2515fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// MostAlignedSDNode - The SDNode class with the greatest alignment 2516fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// requirement. 2517fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// 2518015b714f298ce3122302a4e996b81bd3e8c750cdDan Gohmantypedef ARG_FLAGSSDNode MostAlignedSDNode; 2519b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 2520c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD { 2521186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// isNormalLoad - Returns true if the specified node is a non-extending 2522186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// and unindexed load. 2523186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng inline bool isNormalLoad(const SDNode *N) { 2524c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N); 2525c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD && 2526186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng Ld->getAddressingMode() == ISD::UNINDEXED; 2527186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng } 2528186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng 252924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// isNON_EXTLoad - Returns true if the specified node is a non-extending 253024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// load. 253124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng inline bool isNON_EXTLoad(const SDNode *N) { 2532c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 253324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 253424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 253524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2536c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 2537c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2538c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isEXTLoad(const SDNode *N) { 2539c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 254024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 2541c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 2542c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2543c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 2544c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2545c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isSEXTLoad(const SDNode *N) { 2546c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 254724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 2548c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 2549c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2550c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 2551c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2552c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isZEXTLoad(const SDNode *N) { 2553c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 255424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 2555c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 25568b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 2557c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load. 255802c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// 255902c50e4891841c28b2a743731dfc60744bb78879Evan Cheng inline bool isUNINDEXEDLoad(const SDNode *N) { 2560c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 256102c50e4891841c28b2a743731dfc60744bb78879Evan Cheng cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 256202c50e4891841c28b2a743731dfc60744bb78879Evan Cheng } 256302c50e4891841c28b2a743731dfc60744bb78879Evan Cheng 2564c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isNormalStore - Returns true if the specified node is a non-truncating 2565c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// and unindexed store. 2566c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands inline bool isNormalStore(const SDNode *N) { 2567c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands const StoreSDNode *St = dyn_cast<StoreSDNode>(N); 2568c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return St && !St->isTruncatingStore() && 2569c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands St->getAddressingMode() == ISD::UNINDEXED; 2570c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands } 2571c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands 25728b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 25738b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 25748b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isNON_TRUNCStore(const SDNode *N) { 2575c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore(); 25768b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 25778b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 25788b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isTRUNCStore - Returns true if the specified node is a truncating 25798b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 25808b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isTRUNCStore(const SDNode *N) { 2581c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore(); 2582c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands } 2583c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands 2584c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isUNINDEXEDStore - Returns true if the specified node is an 2585c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// unindexed store. 2586c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands inline bool isUNINDEXEDStore(const SDNode *N) { 2587c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && 2588c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 25898b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 2590c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 2591c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2592c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 259363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace 259463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 259563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif 2596