SelectionDAGNodes.h revision f70dab704929cfeaae4fa6bd69b9037cd75a0d48
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 224fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman#include "llvm/Constants.h" 23583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/ADT/FoldingSet.h" 241080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner#include "llvm/ADT/GraphTraits.h" 2543d1fd449f1a0ac9d9dafa0b9569bb6b2e976198Anton Korobeynikov#include "llvm/ADT/iterator.h" 26fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/ilist_node.h" 27fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/STLExtras.h" 28d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h" 2936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman#include "llvm/CodeGen/MachineMemOperand.h" 300e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/Allocator.h" 310e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/RecyclingAllocator.h" 3239931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h" 333b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen#include "llvm/CodeGen/DebugLoc.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; 4383489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patelclass Value; 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/// 6063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD { 61d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov 6263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 6363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::NodeType enum - This enum defines all of the operators valid in a 6463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SelectionDAG. 6563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 66f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman /// These are sometimes called the target-independent operators; targets 67f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman /// may also define target-dependent operators. For example, on x86, these 68f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman /// are the enum values in the X86ISD namespace. Targets should aim to use 69f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman /// target-independent operators to model their instruction sets as much 70f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman /// as possible, and only use target-dependent operators when they have 71f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman /// special requirements. 72f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman /// 7363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum NodeType { 743258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // DELETED_NODE - This is an illegal flag value that is used to catch 753258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // errors. This opcode is not a legal opcode for any node. 763258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner DELETED_NODE, 773258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner 788a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // EntryToken - This is the marker used to indicate the start of the region. 798a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner EntryToken, 808a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner 81b2ab0e7471df7126a5b63fe8414b95c9584a0214Bill Wendling // TokenFactor - This node takes multiple tokens as input and produces a 828a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // single token result. This is used to represent the fact that the operand 838a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // operators are independent of each other. 848a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner TokenFactor, 85f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman 86f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // AssertSext, AssertZext - These nodes record if a register contains a 87f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // value that has already been zero or sign extended from a narrower type. 88f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // These nodes take two operands. The first is the node that has already 89f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // been extended, and the second is a value type node indicating the width 90f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // of the extension 91f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman AssertSext, AssertZext, 92ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 938a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // Various leaf nodes. 947f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register, 951ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng Constant, ConstantFP, 96b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio GlobalAddress, GlobalTLSAddress, FrameIndex, 97056292fd738924f3f7703725d8f630983794b5a5Bill Wendling JumpTable, ConstantPool, ExternalSymbol, 981ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng 9982c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth // The address of the GOT 10082c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth GLOBAL_OFFSET_TABLE, 101bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman 102bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and 103bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // llvm.returnaddress on the DAG. These nodes take one operand, the index 104bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // of the frame or return address to return. An index of zero corresponds 105bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // to the current function's frame or return address, an index of one to the 106bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // parent's frame or return address, and so on. 107bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman FRAMEADDR, RETURNADDR, 1082365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 1092365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to 1102365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // first (possible) on-stack argument. This is needed for correct stack 1112365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // adjustment during unwind. 1122365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov FRAME_TO_ARGS_OFFSET, 113f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 114f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the 115f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // address of the exception block on entry to an landing pad block. 116f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EXCEPTIONADDR, 117f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 118f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents 119f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // the selection index of the exception thrown. 120f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EHSELECTION, 121beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth 1222365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 1232365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // 'eh_return' gcc dwarf builtin, which is used to return from 1242365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // exception. The general meaning is: adjust stack by OFFSET and pass 1252365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // execution to HANDLER. Many platform-related details also :) 1262365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov EH_RETURN, 1272365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 128ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // TargetConstant* - Like Constant*, but the DAG does not do any folding or 129ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // simplification of the constant. 130056f9f61d071c6c583951678f2bf543a1316efccChris Lattner TargetConstant, 131ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner TargetConstantFP, 132f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner 133f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or 134f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // anything else with this node, and this is valid in the target-specific 135f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // dag, turning into a GlobalAddress operand. 136f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner TargetGlobalAddress, 137b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio TargetGlobalTLSAddress, 138afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner TargetFrameIndex, 13937efe6764568a3829fee26aba532283131d1a104Nate Begeman TargetJumpTable, 140aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner TargetConstantPool, 141056292fd738924f3f7703725d8f630983794b5a5Bill Wendling TargetExternalSymbol, 14272601cac6051a9571ca4db3b32d6a73e40b40bd1Chris Lattner 143ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) 144ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with no side effects. 145ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// The first operand is the ID number of the intrinsic from the 146ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The 147ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// node has returns the result of the intrinsic. 148ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_WO_CHAIN, 149ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 150ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) 151ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 152ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// returns a result. The first operand is a chain pointer. The second is 153ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The 154ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// operands to the intrinsic follow. The node has two results, the result 155ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// of the intrinsic and an output chain. 156ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_W_CHAIN, 15763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 158ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) 159ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 160ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// does not return a result. The first operand is a chain pointer. The 161ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// second is the ID number of the intrinsic from the llvm::Intrinsic 162ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// namespace. The operands to the intrinsic follow. 163ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_VOID, 164ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner 165d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // CopyToReg - This node has three operands: a chain, a register number to 166d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // set to this value, and a value. 16763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyToReg, 16863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 16963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // CopyFromReg - This node indicates that the input value is a virtual or 17063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // physical register that is defined outside of the scope of this 171ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman // SelectionDAG. The register is available from the RegisterSDNode object. 17263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyFromReg, 17363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 174fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman // UNDEF - An undefined node 175fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman UNDEF, 176681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner 177b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node 178b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// represents the formal arguments for a function. CC# is a Constant value 179b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// indicating the calling convention of the function, and ISVARARG is a 180b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// flag that indicates whether the function is varargs or not. This node 181b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// has one result value for each incoming argument, plus one for the output 182b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// chain. It must be custom legalized. See description of CALL node for 183b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FLAG argument contents explanation. 184c1a8ad71e11123f1e3c8d9913a7f51978b9967d5Chris Lattner /// 185681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner FORMAL_ARGUMENTS, 1866c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner 187095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CALLEE, 188b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn) 1896c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// This node represents a fully general function call, before the legalizer 190b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// runs. This has one result value for each argument / flag pair, plus 191b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// a chain result. It must be custom legalized. Flag argument indicates 192b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// misc. argument attributes. Currently: 193b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 0 - signness 194b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 1 - 'inreg' attribute 195b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 2 - 'sret' attribute 196594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 4 - 'byval' attribute 197594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 5 - 'nest' attribute 198594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 6-9 - alignment of byval structures 199594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 10-26 - size of byval structures 20013a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// Bits 31:27 - argument ABI alignment in the first argument piece and 20113a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// alignment '1' in other argument pieces. 202095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// 203095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// CALL nodes use the CallSDNode subclass of SDNode, which 204095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// additionally carries information about the calling convention, 205095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// whether the call is varargs, and if it's marked as a tail call. 206095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// 2076c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner CALL, 208fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman 20925eb043759c23b61769108f78382eb9701c41db2Duncan Sands // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by 210041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // a Constant, which is required to be operand #1) half of the integer or 211041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // float value specified as operand #0. This is only for use before 212041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // legalization, for values that will be broken into multiple registers. 21363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner EXTRACT_ELEMENT, 21463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 21563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given 21663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // two values of the same integer value type, this produces a value twice as 21763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // big. Like EXTRACT_ELEMENT, this can only be used before legalization. 21863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BUILD_PAIR, 219041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands 220006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // MERGE_VALUES - This node takes multiple discrete operands and returns 221006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // them all as its individual results. This nodes has exactly the same 222006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // number of inputs and outputs, and is only valid before legalization. 223006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // This node is useful for some pieces of the code generator that want to 224006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // think about a single node with multiple results, not multiple nodes. 225006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner MERGE_VALUES, 22663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 227615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple integer binary arithmetic operators. 228bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, 229fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 230fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing 231b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // a signed/unsigned value of type i[2*N], and return the full value as 232fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // two results, each of type iN. 233fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SMUL_LOHI, UMUL_LOHI, 234fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 235fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and 236fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // remainder result. 237fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SDIVREM, UDIVREM, 238615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner 23955e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // CARRY_FALSE - This node is used when folding other nodes, 24055e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner // like ADDC/SUBC, which indicate the carry result is always false. 24155e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner CARRY_FALSE, 24255e34eb31741f7902445cfa94fddde7a6910c408Chris Lattner 243551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-setting nodes for multiple precision addition and subtraction. 244551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // These nodes take two operands of the same value type, and produce two 245551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // results. The first result is the normal add or sub result, the second 246551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // result is the carry flag result. 247551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDC, SUBC, 248551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman 249551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-using nodes for multiple precision addition and subtraction. These 250551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // nodes take three operands: The first two are the normal lhs and rhs to 251551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // the add or sub, and the third is the input carry flag. These nodes 252551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // produce two results; the normal result of the add or sub, and the output 253551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // carry flag. These nodes both read and write a carry flag to allow them 254551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // to them to be chained together for add and sub of arbitrarily large 255551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // values. 256551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDE, SUBE, 257ea7b527aa56ad0fe547d3d99b21e845a49a031cbBill Wendling 258253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition. 259253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // These nodes take two operands: the normal LHS and RHS to the add. They 260253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // produce two results: the normal result of the add, and a boolean that 261253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // indicates if an overflow occured (*not* a flag, because it may be stored 262253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // to memory, etc.). If the type of the boolean is not i1 then the high 26303228089d5235f8c90477f88809139464e9c6ea5Duncan Sands // bits conform to getBooleanContents. 264253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // These nodes are generated from the llvm.[su]add.with.overflow intrinsics. 2651c55a9c0cc355ad72c55ae7665143b9a992d223bBill Wendling SADDO, UADDO, 266ea7b527aa56ad0fe547d3d99b21e845a49a031cbBill Wendling 26774c376529101acbe141a256d0bf23a44eb454c84Bill Wendling // Same for subtraction 26874c376529101acbe141a256d0bf23a44eb454c84Bill Wendling SSUBO, USUBO, 26974c376529101acbe141a256d0bf23a44eb454c84Bill Wendling 27074c376529101acbe141a256d0bf23a44eb454c84Bill Wendling // Same for multiplication 27174c376529101acbe141a256d0bf23a44eb454c84Bill Wendling SMULO, UMULO, 27274c376529101acbe141a256d0bf23a44eb454c84Bill Wendling 273615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple binary floating point operators. 274615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner FADD, FSUB, FMUL, FDIV, FREM, 27538bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 27638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This 27738bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // DAG node does not require that X and Y have the same type, just that they 27838bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // are both floating point. X and the result must have the same type. 27938bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(f32, f64) is allowed. 28038bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner FCOPYSIGN, 281fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner 2821a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point 2831a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // value as an integer 0/1 value. 2841a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner FGETSIGN, 2851a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner 286664e9546d674096c5a012536f1a424b1681ece51Dan Gohman /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector 28722232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// with the specified, possibly variable, elements. The number of elements 28822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner /// is required to be a power of two. 28922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner BUILD_VECTOR, 29022232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 2917f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element 2924f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// at IDX replaced with VAL. If the type of VAL is larger than the vector 2934f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// element type then VAL is truncated before replacement. 29422232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner INSERT_VECTOR_ELT, 2954b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner 2964b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR 2977f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// identified by the (potentially variable) element number IDX. 2984b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner EXTRACT_VECTOR_ELT, 29922232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner 3007f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of 3017f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector type with the same length and element type, this produces a 3027f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// concatenated vector result value, with length equal to the sum of the 303b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman /// lengths of the input vectors. 3047f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman CONCAT_VECTORS, 3056595635175764f402e7a5e53216c8d46bdce8c28Dan Gohman 3067f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an 3077f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector value) starting with the (potentially variable) element number 3087f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// IDX, which must be a multiple of the result vector length. 3097f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman EXTRACT_SUBVECTOR, 31059c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 31149c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// VECTOR_SHUFFLE(VEC1, VEC2, SHUFFLEVEC) - Returns a vector, of the same 31249c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner /// type as VEC1/VEC2. SHUFFLEVEC is a BUILD_VECTOR of constant int values 31359c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// (maybe of an illegal datatype) or undef that indicate which value each 31459c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// result element will get. The elements of VEC1/VEC2 are enumerated in 31559c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// order. This is quite similar to the Altivec 'vperm' instruction, except 31659c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// that the indices must be constants and are in terms of the element size 31759c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands /// of VEC1/VEC2, not in terms of bytes. 31849c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner VECTOR_SHUFFLE, 31959c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 320210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a 321a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// scalar value into element 0 of the resultant vector type. The top 322a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// elements 1 to N-1 of the N-element vector are undefined. 323210721aecc0916315f61660dc387a96b89ec423bChris Lattner SCALAR_TO_VECTOR, 324210721aecc0916315f61660dc387a96b89ec423bChris Lattner 325557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // EXTRACT_SUBREG - This node is used to extract a sub-register value. 326557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg and a constant sub-register index as operands. 327709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // Note sub-register indices must be increasing. That is, if the 328709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // sub-register index of a 8-bit sub-register is N, then the index for a 329709d19fb6677d8f31c7c9d2457f3647cb09b1941Evan Cheng // 16-bit sub-register must be at least N+1. 330557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb EXTRACT_SUBREG, 331557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 3324499e495eabe8de7d595416a03c56af4688df507Evan Cheng // INSERT_SUBREG - This node is used to insert a sub-register value. 333557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb // This node takes a superreg, a subreg value, and a constant sub-register 3344499e495eabe8de7d595416a03c56af4688df507Evan Cheng // index as operands. 335557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb INSERT_SUBREG, 336557c3631d320c5731e55b6f818a1c7b2d4d97176Christopher Lamb 337bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner // MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing 338b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // an unsigned/signed value of type i[2*N], then return the top part. 339bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner MULHU, MULHS, 34063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 34135ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // Bitwise operators - logical and, logical or, logical xor, shift left, 34235ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // shift right algebraic (shift in sign bits), shift right logical (shift in 34335ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman // zeroes), rotate left, rotate right, and byteswap. 34435ef913ec21de0f4f1b39c811b4335438717a9b8Nate Begeman AND, OR, XOR, SHL, SRA, SRL, ROTL, ROTR, BSWAP, 34563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 346691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth // Counting operators 347691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth CTTZ, CTLZ, CTPOP, 348691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth 3493b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not 35003228089d5235f8c90477f88809139464e9c6ea5Duncan Sands // i1 then the high bits must conform to getBooleanContents. 3513b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands SELECT, 3523b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands 3539373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // Select with condition operator - This selects between a true value and 3549373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // a false value (ops #2 and #3) based on the boolean result of comparing 3559373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // the lhs and rhs (ops #0 and #1) of a conditional expression with the 3569373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman // condition code in op #4, a CondCodeSDNode. 3579373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman SELECT_CC, 35863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3593b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // SetCC operator - This evaluates to a true value iff the condition is 3603b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // true. If the result value type is not i1 then the high bits conform 36103228089d5235f8c90477f88809139464e9c6ea5Duncan Sands // to getBooleanContents. The operands to this are the left and right 3623b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // operands to compare (ops #0, and #1) and the condition code to compare 3633b521d5acccf4fecdb1aea878180df6dc29553dcDuncan Sands // them with (op #2) as a CondCodeSDNode. 36463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETCC, 36563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 366b43e9c196542acc80c9e4643809661065710848fNate Begeman // Vector SetCC operator - This evaluates to a vector of integer elements 367b43e9c196542acc80c9e4643809661065710848fNate Begeman // with the high bit in each element set to true if the comparison is true 368b43e9c196542acc80c9e4643809661065710848fNate Begeman // and false if the comparison is false. All other bits in each element 369b43e9c196542acc80c9e4643809661065710848fNate Begeman // are undefined. The operands to this are the left and right operands 370b43e9c196542acc80c9e4643809661065710848fNate Begeman // to compare (ops #0, and #1) and the condition code to compare them with 371b43e9c196542acc80c9e4643809661065710848fNate Begeman // (op #2) as a CondCodeSDNode. 372b43e9c196542acc80c9e4643809661065710848fNate Begeman VSETCC, 373b43e9c196542acc80c9e4643809661065710848fNate Begeman 37414c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // SHL_PARTS/SRA_PARTS/SRL_PARTS - These operators are used for expanded 37514c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // integer shift operations, just like ADD/SUB_PARTS. The operation 37614c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner // ordering is: 3776b8f2d649c1e96e0222be9de1e5d6c79e3eef021Chris Lattner // [Lo,Hi] = op [LoLHS,HiLHS], Amt 37814c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner SHL_PARTS, SRA_PARTS, SRL_PARTS, 37914c5b53c037a6a175118ed1a7d7e0e74153d56c4Chris Lattner 38063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Conversion operators. These are all single input single output 38163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operations. For all of these, the result type must be strictly 38263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // wider or narrower (depending on the operation) than the source 38363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // type. 38463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 38563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // SIGN_EXTEND - Used for integer types, replicating the sign bit 38663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // into new bits. 38763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SIGN_EXTEND, 38863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 38963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // ZERO_EXTEND - Used for integer types, zeroing the new bits. 39063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ZERO_EXTEND, 39163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3927e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner // ANY_EXTEND - Used for integer types. The high bits are undefined. 3937e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner ANY_EXTEND, 3947e122db776d9731dfe5acb7faa9da4f3c33ee5a1Chris Lattner 39563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // TRUNCATE - Completely drop the high bits. 39663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner TRUNCATE, 39763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3981645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // [SU]INT_TO_FP - These operators convert integers (whose interpreted sign 3991645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner // depends on the first letter) to floating point. 4001645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner SINT_TO_FP, 4011645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner UINT_TO_FP, 4021645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 403ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to 404ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // sign extend a small value in a large integer register (e.g. sign 405ea5761068956b157832d67bcc9d5e8ba706f545cChris Lattner // extending the low 8 bits of a 32-bit register to fill the top 24 bits 40615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // with the 7th bit). The size of the smaller type is indicated by the 1th 40715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner // operand, a ValueType node. 408859157daee6a4b49e99921832e1dde065167b317Chris Lattner SIGN_EXTEND_INREG, 409859157daee6a4b49e99921832e1dde065167b317Chris Lattner 4100bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_TO_[US]INT - Convert a floating point value to a signed or unsigned 4110bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// integer. 4121645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_SINT, 4131645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner FP_TO_UINT, 4141645ed0b93901ec678cd54024c8b09bca632b296Chris Lattner 4150bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type 4160bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// down to the precision of the destination VT. TRUNC is a flag, which is 4170bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// always an integer that is zero or one. If TRUNC is 0, this is a 4180bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// normal rounding, if it is 1, this FP_ROUND is known to not change the 4190bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// value of Y. 4200bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// 4210bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// The TRUNC = 1 case is used in cases where we know that the value will 4220bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// not be modified by the node, because Y is not using any of the extra 4230bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// precision of source type. This allows certain transformations like 4240bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,1)) -> X which are not safe for 4250bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// FP_EXTEND(FP_ROUND(X,0)) because the extra bits aren't removed. 42663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_ROUND, 4270bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner 4281a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman // FLT_ROUNDS_ - Returns current rounding mode: 429917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // -1 Undefined 430917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 0 Round to 0 431917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 1 Round to nearest 432917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 2 Round to +inf 433917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov // 3 Round to -inf 4341a0248690aaa9f7baaf1247e5f65a1c0c9e3783cDan Gohman FLT_ROUNDS_, 435917c2a6ff2cfcd1263a5dd80c54336754c553aceAnton Korobeynikov 4360bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_ROUND_INREG(Y, VT) - This operator takes an FP register, and 4370bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// rounds it to a floating point value. It then promotes it and returns it 4380bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// in a register of the same size. This operation effectively just 4390bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// discards excess precision. The type to round down to is specified by 4400bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// the VT operand, a VTSDNode. 441859157daee6a4b49e99921832e1dde065167b317Chris Lattner FP_ROUND_INREG, 442859157daee6a4b49e99921832e1dde065167b317Chris Lattner 4430bd4893a0726889b942405262e53d06cf3fe3be8Chris Lattner /// X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type. 44463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner FP_EXTEND, 44563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4461ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // BIT_CONVERT - Theis operator converts between integer and FP values, as 4471ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner // if one was stored to memory as integer and the other was loaded from the 44880f55abf009c86bc03821e10746832f88f8a735fChris Lattner // same address (or equivalently for vector format conversions, etc). The 44980f55abf009c86bc03821e10746832f88f8a735fChris Lattner // source and result are required to have the same bit size (e.g. 45080f55abf009c86bc03821e10746832f88f8a735fChris Lattner // f32 <-> i32). This can also be used for int-to-int or fp-to-fp 45180f55abf009c86bc03821e10746832f88f8a735fChris Lattner // conversions, but that is a noop, deleted by getNode(). 4521ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner BIT_CONVERT, 4531ac1c4b9d2877bd2d15bcf578bc617a605d815b0Chris Lattner 45477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // CONVERT_RNDSAT - This operator is used to support various conversions 45500ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang // between various types (float, signed, unsigned and vectors of those 45600ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang // types) with rounding and saturation. NOTE: Avoid using this operator as 45700ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang // most target don't support it and the operator might be removed in the 45800ec49b6bafc33ee17d97ec1c723e1edb41d4c97Mon P Wang // future. It takes the following arguments: 45977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 0) value 46077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 1) dest type (type to convert to) 46177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 2) src type (type to convert from) 46277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 3) rounding imm 46377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 4) saturation imm 46477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang // 5) ISD::CvtCode indicating the type of conversion to do 46577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CONVERT_RNDSAT, 46677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 467509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman // FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, 4687794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen // FLOG, FLOG2, FLOG10, FEXP, FEXP2, 4698471ef5f4e79fbe4d7021e91d45e39fdbf8783fcDan Gohman // FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR - Perform various unary floating 470509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman // point operations. These are inspired by libm. 47107f04fd574a59c690f297fd10c2e0dd14093675eDan Gohman FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, 4727794f2a3a7778bdbc9bdd861db1fe914450e0470Dale Johannesen FLOG, FLOG2, FLOG10, FEXP, FEXP2, 473509e84fa7146175c86dec5ef2167290f294dc89eDan Gohman FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR, 47438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 4758862ef148100070b7bf28beead3951464250c926Evan Cheng // LOAD and STORE have token chains as their first operand, then the same 4768862ef148100070b7bf28beead3951464250c926Evan Cheng // operands as an LLVM load/store instruction, then an offset node that 4778862ef148100070b7bf28beead3951464250c926Evan Cheng // is added / subtracted from the base pointer to form the address (for 4788862ef148100070b7bf28beead3951464250c926Evan Cheng // indexed memory ops). 47963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner LOAD, STORE, 480ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 48163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned 48257fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // to a specified boundary. This node always has two return values: a new 48357fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // stack pointer value and a chain. The first operand is the token chain, 48457fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // the second is the number of bytes to allocate, and the third is the 48557fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment boundary. The size is guaranteed to be a multiple of the stack 48657fc00d5cf47343ba762493b8781ca0b14489c35Anton Korobeynikov // alignment, and the alignment is guaranteed to be bigger than the stack 48774fe063e90045931eefaba561730e6a9175ced78Chris Lattner // alignment (if required) or 0 to get standard stack alignment. 48863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner DYNAMIC_STACKALLOC, 48963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 49063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Control flow instructions. These all have token chains. 491ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 49263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BR - Unconditional branch. The first operand is the chain 49363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // operand, the second is the MBB to branch to. 49463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BR, 49563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 49637efe6764568a3829fee26aba532283131d1a104Nate Begeman // BRIND - Indirect branch. The first operand is the chain, the second 49737efe6764568a3829fee26aba532283131d1a104Nate Begeman // is the value to branch to, which must be of the same type as the target's 49837efe6764568a3829fee26aba532283131d1a104Nate Begeman // pointer type. 49937efe6764568a3829fee26aba532283131d1a104Nate Begeman BRIND, 500c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng 501c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // BR_JT - Jumptable branch. The first operand is the chain, the second 502c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng // is the jumptable index, the last one is the jumptable entry index. 503c41cd9c391f1f69adf416145a5a1308d7ce342fcEvan Cheng BR_JT, 50447b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands 50547b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands // BRCOND - Conditional branch. The first operand is the chain, the 50647b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands // second is the condition, the third is the block to branch to if the 50747b3417cf0d90724f9dab71aae4c7204e46847b6Duncan Sands // condition is true. If the type of the condition is not i1, then the 50803228089d5235f8c90477f88809139464e9c6ea5Duncan Sands // high bits must conform to getBooleanContents. 50963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BRCOND, 51063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 5117cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // BR_CC - Conditional branch. The behavior is like that of SELECT_CC, in 5127cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // that the condition is represented as condition code, and two nodes to 5137cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // compare, rather than as a combined SetCC node. The operands in order are 5147cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman // chain, cc, lhs, rhs, block to branch to if condition is true. 5157cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman BR_CC, 5167cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman 51763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // RET - Return from function. The first operand is the chain, 5188e7d056bc5c0688501f6721994c8f4074d699c69Evan Cheng // and any subsequent operands are pairs of return value and return value 519c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen // attributes (see CALL for description of attributes) for the function. 520c9c6da61ac027d9818652d417907f84398288b99Dale Johannesen // This operation can have variable number of operands. 52163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner RET, 52263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 5237572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // INLINEASM - Represents an inline asm block. This node always has two 5247572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // return values: a chain and a flag result. The inputs are as follows: 5257572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #0 : Input chain. 526056292fd738924f3f7703725d8f630983794b5a5Bill Wendling // Operand #1 : a ExternalSymbolSDNode with a pointer to the asm string. 5277572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+2: A RegisterNode. 5287572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #2n+3: A TargetConstant, indicating if the reg is a use/def 5297572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner // Operand #last: Optional, an incoming flag. 5307572eb81eee93b0c666ddc5f5ff0ff72f17574fdChris Lattner INLINEASM, 5311ee29257428960fede862fcfdbe80d5d007927e9Jim Laskey 5324406604047423576e36657c7ede266ca42e79642Dan Gohman // DBG_LABEL, EH_LABEL - Represents a label in mid basic block used to track 5334406604047423576e36657c7ede266ca42e79642Dan Gohman // locations needed for debug and exception handling tables. These nodes 5344406604047423576e36657c7ede266ca42e79642Dan Gohman // take a chain as input and return a chain. 5354406604047423576e36657c7ede266ca42e79642Dan Gohman DBG_LABEL, 5364406604047423576e36657c7ede266ca42e79642Dan Gohman EH_LABEL, 537a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng 538a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // DECLARE - Represents a llvm.dbg.declare intrinsic. It's used to track 539a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // local variable declarations for debugging information. First operand is 540a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // a chain, while the next two operands are first two arguments (address 541a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng // and variable) of a llvm.dbg.declare instruction. 542a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng DECLARE, 543f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey 5445a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKSAVE - STACKSAVE has one operand, an input chain. It produces a 5455a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // value, the same type as the pointer type for the system, and an output 5465a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // chain. 5475a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKSAVE, 5485a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 5495a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // STACKRESTORE has two operands, an input chain and a pointer to restore to 5505a67afc118d47a0061ca9809c763451ea3125306Chris Lattner // it returns an output chain. 5515a67afc118d47a0061ca9809c763451ea3125306Chris Lattner STACKRESTORE, 5525a67afc118d47a0061ca9809c763451ea3125306Chris Lattner 55316cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of 55416cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // a call sequence, and carry arbitrary information that target might want 55516cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // to know. The first operand is a chain, the rest are specified by the 55616cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner // target and not touched by the DAG optimizers. 5570ea0356dff38dfd0420b8c0a2fdf2fae7898c024Dale Johannesen // CALLSEQ_START..CALLSEQ_END pairs may not be nested. 55816cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_START, // Beginning of a call sequence 55916cd04d26c53c6f81313cafb85f6c0e7a07cdff6Chris Lattner CALLSEQ_END, // End of a call sequence 560acc398c195a697795bff3245943d104eb19192b9Nate Begeman 561acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAARG - VAARG has three operands: an input chain, a pointer, and a 562acc398c195a697795bff3245943d104eb19192b9Nate Begeman // SRCVALUE. It returns a pair of values: the vaarg value and a new chain. 563acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAARG, 564acc398c195a697795bff3245943d104eb19192b9Nate Begeman 565acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VACOPY - VACOPY has five operands: an input chain, a destination pointer, 566acc398c195a697795bff3245943d104eb19192b9Nate Begeman // a source pointer, a SRCVALUE for the destination, and a SRCVALUE for the 567acc398c195a697795bff3245943d104eb19192b9Nate Begeman // source. 568acc398c195a697795bff3245943d104eb19192b9Nate Begeman VACOPY, 569acc398c195a697795bff3245943d104eb19192b9Nate Begeman 570acc398c195a697795bff3245943d104eb19192b9Nate Begeman // VAEND, VASTART - VAEND and VASTART have three operands: an input chain, a 571acc398c195a697795bff3245943d104eb19192b9Nate Begeman // pointer, and a SRCVALUE. 572acc398c195a697795bff3245943d104eb19192b9Nate Begeman VAEND, VASTART, 57363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 57469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // SRCVALUE - This is a node type that holds a Value* that is used to 57569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // make reference to a value in the LLVM IR. 57621074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner SRCVALUE, 57721074f43ed5165828717ea3606eb2bd222a39b26Chris Lattner 57836b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // MEMOPERAND - This is a node that contains a MachineMemOperand which 57936b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // records information about a memory reference. This is used to make 58036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman // AliasAnalysis queries from the backend. 58169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman MEMOPERAND, 58269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 583e3f570c3f9048bc71a9f5841343eae63719e439bMisha Brukman // PCMARKER - This corresponds to the pcmarker intrinsic. 58495762124a1d781cc0f8cbc4c22e9c5c1358d7ea0Andrew Lenharth PCMARKER, 58563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 586aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth // READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic. 5878b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // The only operand is a chain and a value and a chain are produced. The 5888b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // value is the contents of the architecture specific cycle counter like 5898b91c77385a055474d271aa8c10f0382fdeaafebAndrew Lenharth // register (or other high accuracy low latency clock source) 590aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth READCYCLECOUNTER, 591aeef8fc5c6124a34bd2a723071a3982b559c26f2Andrew Lenharth 592d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner // HANDLENODE node - Used as a handle for various purposes. 593d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner HANDLENODE, 5942d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 5957f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman // DBG_STOPPOINT - This node is used to represent a source location for 5967f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman // debug info. It takes token chain as input, and carries a line number, 59783489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel // column number, and a pointer to a CompileUnit object identifying 5987f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman // the containing compilation unit. It produces a token chain as output. 5997f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman DBG_STOPPOINT, 60047725d059b259f8a0c145478300c9e9caa006b59Chris Lattner 601f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey // DEBUG_LOC - This node is used to represent source line information 602abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // embedded in the code. It takes a token chain as input, then a line 60344c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey // number, then a column then a file id (provided by MachineModuleInfo.) It 604abf6d1784b2d4bbcb7d20ab64881f77d755059f6Jim Laskey // produces a token chain as output. 605f5395cee6a24699a016b2e379cf4804b09ce5030Jim Laskey DEBUG_LOC, 60636397f50343639ce9a25996f2d790c656791ab92Duncan Sands 60736397f50343639ce9a25996f2d790c656791ab92Duncan Sands // TRAMPOLINE - This corresponds to the init_trampoline intrinsic. 60836397f50343639ce9a25996f2d790c656791ab92Duncan Sands // It takes as input a token chain, the pointer to the trampoline, 60936397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the pointer to the nested function, the pointer to pass for the 61036397f50343639ce9a25996f2d790c656791ab92Duncan Sands // 'nest' parameter, a SRCVALUE for the trampoline and another for 61136397f50343639ce9a25996f2d790c656791ab92Duncan Sands // the nested function (allowing targets to access the original 612f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // Function*). It produces the result of the intrinsic and a token 613f7331b3dd72409e644833ecaf62a0f6db03c97eeDuncan Sands // chain as output. 61436397f50343639ce9a25996f2d790c656791ab92Duncan Sands TRAMPOLINE, 61536397f50343639ce9a25996f2d790c656791ab92Duncan Sands 61666fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov // TRAP - Trapping instruction 61766fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov TRAP, 61866fac79b899904ddd82e5ee354a6d370d80230f6Anton Korobeynikov 61927b7db549e4c5bff4579d209304de5628513edebEvan Cheng // PREFETCH - This corresponds to a prefetch intrinsic. It takes chains are 62027b7db549e4c5bff4579d209304de5628513edebEvan Cheng // their first operand. The other operands are the address to prefetch, 62127b7db549e4c5bff4579d209304de5628513edebEvan Cheng // read / write specifier, and locality specifier. 62227b7db549e4c5bff4579d209304de5628513edebEvan Cheng PREFETCH, 62327b7db549e4c5bff4579d209304de5628513edebEvan Cheng 62422c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load, 62522c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // store-store, device) 626ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // This corresponds to the memory.barrier intrinsic. 62722c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // it takes an input chain, 4 operands to specify the type of barrier, an 62822c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // operand specifying if the barrier applies to device and uncached memory 62922c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth // and produces an output chain. 63022c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth MEMBARRIER, 63122c5c1b2dfcb1da6a7ebfebea903401fc77d56e6Andrew Lenharth 63228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) 633ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.lcs intrinsic. 634ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // cmp is compared to *ptr, and if equal, swap is stored in *ptr. 635ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 6360b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_CMP_SWAP, 637ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 638ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) 639ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // this corresponds to the atomic.swap intrinsic. 640ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // amt is stored to *ptr atomically. 641ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth // the return is always the original value in *ptr 6420b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_SWAP, 643ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 644a82a91850779f7c3a173a5828333dfd5162f855dDan Gohman // Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt) 645a82a91850779f7c3a173a5828333dfd5162f855dDan Gohman // this corresponds to the atomic.load.[OpName] intrinsic. 64663307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // op(*ptr, amt) is stored to *ptr atomically. 64763307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang // the return is always the original value in *ptr 6480b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_ADD, 6490b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_SUB, 6500b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_AND, 6510b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_OR, 6520b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_XOR, 6530b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_NAND, 6540b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_MIN, 6550b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_MAX, 6560b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_UMIN, 6570b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman ATOMIC_LOAD_UMAX, 65863307c335aa08b0d6a75f81d64d79af7e90eb78bMon P Wang 65963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILTIN_OP_END - This must be the last enum value in this list. 660410354fe0c052141dadeca939395743f8dd58e38Chris Lattner BUILTIN_OP_END 66163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 66263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 663322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// Node predicates 664322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 665a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng /// isBuildVectorAllOnes - Return true if the specified node is a 666322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner /// BUILD_VECTOR where all of the elements are ~0 or undef. 667a8df166fbef047c90adba3c673162a1b1f6681c4Evan Cheng bool isBuildVectorAllOnes(const SDNode *N); 6684a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng 6694a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// isBuildVectorAllZeros - Return true if the specified node is a 6704a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng /// BUILD_VECTOR where all of the elements are 0 or undef. 6714a147842eb24a7611fcd7bfb37c55185b4664927Evan Cheng bool isBuildVectorAllZeros(const SDNode *N); 672bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng 673efec751a1b786724862ceff52748df94873a807eEvan Cheng /// isScalarToVector - Return true if the specified node is a 674efec751a1b786724862ceff52748df94873a807eEvan Cheng /// ISD::SCALAR_TO_VECTOR node or a BUILD_VECTOR node where only the low 675efec751a1b786724862ceff52748df94873a807eEvan Cheng /// element is not an undef. 676efec751a1b786724862ceff52748df94873a807eEvan Cheng bool isScalarToVector(const SDNode *N); 677efec751a1b786724862ceff52748df94873a807eEvan Cheng 678bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng /// isDebugLabel - Return true if the specified node represents a debug 6794406604047423576e36657c7ede266ca42e79642Dan Gohman /// label (i.e. ISD::DBG_LABEL or TargetInstrInfo::DBG_LABEL node). 680bb81d97feb396a8bb21d074db1c57e9f66525f40Evan Cheng bool isDebugLabel(const SDNode *N); 681322dcd379eb19ea8d01478a661920ea1ce62fa0dChris Lattner 68263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 683144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// MemIndexedMode enum - This enum defines the load / store indexed 684144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng /// addressing modes. 68524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 68624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// UNINDEXED "Normal" load / store. The effective address is already 68724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computed and is available in the base pointer. The offset 68881c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// operand is always undefined. In addition to producing a 68981c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// chain, an unindexed load produces one value (result of the 690276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// load); an unindexed store does not produce a value. 69124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 69235acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// PRE_INC Similar to the unindexed mode where the effective address is 6938862ef148100070b7bf28beead3951464250c926Evan Cheng /// PRE_DEC the value of the base pointer add / subtract the offset. 6948862ef148100070b7bf28beead3951464250c926Evan Cheng /// It considers the computation as being folded into the load / 69524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// store operation (i.e. the load / store does the address 69624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// computation as well as performing the memory transaction). 69781c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// The base operand is always undefined. In addition to 69881c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// producing a chain, pre-indexed load produces two values 69981c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// (result of the load and the result of the address 70081c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// computation); a pre-indexed store produces one value (result 70181c384578828dde08f63a4f030f4860a92391cddEvan Cheng /// of the address computation). 70224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 70335acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng /// POST_INC The effective address is the value of the base pointer. The 7048862ef148100070b7bf28beead3951464250c926Evan Cheng /// POST_DEC value of the offset operand is then added to / subtracted 7058862ef148100070b7bf28beead3951464250c926Evan Cheng /// from the base after memory transaction. In addition to 7068862ef148100070b7bf28beead3951464250c926Evan Cheng /// producing a chain, post-indexed load produces two values 7078862ef148100070b7bf28beead3951464250c926Evan Cheng /// (the result of the load and the result of the base +/- offset 7088862ef148100070b7bf28beead3951464250c926Evan Cheng /// computation); a post-indexed store produces one value (the 7098862ef148100070b7bf28beead3951464250c926Evan Cheng /// the result of the base +/- offset computation). 71024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 711144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng enum MemIndexedMode { 71224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng UNINDEXED = 0, 71335acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_INC, 71435acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng PRE_DEC, 71535acd30a2e96a5a4ad9fa837971af2cc583bcd1fEvan Cheng POST_INC, 716144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng POST_DEC, 717144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng LAST_INDEXED_MODE 71824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng }; 71924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 72024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng //===--------------------------------------------------------------------===// 721c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// LoadExtType enum - This enum defines the three variants of LOADEXT 722c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// (load with extension). 723c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 72424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// SEXTLOAD loads the integer operand and sign extends it to a larger 72524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 72624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// ZEXTLOAD loads the integer operand and zero extends it to a larger 72724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer result type. 72824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// EXTLOAD is used for three things: floating point extending loads, 72924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// integer extending loads [the top bits are undefined], and vector 73024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// extending loads [load into low elt]. 73124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// 732c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng enum LoadExtType { 73324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng NON_EXTLOAD = 0, 734c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng EXTLOAD, 735c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng SEXTLOAD, 736c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng ZEXTLOAD, 7370329466b6b4927f4e6f5d144891fef06a027fec5Evan Cheng LAST_LOADEXT_TYPE 738c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng }; 739c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 740c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng //===--------------------------------------------------------------------===// 74163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// ISD::CondCode enum - These are ordered carefully to make the bitfields 74263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// below work out, when considering SETFALSE (something that never exists 74363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// dynamically) as 0. "U" -> Unsigned (for integer operands) or Unordered 74463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// (for floating point), "L" -> Less than, "G" -> Greater than, "E" -> Equal 74563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to. If the "N" column is 1, the result of the comparison is undefined if 74663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the input is a NAN. 74763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 74863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// All of these (except for the 'always folded ops') should be handled for 74963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// floating point. For integer, only the SETEQ,SETNE,SETLT,SETLE,SETGT, 75063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// SETGE,SETULT,SETULE,SETUGT, and SETUGE opcodes are used. 75163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 75263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// Note that these are laid out in a specific order to allow bit-twiddling 75363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// to transform conditions. 75463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum CondCode { 75563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Opcode N U L G E Intuitive operation 75663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE, // 0 0 0 0 Always false (always folded) 75763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOEQ, // 0 0 0 1 True if ordered and equal 75863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGT, // 0 0 1 0 True if ordered and greater than 75963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOGE, // 0 0 1 1 True if ordered and greater than or equal 76063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLT, // 0 1 0 0 True if ordered and less than 76163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETOLE, // 0 1 0 1 True if ordered and less than or equal 76263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETONE, // 0 1 1 0 True if ordered and operands are unequal 76363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETO, // 0 1 1 1 True if ordered (no nans) 76463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUO, // 1 0 0 0 True if unordered: isnan(X) | isnan(Y) 76563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUEQ, // 1 0 0 1 True if unordered or equal 76663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGT, // 1 0 1 0 True if unordered or greater than 76763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUGE, // 1 0 1 1 True if unordered, greater than, or equal 76863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETULT, // 1 1 0 0 True if unordered or less than 769ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETULE, // 1 1 0 1 True if unordered, less than, or equal 77063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETUNE, // 1 1 1 0 True if unordered or not equal 77163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE, // 1 1 1 1 Always true (always folded) 77263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Don't care operations: undefined if the input is a nan. 77363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETFALSE2, // 1 X 0 0 0 Always false (always folded) 77463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETEQ, // 1 X 0 0 1 True if equal 77563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGT, // 1 X 0 1 0 True if greater than 77663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETGE, // 1 X 0 1 1 True if greater than or equal 77763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETLT, // 1 X 1 0 0 True if less than 778ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SETLE, // 1 X 1 0 1 True if less than or equal 77963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETNE, // 1 X 1 1 0 True if not equal 78063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner SETTRUE2, // 1 X 1 1 1 Always true (always folded) 78163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 782410354fe0c052141dadeca939395743f8dd58e38Chris Lattner SETCC_INVALID // Marker value. 78363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner }; 78463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 78563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isSignedIntSetCC - Return true if this is a setcc instruction that 78663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs a signed comparison when used with integer operands. 78763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isSignedIntSetCC(CondCode Code) { 78863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETGT || Code == SETGE || Code == SETLT || Code == SETLE; 78963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 79063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 79163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isUnsignedIntSetCC - Return true if this is a setcc instruction that 79263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// performs an unsigned comparison when used with integer operands. 79363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isUnsignedIntSetCC(CondCode Code) { 79463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return Code == SETUGT || Code == SETUGE || Code == SETULT || Code == SETULE; 79563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 79663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 79763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isTrueWhenEqual - Return true if the specified condition returns true if 79863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// the two operands to the condition are equal. Note that if one of the two 79963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operands is a NaN, this value is meaningless. 80063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline bool isTrueWhenEqual(CondCode Cond) { 80163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond & 1) != 0; 80263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 80363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 80463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getUnorderedFlavor - This function returns 0 if the condition is always 80563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// false if an operand is a NaN, 1 if the condition is always true if the 80663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operand is a NaN, and 2 if the condition is undefined if the operand is a 80763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// NaN. 80863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getUnorderedFlavor(CondCode Cond) { 80963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return ((int)Cond >> 3) & 3; 81063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 81163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 81263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCInverse - Return the operation corresponding to !(X op Y), where 81363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 'op' is a valid SetCC operation. 81463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCInverse(CondCode Operation, bool isInteger); 81563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 81663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCSwappedOperands - Return the operation corresponding to (Y op X) 81763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// when given the operation for (X op Y). 81863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCSwappedOperands(CondCode Operation); 81963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 82063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCOrOperation - Return the result of a logical OR between different 82163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// comparisons of identical values: ((X op1 Y) | (X op2 Y)). This 82263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 82363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 82463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCOrOperation(CondCode Op1, CondCode Op2, bool isInteger); 82563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 82663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getSetCCAndOperation - Return the result of a logical AND between 82763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// different comparisons of identical values: ((X op1 Y) & (X op2 Y)). This 82863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// function returns SETCC_INVALID if it is not possible to represent the 82963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// resultant comparison. 83063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CondCode getSetCCAndOperation(CondCode Op1, CondCode Op2, bool isInteger); 83177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 83277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang //===--------------------------------------------------------------------===// 83377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang /// CvtCode enum - This enum defines the various converts CONVERT_RNDSAT 83477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang /// supports. 83577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang enum CvtCode { 83677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_FF, // Float from Float 83777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_FS, // Float from Signed 83877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_FU, // Float from Unsigned 83977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_SF, // Signed from Float 84077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_UF, // Unsigned from Float 84177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_SS, // Signed from Signed 84277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_SU, // Signed from Unsigned 84377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_US, // Unsigned from Signed 84477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_UU, // Unsigned from Unsigned 84577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang CVT_INVALID // Marker - Invalid opcode 84677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang }; 84763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm::ISD namespace 84863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 84963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 85063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner//===----------------------------------------------------------------------===// 851475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValue - Unlike LLVM values, Selection DAG nodes may return multiple 85263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// values as the result of a computation. Many nodes return multiple values, 85363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// from loads (which define a token and a return value) to ADDC (which returns 85463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// a result and a carry value), to calls (which may return an arbitrary number 85563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// of values). 85663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 85763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// As such, each use of a SelectionDAG computation must indicate the node that 85863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// computes it as well as which return value to use from that node. This pair 859475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// of information is represented with the SDValue value type. 86063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 861475871a144eb604ddaf37503397ba0941442e5fbDan Gohmanclass SDValue { 862ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDNode *Node; // The node defining the value we are using. 86363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned ResNo; // Which return value of the node we are using. 86499a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greifpublic: 865ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDValue() : Node(0), ResNo(0) {} 866ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDValue(SDNode *node, unsigned resno) : Node(node), ResNo(resno) {} 86763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 86899a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif /// get the index which selects a specific result in the SDNode 86999a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif unsigned getResNo() const { return ResNo; } 87099a6cb92d173c142073416c81efe6d3daeb80b49Gabor Greif 871ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif /// get the SDNode which holds the desired result 872ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif SDNode *getNode() const { return Node; } 873ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif 874ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif /// set the SDNode 875ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif void setNode(SDNode *N) { Node = N; } 876ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif 877475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator==(const SDValue &O) const { 878ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node == O.Node && ResNo == O.ResNo; 87963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 880475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator!=(const SDValue &O) const { 88163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return !operator==(O); 88263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 883475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool operator<(const SDValue &O) const { 884ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node < O.Node || (Node == O.Node && ResNo < O.ResNo); 88563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 88663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 887475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getValue(unsigned R) const { 888ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return SDValue(Node, R); 88963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 89063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 891917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng // isOperandOf - Return true if this node is an operand of N. 892917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOperandOf(SDNode *N) const; 893bfa284f69752c54f81bffc2b0d15d5c1e618a659Evan Cheng 89463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the ValueType of the referenced return value. 89563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 89683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands inline MVT getValueType() const; 897ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 89883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands /// getValueSizeInBits - Returns the size of the value in bits. 8994fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// 9004fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman unsigned getValueSizeInBits() const { 90183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands return getValueType().getSizeInBits(); 9024fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman } 9034fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman 90463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Forwarding methods - These forward to the corresponding methods in SDNode. 90563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getOpcode() const; 90663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner inline unsigned getNumOperands() const; 907475871a144eb604ddaf37503397ba0941442e5fbDan Gohman inline const SDValue &getOperand(unsigned i) const; 908c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline uint64_t getConstantOperandVal(unsigned i) const; 9090f66a9172175aa7c3055333358170581c999219bNate Begeman inline bool isTargetOpcode() const; 910e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman inline bool isMachineOpcode() const; 911e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman inline unsigned getMachineOpcode() const; 912124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen inline const DebugLoc getDebugLoc() const; 913a44f4aeca77c6c1627568fe68e92af9c7e33dc7eChris Lattner 914572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 915572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// reachesChainWithoutSideEffects - Return true if this operand (which must 916572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// be a chain) reaches the specified operand without crossing any 917572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// side-effecting instructions. In practice, this looks through token 918572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// factors and non-volatile loads. In order to remain efficient, this only 919572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// looks a couple of nodes in, it does not do an exhaustive search. 920475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool reachesChainWithoutSideEffects(SDValue Dest, 921dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein unsigned Depth = 2) const; 922572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner 9237a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// use_empty - Return true if there are no nodes using value ResNo 924ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif /// of Node. 9257a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 926e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman inline bool use_empty() const; 9277a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman 928231fe7054160d2953e0cc6635f9a171a4b311af2Gabor Greif /// hasOneUse - Return true if there is exactly one node using value 929ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif /// ResNo of Node. 9307a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 9317a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman inline bool hasOneUse() const; 93263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 93363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 93463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 935475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct DenseMapInfo<SDValue> { 936475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static inline SDValue getEmptyKey() { 937475871a144eb604ddaf37503397ba0941442e5fbDan Gohman return SDValue((SDNode*)-1, -1U); 938dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 939475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static inline SDValue getTombstoneKey() { 940475871a144eb604ddaf37503397ba0941442e5fbDan Gohman return SDValue((SDNode*)-1, 0); 941dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 942475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static unsigned getHashValue(const SDValue &Val) { 943ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^ 944ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo(); 945c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng } 946475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static bool isEqual(const SDValue &LHS, const SDValue &RHS) { 94776c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner return LHS == RHS; 94876c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattner } 949c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng static bool isPod() { return true; } 950c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng}; 951c63d391c9a886d58c6a53a7f565fbd544b076d9fEvan Cheng 95263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// simplify_type specializations - Allow casting operators to work directly on 953475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s. 954475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<SDValue> { 955dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein typedef SDNode* SimpleType; 956475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static SimpleType getSimplifiedValue(const SDValue &Val) { 957ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return static_cast<SimpleType>(Val.getNode()); 958dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 959dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 960475871a144eb604ddaf37503397ba0941442e5fbDan Gohmantemplate<> struct simplify_type<const SDValue> { 961dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein typedef SDNode* SimpleType; 962475871a144eb604ddaf37503397ba0941442e5fbDan Gohman static SimpleType getSimplifiedValue(const SDValue &Val) { 963ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return static_cast<SimpleType>(Val.getNode()); 964dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 965dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 966dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 967e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// SDUse - Represents a use of a SDNode. This class holds an SDValue, 968e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// which records the SDNode being used and the result number, a 969e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// pointer to the SDNode using the value, and Next and Prev pointers, 970e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// which link together all the uses of an SDNode. 971e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman/// 9729cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteinclass SDUse { 973e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// Val - The value being used. 974e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman SDValue Val; 975e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// User - The user of this value. 976e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman SDNode *User; 977e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// Prev, Next - Pointers to the uses list of the SDNode referred by 978dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// this operand. 9799cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse **Prev, *Next; 980dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 981e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman SDUse(const SDUse &U); // Do not implement 982e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void operator=(const SDUse &U); // Do not implement 983dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 984e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanpublic: 985e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman SDUse() : Val(), User(NULL), Prev(NULL), Next(NULL) {} 986dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 987e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// Normally SDUse will just implicitly convert to an SDValue that it holds. 988e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman operator const SDValue&() const { return Val; } 989dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 990e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// If implicit conversion to SDValue doesn't work, the get() method returns 991e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// the SDValue. 992e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman const SDValue &get() const { return Val; } 993e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 994e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// getUser - This returns the SDNode that contains this Use. 99502819257a625d0d9a186845354baadd6e8f1890bRoman Levenstein SDNode *getUser() { return User; } 9969cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 997e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// getNext - Get the next SDUse in the use list. 998e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman SDUse *getNext() const { return Next; } 9999cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1000e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// getNode - Convenience function for get().getNode(). 1001e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman SDNode *getNode() const { return Val.getNode(); } 1002e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// getResNo - Convenience function for get().getResNo(). 1003e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman unsigned getResNo() const { return Val.getResNo(); } 1004e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// getValueType - Convenience function for get().getValueType(). 1005e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman MVT getValueType() const { return Val.getValueType(); } 10069cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1007e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// operator== - Convenience function for get().operator== 1008e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman bool operator==(const SDValue &V) const { 1009e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman return Val == V; 10109cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 1011e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1012e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// operator!= - Convenience function for get().operator!= 1013e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman bool operator!=(const SDValue &V) const { 1014e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman return Val != V; 10159cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10169cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1017e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// operator< - Convenience function for get().operator< 1018e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman bool operator<(const SDValue &V) const { 1019e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman return Val < V; 10209cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 10219cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein 1022e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanprivate: 1023e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman friend class SelectionDAG; 1024e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman friend class SDNode; 1025e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1026e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void setUser(SDNode *p) { User = p; } 1027e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1028e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// set - Remove this use from its existing use list, assign it the 1029e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// given value, and add it to the new value's node's use list. 1030e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman inline void set(const SDValue &V); 1031e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// setInitial - like set, but only supports initializing a newly-allocated 1032e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// SDUse with a non-null value. 1033e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman inline void setInitial(const SDValue &V); 1034e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// setNode - like set, but only sets the Node portion of the value, 1035e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// leaving the ResNo portion unmodified. 1036e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman inline void setNode(SDNode *N); 1037e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 10389cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein void addToList(SDUse **List) { 1039dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Next = *List; 1040dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein if (Next) Next->Prev = &Next; 1041dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Prev = List; 1042dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein *List = this; 1043dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1044dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1045dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein void removeFromList() { 1046dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein *Prev = Next; 1047dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein if (Next) Next->Prev = Prev; 1048dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1049dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein}; 1050dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1051dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein/// simplify_type specializations - Allow casting operators to work directly on 1052475871a144eb604ddaf37503397ba0941442e5fbDan Gohman/// SDValues as if they were SDNode*'s. 10539cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<SDUse> { 105463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 10559cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static SimpleType getSimplifiedValue(const SDUse &Val) { 1056e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman return static_cast<SimpleType>(Val.getNode()); 105763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 105863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 10599cac5259fe237120a0c347d6d14e549005148f1bRoman Levensteintemplate<> struct simplify_type<const SDUse> { 106063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner typedef SDNode* SimpleType; 10619cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein static SimpleType getSimplifiedValue(const SDUse &Val) { 1062e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman return static_cast<SimpleType>(Val.getNode()); 106363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 106463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 106563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 106663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 106763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SDNode - Represents one node in the SelectionDAG. 106863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 1069fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass SDNode : public FoldingSetNode, public ilist_node<SDNode> { 1070dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levensteinprivate: 10710442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// NodeType - The operation that this node performs. 10720442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 1073e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman short NodeType; 107463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 107563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// OperandsNeedDelete - This is true if OperandList was new[]'d. If true, 107663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner /// then they will be delete[]'d when the node is destroyed. 1077ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman unsigned short OperandsNeedDelete : 1; 10780442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 1079ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprotected: 1080ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// SubclassData - This member is defined by this class, but is not used for 1081ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// anything. Subclasses can use it to hold whatever state they find useful. 1082ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// This field is initialized to zero by the ctor. 1083ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman unsigned short SubclassData : 15; 1084ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman 1085ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohmanprivate: 1086b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// NodeId - Unique id per SDNode in the DAG. 1087b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int NodeId; 10880442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 10893b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// debugLoc - source line information. 10903b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen DebugLoc debugLoc; 10913b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen 1092f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// OperandList - The values that are used by this operation. 10930442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 10949cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *OperandList; 1095f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner 1096f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// ValueList - The types of the values this node defines. SDNode's may 1097f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// define multiple values simultaneously. 109883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *ValueList; 109963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1100f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// NumOperands/NumValues - The number of entries in the Operand/Value list. 1101f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned short NumOperands, NumValues; 1102b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 1103e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// UseList - List of uses for this SDNode. 1104e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman SDUse *UseList; 1105dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1106e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// getValueTypeList - Return a pointer to the specified value type. 1107e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman static const MVT *getValueTypeList(MVT VT); 1108e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1109e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman friend class SelectionDAG; 1110e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman friend struct ilist_traits<SDNode>; 1111dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 111263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 111363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 111463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // Accessors 111563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // 1116e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 1117e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// getOpcode - Return the SelectionDAG opcode value for this node. For 1118e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// pre-isel nodes (those for which isMachineOpcode returns false), these 1119e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// are the opcode values in the ISD and <target>ISD namespaces. For 1120e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// post-isel opcodes, see getMachineOpcode. 1121e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman unsigned getOpcode() const { return (unsigned short)NodeType; } 1122e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 1123e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// isTargetOpcode - Test if this node has a target-specific opcode (in the 1124e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// <target>ISD namespace). 11250f66a9172175aa7c3055333358170581c999219bNate Begeman bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } 1126e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 1127e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// isMachineOpcode - Test if this node has a post-isel opcode, directly 1128e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// corresponding to a MachineInstr opcode. 1129e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman bool isMachineOpcode() const { return NodeType < 0; } 1130e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 1131e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// getMachineOpcode - This may only be called if isMachineOpcode returns 1132e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// true. It returns the MachineInstr opcode value that the node's opcode 1133e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// corresponds to. 1134e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman unsigned getMachineOpcode() const { 1135ec89a364b86ccd943fc6cf3ad8f84825ba1550fdDan Gohman assert(isMachineOpcode() && "Not a MachineInstr opcode!"); 1136e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman return ~NodeType; 11370f66a9172175aa7c3055333358170581c999219bNate Begeman } 113863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 11396da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman /// use_empty - Return true if there are no uses of this node. 11407a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 1141e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman bool use_empty() const { return UseList == NULL; } 11427a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman 11436da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman /// hasOneUse - Return true if there is exactly one use of this node. 11447a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 1145b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman bool hasOneUse() const { 1146b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman return !use_empty() && next(use_begin()) == use_end(); 1147b9c33c32292d0ae5da2d75623a84a0e7796a2b63Dan Gohman } 114863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 11496da38a05f6d904bd4c2bf51d43938e28e00402abDan Gohman /// use_size - Return the number of uses of this node. This method takes 11507a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// time proportional to the number of uses. 11517a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman /// 11527a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman size_t use_size() const { return std::distance(use_begin(), use_end()); } 11537a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman 1154b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// getNodeId - Return the unique node id. 1155b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng /// 1156b9ee9e60a905b90fa3e84c5c6091af6e5a0382d2Evan Cheng int getNodeId() const { return NodeId; } 11570442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner 11582e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng /// setNodeId - Set unique node id. 11592e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng void setNodeId(int Id) { NodeId = Id; } 11602e07d33f04c513f3c2da3d7b1acfc098f02c7a6eEvan Cheng 11613b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// getDebugLoc - Return the source location info. 1162124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen const DebugLoc getDebugLoc() const { return debugLoc; } 11633b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen 1164ab160cf371d6148d49b5401a903dd4ce381b2f8cDale Johannesen /// setDebugLoc - Set source location info. Try to avoid this, putting 1165ab160cf371d6148d49b5401a903dd4ce381b2f8cDale Johannesen /// it in the constructor is preferable. 1166124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen void setDebugLoc(const DebugLoc dl) { debugLoc = dl; } 11673b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen 11689cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein /// use_iterator - This class provides iterator support for SDUse 1169dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// operands that use a specific SDNode. 1170dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein class use_iterator 11719cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : public forward_iterator<SDUse, ptrdiff_t> { 11729cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *Op; 11739cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein explicit use_iterator(SDUse *op) : Op(op) { 1174dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1175dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein friend class SDNode; 1176dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein public: 11779cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef forward_iterator<SDUse, ptrdiff_t>::reference reference; 11789cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef forward_iterator<SDUse, ptrdiff_t>::pointer pointer; 1179dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1180dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator(const use_iterator &I) : Op(I.Op) {} 1181dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator() : Op(0) {} 1182dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1183dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool operator==(const use_iterator &x) const { 1184dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return Op == x.Op; 1185dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1186dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool operator!=(const use_iterator &x) const { 1187dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return !operator==(x); 1188dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1189dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1190dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// atEnd - return true if this iterator is at the end of uses list. 1191dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein bool atEnd() const { return Op == 0; } 1192dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1193dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein // Iterator traversal: forward iteration only. 1194dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator &operator++() { // Preincrement 1195dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot increment end iterator!"); 1196dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein Op = Op->getNext(); 1197dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein return *this; 1198dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1199dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1200dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator operator++(int) { // Postincrement 1201dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator tmp = *this; ++*this; return tmp; 1202dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1203dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 12048968450305c28444edc3c272d8752a8db0c2f34aDan Gohman /// Retrieve a pointer to the current user node. 12058968450305c28444edc3c272d8752a8db0c2f34aDan Gohman SDNode *operator*() const { 1206dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot dereference end iterator!"); 12078968450305c28444edc3c272d8752a8db0c2f34aDan Gohman return Op->getUser(); 1208dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1209dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 12108968450305c28444edc3c272d8752a8db0c2f34aDan Gohman SDNode *operator->() const { return operator*(); } 12118968450305c28444edc3c272d8752a8db0c2f34aDan Gohman 12128968450305c28444edc3c272d8752a8db0c2f34aDan Gohman SDUse &getUse() const { return *Op; } 1213dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1214174f938bd042a19d1a840eef6ed162fc938e2fd9Duncan Sands /// getOperandNo - Retrieve the operand # of this use in its user. 12158968450305c28444edc3c272d8752a8db0c2f34aDan Gohman /// 12168968450305c28444edc3c272d8752a8db0c2f34aDan Gohman unsigned getOperandNo() const { 1217dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein assert(Op && "Cannot dereference end iterator!"); 12188968450305c28444edc3c272d8752a8db0c2f34aDan Gohman return (unsigned)(Op - Op->getUser()->OperandList); 1219dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1220dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein }; 1221dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1222dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// use_begin/use_end - Provide iteration support to walk over all uses 1223dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein /// of an SDNode. 1224dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1225dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein use_iterator use_begin() const { 1226e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman return use_iterator(UseList); 1227dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1228dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1229dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein static use_iterator use_end() { return use_iterator(0); } 1230dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 12317ece380440238ad0630a225b85a09a2dbed1165aChris Lattner 1232b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// hasNUsesOfValue - Return true if there are exactly NUSES uses of the 1233b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// indicated value. This method ignores uses of other values defined by this 1234b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner /// operation. 12354ee621125876cc954cba5280dd9395552755a871Evan Cheng bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; 12364ee621125876cc954cba5280dd9395552755a871Evan Cheng 123733d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// hasAnyUseOfValue - Return true if there are any use of the indicated 123833d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng /// value. This method ignores uses of other values defined by this operation. 123933d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng bool hasAnyUseOfValue(unsigned Value) const; 124033d5595d667ba4a880bd7fe785724e8197bef70cEvan Cheng 12412a6299543fa22f389158409e897fe7099fda3812Dan Gohman /// isOnlyUserOf - Return true if this node is the only use of N. 1242e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 12432a6299543fa22f389158409e897fe7099fda3812Dan Gohman bool isOnlyUserOf(SDNode *N) const; 1244b18a2f816cc9d1351ca8e380a6db5c5ef981943eChris Lattner 1245917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isOperandOf - Return true if this node is an operand of N. 1246e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// 1247917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isOperandOf(SDNode *N) const; 124880d8eaae05d9bcb25abf6c6f0385ec2554355f26Evan Cheng 1249917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// isPredecessorOf - Return true if this node is a predecessor of N. This 1250917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// node is either an operand of N or it can be reached by recursively 1251917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng /// traversing up the operands. 1252e6e97e66a366cc7d2d103ac58db56e4bfd700b10Evan Cheng /// NOTE: this is an expensive method. Use it carefully. 1253917be6814e0a4e529d290be5d806a054bbbc4a27Evan Cheng bool isPredecessorOf(SDNode *N) const; 12547ceebb437ebb18efefe72d8d2d0e9c762c3aa6b3Evan Cheng 125563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumOperands - Return the number of values used by this operation. 125663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 1257f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumOperands() const { return NumOperands; } 125863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1259c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// getConstantOperandVal - Helper method returns the integer value of a 1260c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// ConstantSDNode operand. 1261c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng uint64_t getConstantOperandVal(unsigned Num) const; 1262c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 1263475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOperand(unsigned Num) const { 1264f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(Num < NumOperands && "Invalid child # of SDNode!"); 1265e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman return OperandList[Num]; 126663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 1267c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 12689cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein typedef SDUse* op_iterator; 1269f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_begin() const { return OperandList; } 1270f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner op_iterator op_end() const { return OperandList+NumOperands; } 127150f5a51f41d36c519de68ff11fbf7c7c76f45416Chris Lattner 12720b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList getVTList() const { 12730b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner SDVTList X = { ValueList, NumValues }; 12740b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner return X; 12750b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner }; 1276d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman 1277d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman /// getFlaggedNode - If this node has a flag operand, return the node 1278d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman /// to which the flag operand points. Otherwise return NULL. 1279d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman SDNode *getFlaggedNode() const { 1280d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman if (getNumOperands() != 0 && 1281d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman getOperand(getNumOperands()-1).getValueType() == MVT::Flag) 1282d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman return getOperand(getNumOperands()-1).getNode(); 1283d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman return 0; 1284d23e0f81bc76902052e9198cad3a0d87a412a632Dan Gohman } 1285fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman 1286fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman // If this is a pseudo op, like copyfromreg, look to see if there is a 1287fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman // real target node flagged to it. If so, return the target node. 1288fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman const SDNode *getFlaggedMachineNode() const { 1289fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman const SDNode *FoundNode = this; 1290fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman 1291fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman // Climb up flag edges until a machine-opcode node is found, or the 1292fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman // end of the chain is reached. 1293fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman while (!FoundNode->isMachineOpcode()) { 1294fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman const SDNode *N = FoundNode->getFlaggedNode(); 1295fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman if (!N) break; 1296fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman FoundNode = N; 1297fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman } 1298fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman 1299fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman return FoundNode; 1300fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman } 1301fc54c552963545a81e4ea38e60460590afb2d5aeDan Gohman 130263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getNumValues - Return the number of values defined/returned by this 130363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// operator. 130463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 1305f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner unsigned getNumValues() const { return NumValues; } 130663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 130763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// getValueType - Return the type of a specified result. 130863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 130983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getValueType(unsigned ResNo) const { 1310f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner assert(ResNo < NumValues && "Illegal result number!"); 1311f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner return ValueList[ResNo]; 131263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 13139eb59ec548b861d6ede05b4e6dc22aabf645e665Jeff Cohen 13144fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// getValueSizeInBits - Returns MVT::getSizeInBits(getValueType(ResNo)). 13154fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman /// 13164fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman unsigned getValueSizeInBits(unsigned ResNo) const { 131783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands return getValueType(ResNo).getSizeInBits(); 13184fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman } 13194fc3d5dac255120e2f0c0b537044fcf56a30fa34Dan Gohman 132083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands typedef const MVT* value_iterator; 1321f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_begin() const { return ValueList; } 1322f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner value_iterator value_end() const { return ValueList+NumValues; } 132363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 13246e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// getOperationName - Return the opcode of this operation for printing. 13256e6e3ceb080e5a8bdfd3258d883a06ebbd8a1965Chris Lattner /// 1326ded5ed873fa7cd85f0b9d7c677b81dddf9a61eaaReid Spencer std::string getOperationName(const SelectionDAG *G = 0) const; 1327144d8f09e139f691cafadbc17873943ba4c465f3Evan Cheng static const char* getIndexedModeName(ISD::MemIndexedMode AM); 1328944fac71e082cc2664cc71b4d3f6c72bab7143fbChris Lattner void print(raw_ostream &OS, const SelectionDAG *G = 0) const; 132963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner void dump() const; 1330efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner void dump(const SelectionDAG *G) const; 133163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 133263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *) { return true; } 133363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1334583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// Profile - Gather unique data for the node. 1335583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// 1336b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman void Profile(FoldingSetNodeID &ID) const; 1337583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey 1338e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// addUse - This method should only be used by the SDUse class. 1339109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// 1340e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void addUse(SDUse &U) { U.addToList(&UseList); } 1341e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1342e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanprotected: 134383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands static SDVTList getSDVTList(MVT VT) { 134463e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner SDVTList Ret = { getValueTypeList(VT), 1 }; 134563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner return Ret; 13462d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 134763e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 13483b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// The constructors that supply DebugLoc explicitly should be preferred 13493b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// for new code. 1350475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps) 1351ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0), 13521bb1d99f23c655f11455607dd725b239ade4464dDale Johannesen NodeId(-1), debugLoc(DebugLoc::getUnknownLoc()), 1353e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList(NumOps ? new SDUse[NumOps] : 0), 1354e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman ValueList(VTs.VTs), 1355e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands(NumOps), NumValues(VTs.NumVTs), 1356e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman UseList(NULL) { 13579cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein for (unsigned i = 0; i != NumOps; ++i) { 13589cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein OperandList[i].setUser(this); 1359e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList[i].setInitial(Ops[i]); 13609cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein } 1361f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner } 1362dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 1363ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// This constructor adds no operands itself; operands can be 1364ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// set later with InitOperands. 1365dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein SDNode(unsigned Opc, SDVTList VTs) 1366ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0), 13671bb1d99f23c655f11455607dd725b239ade4464dDale Johannesen NodeId(-1), debugLoc(DebugLoc::getUnknownLoc()), OperandList(0), 13683b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen ValueList(VTs.VTs), NumOperands(0), NumValues(VTs.NumVTs), 13693b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen UseList(NULL) {} 13703b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen 13713b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// The next two constructors specify DebugLoc explicitly; the intent 13723b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// is that they will replace the above two over time, and eventually 13733b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// the ones above can be removed. 1374124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs, const SDValue *Ops, 1375124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen unsigned NumOps) 13763b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0), 1377124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen NodeId(-1), debugLoc(dl), 13783b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen OperandList(NumOps ? new SDUse[NumOps] : 0), 13793b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen ValueList(VTs.VTs), 13803b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen NumOperands(NumOps), NumValues(VTs.NumVTs), 13813b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen UseList(NULL) { 13823b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen for (unsigned i = 0; i != NumOps; ++i) { 13833b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen OperandList[i].setUser(this); 13843b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen OperandList[i].setInitial(Ops[i]); 13853b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen } 13863b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen } 13873b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen 13883b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// This constructor adds no operands itself; operands can be 13893b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// set later with InitOperands. 1390124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs) 13913b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0), 1392124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen NodeId(-1), debugLoc(dl), OperandList(0), 13933b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen ValueList(VTs.VTs), NumOperands(0), NumValues(VTs.NumVTs), 1394e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman UseList(NULL) {} 1395bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner 1396e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with 1 operand. 1397e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue &Op0) { 1398e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setUser(this); 1399e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setInitial(Op0); 1400e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = 1; 1401bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = Ops; 1402e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman } 1403e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1404e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with 2 operands. 1405e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) { 1406e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setUser(this); 1407e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setInitial(Op0); 1408e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setUser(this); 1409e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setInitial(Op1); 1410e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = 2; 1411e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList = Ops; 1412e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman } 1413e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1414e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with 3 operands. 1415e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1, 1416e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman const SDValue &Op2) { 1417e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setUser(this); 1418e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setInitial(Op0); 1419e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setUser(this); 1420e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setInitial(Op1); 1421e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[2].setUser(this); 1422e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[2].setInitial(Op2); 1423e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = 3; 1424e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList = Ops; 1425e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman } 1426e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1427e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with 4 operands. 1428e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1, 1429e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman const SDValue &Op2, const SDValue &Op3) { 1430e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setUser(this); 1431e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setInitial(Op0); 1432e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setUser(this); 1433e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setInitial(Op1); 1434e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[2].setUser(this); 1435e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[2].setInitial(Op2); 1436e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[3].setUser(this); 1437e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[3].setInitial(Op3); 1438e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = 4; 1439e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList = Ops; 1440e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman } 1441e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1442e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with N operands. 1443e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) { 1444e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman for (unsigned i = 0; i != N; ++i) { 1445e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[i].setUser(this); 1446e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[i].setInitial(Vals[i]); 1447dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1448e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = N; 1449e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList = Ops; 1450bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 14510fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman 14520fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman /// DropOperands - Release the operands and set this node to have 1453e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// zero operands. 14540fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman void DropOperands(); 145563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 145663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 145763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1458475871a144eb604ddaf37503397ba0941442e5fbDan Gohman// Define inline functions from the SDValue class. 145963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1460475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getOpcode() const { 1461ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOpcode(); 146263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1463475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline MVT SDValue::getValueType() const { 1464ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getValueType(ResNo); 146563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1466475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getNumOperands() const { 1467ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getNumOperands(); 146863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1469475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline const SDValue &SDValue::getOperand(unsigned i) const { 1470ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOperand(i); 147163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1472475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline uint64_t SDValue::getConstantOperandVal(unsigned i) const { 1473ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getConstantOperandVal(i); 1474c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 1475475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isTargetOpcode() const { 1476ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->isTargetOpcode(); 14770f66a9172175aa7c3055333358170581c999219bNate Begeman} 1478475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isMachineOpcode() const { 1479ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->isMachineOpcode(); 1480e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman} 1481475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getMachineOpcode() const { 1482ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getMachineOpcode(); 14830f66a9172175aa7c3055333358170581c999219bNate Begeman} 1484475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::use_empty() const { 1485ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return !Node->hasAnyUseOfValue(ResNo); 1486e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman} 1487475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::hasOneUse() const { 1488ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->hasNUsesOfValue(1, ResNo); 14897a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman} 1490124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johanneseninline const DebugLoc SDValue::getDebugLoc() const { 14913b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen return Node->getDebugLoc(); 14923b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen} 149363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1494e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman// Define inline functions from the SDUse class. 1495e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1496e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::set(const SDValue &V) { 1497e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman if (Val.getNode()) removeFromList(); 1498e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Val = V; 1499e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman if (V.getNode()) V.getNode()->addUse(*this); 1500e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman} 1501e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1502e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::setInitial(const SDValue &V) { 1503e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Val = V; 1504e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman V.getNode()->addUse(*this); 1505e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman} 1506e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1507e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::setNode(SDNode *N) { 1508e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman if (Val.getNode()) removeFromList(); 1509e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Val.setNode(N); 1510e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman if (N) N->addUse(*this); 1511e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman} 1512e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 15133f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes. This is solely 15143f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 15153f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode { 15169cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Op; 15173f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 1518475871a144eb604ddaf37503397ba0941442e5fbDan Gohman UnarySDNode(unsigned Opc, SDVTList VTs, SDValue X) 15199cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : SDNode(Opc, VTs) { 1520e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(&Op, X); 15213f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 15223f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 15233f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 15243f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes. This is solely 15253f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 15263f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode { 15279cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[2]; 15283f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 1529475871a144eb604ddaf37503397ba0941442e5fbDan Gohman BinarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y) 15303f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 1531e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(Ops, X, Y); 15323f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 15333f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 15343f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 15353f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely 15363f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 15373f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode { 15389cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[3]; 15393f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 1540475871a144eb604ddaf37503397ba0941442e5fbDan Gohman TernarySDNode(unsigned Opc, SDVTList VTs, SDValue X, SDValue Y, 1541475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Z) 15423f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner : SDNode(Opc, VTs) { 1543e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(Ops, X, Y, Z); 15443f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner } 15453f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 15463f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 15473f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 1548d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that 1549d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its 1550d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand. This node should be directly created by end-users and not added to 1551d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list. 1552d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode { 15539cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Op; 1554d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic: 1555ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is 1556ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling // fixed. 155769cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#ifdef __GNUC__ 1558475871a144eb604ddaf37503397ba0941442e5fbDan Gohman explicit __attribute__((__noinline__)) HandleSDNode(SDValue X) 155969cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#else 1560475871a144eb604ddaf37503397ba0941442e5fbDan Gohman explicit HandleSDNode(SDValue X) 156169cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#endif 15629cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein : SDNode(ISD::HANDLENODE, getSDVTList(MVT::Other)) { 1563e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(&Op, X); 1564bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 156548b85926524f9d29ae600123c90194cd73fd629eChris Lattner ~HandleSDNode(); 1566e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman const SDValue &getValue() const { return Op; } 1567d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner}; 1568d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner 156928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang/// Abstact virtual class for operations for memory operations 157028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass MemSDNode : public SDNode { 157128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangprivate: 15721ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman // MemoryVT - VT of in-memory value. 15731ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MVT MemoryVT; 15741ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman 157528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang //! SrcValue - Memory location for alias analysis. 157628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang const Value *SrcValue; 157728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1578492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman //! SVOffset - Memory location offset. Note that base is defined in MemSDNode 1579492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman int SVOffset; 1580492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman 1581492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman /// Flags - the low bit indicates whether this is a volatile reference; 1582492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman /// the remainder is a log2 encoding of the alignment in bytes. 1583492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman unsigned Flags; 158428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 158528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangpublic: 15861ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MemSDNode(unsigned Opc, SDVTList VTs, MVT MemoryVT, 1587492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman const Value *srcValue, int SVOff, 1588492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman unsigned alignment, bool isvolatile); 158928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1590c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MemSDNode(unsigned Opc, SDVTList VTs, const SDValue *Ops, unsigned NumOps, 1591c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MVT MemoryVT, const Value *srcValue, int SVOff, 1592c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang unsigned alignment, bool isvolatile); 1593c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 159428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// Returns alignment and volatility of the memory access 1595492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman unsigned getAlignment() const { return (1u << (Flags >> 1)) >> 1; } 1596492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman bool isVolatile() const { return Flags & 1; } 159728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 159828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// Returns the SrcValue and offset that describes the location of the access 159928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang const Value *getSrcValue() const { return SrcValue; } 1600492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman int getSrcValueOffset() const { return SVOffset; } 160128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 16021ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman /// getMemoryVT - Return the type of the in-memory value. 16031ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MVT getMemoryVT() const { return MemoryVT; } 16041ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman 160528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// getMemOperand - Return a MachineMemOperand object describing the memory 160628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// reference performed by operation. 16071ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MachineMemOperand getMemOperand() const; 16081ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman 1609475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getChain() const { return getOperand(0); } 1610475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { 16111ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman return getOperand(getOpcode() == ISD::STORE ? 2 : 1); 16121ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman } 161328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1614b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman /// getRawFlags - Represent the flags as a bunch of bits. 1615b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman /// 1616b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman unsigned getRawFlags() const { return Flags; } 1617b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman 161828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Methods to support isa and dyn_cast 161928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const MemSDNode *) { return true; } 162028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const SDNode *N) { 1621c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // For some targets, we lower some target intrinsics to a MemIntrinsicNode 1622c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // with either an intrinsic or a target opcode. 1623e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen return N->getOpcode() == ISD::LOAD || 1624e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::STORE || 16250b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_CMP_SWAP || 16260b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_SWAP || 16270b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_ADD || 16280b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_SUB || 16290b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_AND || 16300b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_OR || 16310b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_XOR || 16320b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_NAND || 16330b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_MIN || 16340b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_MAX || 16350b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || 16360b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_UMAX || 1637c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_W_CHAIN || 1638c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_VOID || 1639c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->isTargetOpcode(); 164028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang } 164128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang}; 164228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1643c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// AtomicSDNode - A SDNode reprenting atomic operations. 1644c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// 164528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass AtomicSDNode : public MemSDNode { 16469cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[4]; 164728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1648c53361294957b63a9c1e405256c6f0a81db1685cDan Gohmanpublic: 164928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Opc: opcode for atomic 165028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // VTL: value type list 165128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Chain: memory chain for operaand 1652475871a144eb604ddaf37503397ba0941442e5fbDan Gohman // Ptr: address to update as a SDValue 165328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Cmp: compare value 165428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Swp: swap value 165528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // SrcVal: address to update as a Value (used for MemOperand) 165628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Align: alignment of memory 16570b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman AtomicSDNode(unsigned Opc, SDVTList VTL, MVT MemVT, 16580b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman SDValue Chain, SDValue Ptr, 1659475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Cmp, SDValue Swp, const Value* SrcVal, 166028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang unsigned Align=0) 16610b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman : MemSDNode(Opc, VTL, MemVT, SrcVal, /*SVOffset=*/0, 1662492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman Align, /*isVolatile=*/true) { 1663e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(Ops, Chain, Ptr, Cmp, Swp); 1664ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth } 16650b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman AtomicSDNode(unsigned Opc, SDVTList VTL, MVT MemVT, 16660b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman SDValue Chain, SDValue Ptr, 1667475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Val, const Value* SrcVal, unsigned Align=0) 16680b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman : MemSDNode(Opc, VTL, MemVT, SrcVal, /*SVOffset=*/0, 1669492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman Align, /*isVolatile=*/true) { 1670e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(Ops, Chain, Ptr, Val); 1671ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth } 167228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1673475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(1); } 1674475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getVal() const { return getOperand(2); } 167528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1676e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen bool isCompareAndSwap() const { 1677e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen unsigned Op = getOpcode(); 16780b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman return Op == ISD::ATOMIC_CMP_SWAP; 1679e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen } 168028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 168128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Methods to support isa and dyn_cast 168228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const AtomicSDNode *) { return true; } 168328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const SDNode *N) { 16840b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman return N->getOpcode() == ISD::ATOMIC_CMP_SWAP || 16850b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_SWAP || 16860b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_ADD || 16870b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_SUB || 16880b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_AND || 16890b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_OR || 16900b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_XOR || 16910b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_NAND || 16920b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_MIN || 16930b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_MAX || 16940b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || 16950b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_UMAX; 169628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang } 1697ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth}; 1698ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 1699c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// MemIntrinsicSDNode - This SDNode is used for target intrinsic that touches 1700c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// memory and need an associated memory operand. 1701c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// 1702c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wangclass MemIntrinsicSDNode : public MemSDNode { 1703c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool ReadMem; // Intrinsic reads memory 1704c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool WriteMem; // Intrinsic writes memory 17053dbc4e350216e197e3014452400f43899f7ad620Dan Gohmanpublic: 1706c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MemIntrinsicSDNode(unsigned Opc, SDVTList VTs, 1707c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang const SDValue *Ops, unsigned NumOps, 1708c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MVT MemoryVT, const Value *srcValue, int SVO, 1709c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang unsigned Align, bool Vol, bool ReadMem, bool WriteMem) 1710c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang : MemSDNode(Opc, VTs, Ops, NumOps, MemoryVT, srcValue, SVO, Align, Vol), 1711c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang ReadMem(ReadMem), WriteMem(WriteMem) { 1712c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang } 1713c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 1714c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool readMem() const { return ReadMem; } 1715c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool writeMem() const { return WriteMem; } 1716c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 1717c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // Methods to support isa and dyn_cast 1718c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang static bool classof(const MemIntrinsicSDNode *) { return true; } 1719c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang static bool classof(const SDNode *N) { 1720c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // We lower some target intrinsics to their target opcode 1721c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // early a node with a target opcode can be of this class 1722c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang return N->getOpcode() == ISD::INTRINSIC_W_CHAIN || 1723c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_VOID || 1724c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->isTargetOpcode(); 1725c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang } 1726c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang}; 1727c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 172863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode { 17294fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantInt *Value; 173063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 173163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 17324fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT) 1733bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, getSDVTList(VT)), 1734bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner Value(val) { 173563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 173663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 173763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17384fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantInt *getConstantIntValue() const { return Value; } 17394fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const APInt &getAPIntValue() const { return Value->getValue(); } 17404fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman uint64_t getZExtValue() const { return Value->getZExtValue(); } 17417810bfed5570c192e0714a8fd0e5130a0c38dd2eDan Gohman int64_t getSExtValue() const { return Value->getSExtValue(); } 174263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17434fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman bool isNullValue() const { return Value->isNullValue(); } 17444fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman bool isAllOnesValue() const { return Value->isAllOnesValue(); } 174563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 174663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantSDNode *) { return true; } 174763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1748056f9f61d071c6c583951678f2bf543a1316efccChris Lattner return N->getOpcode() == ISD::Constant || 1749056f9f61d071c6c583951678f2bf543a1316efccChris Lattner N->getOpcode() == ISD::TargetConstant; 175063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 175163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 175263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 175363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode { 17544fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantFP *Value; 175563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 175663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 17574fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT) 175887503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 175987503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen getSDVTList(VT)), Value(val) { 176063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 176163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 176263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17634fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const APFloat& getValueAPF() const { return Value->getValueAPF(); } 17644fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantFP *getConstantFPValue() const { return Value; } 176563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 176663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isExactlyValue - We don't rely on operator== working on double values, as 176763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 176863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// As such, this method can be used to do an exact bit-for-bit comparison of 176963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// two floating point values. 1770c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen 1771c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// We leave the version with the double argument here because it's just so 1772c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// convenient to write "2.0" and the like. Without this function we'd 1773c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// have to duplicate its logic everywhere it's called. 17749dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen bool isExactlyValue(double V) const { 177523a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen bool ignored; 17769dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen // convert is not supported on this type 17774fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) 17789dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen return false; 177984cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner APFloat Tmp(V); 17804fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman Tmp.convert(Value->getValueAPF().getSemantics(), 178123a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen APFloat::rmNearestTiesToEven, &ignored); 178284cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner return isExactlyValue(Tmp); 178387503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen } 1784e6c1742914149d44360fbf05a653041a672282afDale Johannesen bool isExactlyValue(const APFloat& V) const; 178563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 178683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands bool isValueValidForType(MVT VT, const APFloat& Val); 1787f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen 178863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantFPSDNode *) { return true; } 178963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1790ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner return N->getOpcode() == ISD::ConstantFP || 1791ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner N->getOpcode() == ISD::TargetConstantFP; 179263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 179363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 179463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 179563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode { 179663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *TheGlobal; 17976520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t Offset; 179863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 179963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 18006520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT, 18016520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t o = 0); 180263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 180363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 180463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *getGlobal() const { return TheGlobal; } 18056520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t getOffset() const { return Offset; } 180663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 180763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const GlobalAddressSDNode *) { return true; } 180863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1809f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner return N->getOpcode() == ISD::GlobalAddress || 1810b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalAddress || 1811b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::GlobalTLSAddress || 1812b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalTLSAddress; 181363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 181463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 181563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 181663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode { 181763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int FI; 181863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 181963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 182083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands FrameIndexSDNode(int fi, MVT VT, bool isTarg) 1821bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, getSDVTList(VT)), 1822bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner FI(fi) { 182363e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 182463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 182563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 182663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int getIndex() const { return FI; } 182763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 182863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const FrameIndexSDNode *) { return true; } 182963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1830afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner return N->getOpcode() == ISD::FrameIndex || 1831afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner N->getOpcode() == ISD::TargetFrameIndex; 183263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 183363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 183463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 183537efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode { 183637efe6764568a3829fee26aba532283131d1a104Nate Begeman int JTI; 183737efe6764568a3829fee26aba532283131d1a104Nate Begemanprotected: 183837efe6764568a3829fee26aba532283131d1a104Nate Begeman friend class SelectionDAG; 183983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands JumpTableSDNode(int jti, MVT VT, bool isTarg) 1840bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, getSDVTList(VT)), 1841bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner JTI(jti) { 184263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 184337efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic: 184437efe6764568a3829fee26aba532283131d1a104Nate Begeman 184559a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner int getIndex() const { return JTI; } 184637efe6764568a3829fee26aba532283131d1a104Nate Begeman 184737efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const JumpTableSDNode *) { return true; } 184837efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const SDNode *N) { 184937efe6764568a3829fee26aba532283131d1a104Nate Begeman return N->getOpcode() == ISD::JumpTable || 185037efe6764568a3829fee26aba532283131d1a104Nate Begeman N->getOpcode() == ISD::TargetJumpTable; 185137efe6764568a3829fee26aba532283131d1a104Nate Begeman } 185237efe6764568a3829fee26aba532283131d1a104Nate Begeman}; 185337efe6764568a3829fee26aba532283131d1a104Nate Begeman 185463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode { 1855d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng union { 1856d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *ConstVal; 1857d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *MachineCPVal; 1858d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } Val; 1859baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int Offset; // It's a MachineConstantPoolValue if top bit is set. 1860b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned Alignment; 186163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 186263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 186383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o=0) 1864ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1865bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1866d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1867d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1868d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 186983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align) 1870ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1871bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1872d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1873d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1874d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1875d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 187683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT VT, int o=0) 1877ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1878bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(0) { 1879d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1880d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1881d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1882d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1883d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 188483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT VT, int o, unsigned Align) 1885ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 1886bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align) { 1887d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1888d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1889d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Offset |= 1 << (sizeof(unsigned)*8-1); 1890d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 189163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 189263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1893d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng bool isMachineConstantPoolEntry() const { 1894d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return (int)Offset < 0; 1895d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1896d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1897d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *getConstVal() const { 1898d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1899d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.ConstVal; 1900d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1901d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1902d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *getMachineCPVal() const { 1903d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1904d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.MachineCPVal; 1905d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1906d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1907baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int getOffset() const { 1908baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng return Offset & ~(1 << (sizeof(unsigned)*8-1)); 1909baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng } 1910ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner 1911ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // Return the alignment of this constant pool object, which is either 0 (for 1912ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // default alignment) or log2 of the desired value. 1913b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned getAlignment() const { return Alignment; } 191463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1915d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng const Type *getType() const; 1916d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 191763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantPoolSDNode *) { return true; } 191863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1919aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner return N->getOpcode() == ISD::ConstantPool || 1920aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner N->getOpcode() == ISD::TargetConstantPool; 192163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 192263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 192363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 192463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode { 192563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *MBB; 192663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 192763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1928423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit BasicBlockSDNode(MachineBasicBlock *mbb) 1929bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::BasicBlock, getSDVTList(MVT::Other)), MBB(mbb) { 193063e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 193163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 193263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 193363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *getBasicBlock() const { return MBB; } 193463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 193563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const BasicBlockSDNode *) { return true; } 193663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 193763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return N->getOpcode() == ISD::BasicBlock; 193863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 193963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 194063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 194114471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is 194214471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// used when the SelectionDAG needs to make a simple reference to something 194314471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// in the LLVM IR representation. 194414471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 194514471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// Note that this is not used for carrying alias information; that is done 194614471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// with MemOperandSDNode, which includes a Value which is required to be a 194714471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// pointer, and several other fields specific to memory references. 194814471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 19492d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode { 19502d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *V; 19512d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthprotected: 19522d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth friend class SelectionDAG; 195369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// Create a SrcValue for a general value. 195469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman explicit SrcValueSDNode(const Value *v) 195569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman : SDNode(ISD::SRCVALUE, getSDVTList(MVT::Other)), V(v) {} 19562d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 19572d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic: 195869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// getValue - return the contained Value. 19592d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *getValue() const { return V; } 19602d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 19612d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SrcValueSDNode *) { return true; } 19622d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SDNode *N) { 19632d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth return N->getOpcode() == ISD::SRCVALUE; 19642d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 19652d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth}; 19662d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 196763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 196836b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is 196969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// used to represent a reference to memory after ISD::LOAD 197069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// and ISD::STORE have been lowered. 197169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// 197269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanclass MemOperandSDNode : public SDNode { 197369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanprotected: 197469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman friend class SelectionDAG; 197536b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// Create a MachineMemOperand node 197636b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman explicit MemOperandSDNode(const MachineMemOperand &mo) 197769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman : SDNode(ISD::MEMOPERAND, getSDVTList(MVT::Other)), MO(mo) {} 197869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 197969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanpublic: 198036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// MO - The contained MachineMemOperand. 198136b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman const MachineMemOperand MO; 198269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 198369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const MemOperandSDNode *) { return true; } 198469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const SDNode *N) { 198569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman return N->getOpcode() == ISD::MEMOPERAND; 198669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman } 198769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman}; 198869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 198969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 1990d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode { 199163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Reg; 199263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 199363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 199483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands RegisterSDNode(unsigned reg, MVT VT) 1995bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::Register, getSDVTList(VT)), Reg(reg) { 199663e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 199763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 199863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 199963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getReg() const { return Reg; } 200063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 2001d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner static bool classof(const RegisterSDNode *) { return true; } 200263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 2003d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner return N->getOpcode() == ISD::Register; 200463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 200563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 200663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 20077f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanclass DbgStopPointSDNode : public SDNode { 20087f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman SDUse Chain; 20097f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned Line; 20107f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned Column; 201183489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel Value *CU; 20127f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanprotected: 20137f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman friend class SelectionDAG; 2014475871a144eb604ddaf37503397ba0941442e5fbDan Gohman DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c, 201583489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel Value *cu) 20167f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman : SDNode(ISD::DBG_STOPPOINT, getSDVTList(MVT::Other)), 20177f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman Line(l), Column(c), CU(cu) { 2018e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(&Chain, ch); 20197f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman } 20207f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanpublic: 20217f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned getLine() const { return Line; } 20227f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned getColumn() const { return Column; } 202383489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel Value *getCompileUnit() const { return CU; } 20247f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman 20257f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman static bool classof(const DbgStopPointSDNode *) { return true; } 20267f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman static bool classof(const SDNode *N) { 20277f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman return N->getOpcode() == ISD::DBG_STOPPOINT; 20287f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman } 20297f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman}; 20307f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman 20314406604047423576e36657c7ede266ca42e79642Dan Gohmanclass LabelSDNode : public SDNode { 20324406604047423576e36657c7ede266ca42e79642Dan Gohman SDUse Chain; 20334406604047423576e36657c7ede266ca42e79642Dan Gohman unsigned LabelID; 20344406604047423576e36657c7ede266ca42e79642Dan Gohmanprotected: 20354406604047423576e36657c7ede266ca42e79642Dan Gohman friend class SelectionDAG; 2036475871a144eb604ddaf37503397ba0941442e5fbDan Gohman LabelSDNode(unsigned NodeTy, SDValue ch, unsigned id) 20374406604047423576e36657c7ede266ca42e79642Dan Gohman : SDNode(NodeTy, getSDVTList(MVT::Other)), LabelID(id) { 2038e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(&Chain, ch); 20394406604047423576e36657c7ede266ca42e79642Dan Gohman } 20404406604047423576e36657c7ede266ca42e79642Dan Gohmanpublic: 20414406604047423576e36657c7ede266ca42e79642Dan Gohman unsigned getLabelID() const { return LabelID; } 20424406604047423576e36657c7ede266ca42e79642Dan Gohman 20434406604047423576e36657c7ede266ca42e79642Dan Gohman static bool classof(const LabelSDNode *) { return true; } 20444406604047423576e36657c7ede266ca42e79642Dan Gohman static bool classof(const SDNode *N) { 20454406604047423576e36657c7ede266ca42e79642Dan Gohman return N->getOpcode() == ISD::DBG_LABEL || 20464406604047423576e36657c7ede266ca42e79642Dan Gohman N->getOpcode() == ISD::EH_LABEL; 20474406604047423576e36657c7ede266ca42e79642Dan Gohman } 20484406604047423576e36657c7ede266ca42e79642Dan Gohman}; 20494406604047423576e36657c7ede266ca42e79642Dan Gohman 2050056292fd738924f3f7703725d8f630983794b5a5Bill Wendlingclass ExternalSymbolSDNode : public SDNode { 205163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *Symbol; 205263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 205363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 2054056292fd738924f3f7703725d8f630983794b5a5Bill Wendling ExternalSymbolSDNode(bool isTarget, const char *Sym, MVT VT) 2055056292fd738924f3f7703725d8f630983794b5a5Bill Wendling : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 2056056292fd738924f3f7703725d8f630983794b5a5Bill Wendling getSDVTList(VT)), Symbol(Sym) { 2057056292fd738924f3f7703725d8f630983794b5a5Bill Wendling } 205863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 2059056292fd738924f3f7703725d8f630983794b5a5Bill Wendling 206063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *getSymbol() const { return Symbol; } 206163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 2062056292fd738924f3f7703725d8f630983794b5a5Bill Wendling static bool classof(const ExternalSymbolSDNode *) { return true; } 206363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 2064056292fd738924f3f7703725d8f630983794b5a5Bill Wendling return N->getOpcode() == ISD::ExternalSymbol || 2065056292fd738924f3f7703725d8f630983794b5a5Bill Wendling N->getOpcode() == ISD::TargetExternalSymbol; 206663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 206763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 206863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 20697cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode { 207063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ISD::CondCode Condition; 207163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerprotected: 207263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 2073423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit CondCodeSDNode(ISD::CondCode Cond) 2074bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::CONDCODE, getSDVTList(MVT::Other)), Condition(Cond) { 207563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 207663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 207763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 20787cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner ISD::CondCode get() const { return Condition; } 207963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 20807cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner static bool classof(const CondCodeSDNode *) { return true; } 208163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 20827cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner return N->getOpcode() == ISD::CONDCODE; 208363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 208463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 208563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 208677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the 208777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// future and most targets don't support it. 208877cdf30742284a173fe818417eb482224cdee8d4Mon P Wangclass CvtRndSatSDNode : public SDNode { 208977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang ISD::CvtCode CvtCode; 209077cdf30742284a173fe818417eb482224cdee8d4Mon P Wangprotected: 209177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang friend class SelectionDAG; 209277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang explicit CvtRndSatSDNode(MVT VT, const SDValue *Ops, unsigned NumOps, 209377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang ISD::CvtCode Code) 209477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang : SDNode(ISD::CONVERT_RNDSAT, getSDVTList(VT), Ops, NumOps), CvtCode(Code) { 209577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang assert(NumOps == 5 && "wrong number of operations"); 209677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang } 209777cdf30742284a173fe818417eb482224cdee8d4Mon P Wangpublic: 209877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang ISD::CvtCode getCvtCode() const { return CvtCode; } 209977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 210077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang static bool classof(const CvtRndSatSDNode *) { return true; } 210177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang static bool classof(const SDNode *N) { 210277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang return N->getOpcode() == ISD::CONVERT_RNDSAT; 210377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang } 210477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang}; 210577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 2106276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsnamespace ISD { 2107276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands struct ArgFlagsTy { 2108276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands private: 2109276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t NoFlagSet = 0ULL; 2110276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ZExt = 1ULL<<0; ///< Zero extended 2111276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ZExtOffs = 0; 2112276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SExt = 1ULL<<1; ///< Sign extended 2113276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SExtOffs = 1; 2114276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t InReg = 1ULL<<2; ///< Passed in register 2115276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t InRegOffs = 2; 2116276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr 2117276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SRetOffs = 3; 2118276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value 2119276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValOffs = 4; 2120276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain 2121276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t NestOffs = 5; 2122276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment 2123276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValAlignOffs = 6; 21246ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray static const uint64_t Split = 1ULL << 10; 21256ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray static const uint64_t SplitOffs = 10; 2126276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t OrigAlign = 0x1FULL<<27; 2127276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t OrigAlignOffs = 27; 2128276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size 2129276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValSizeOffs = 32; 2130276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2131276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t One = 1ULL; //< 1 of this type, for shifts 2132276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2133276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands uint64_t Flags; 2134276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands public: 2135276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ArgFlagsTy() : Flags(0) { } 2136276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2137276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isZExt() const { return Flags & ZExt; } 2138276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setZExt() { Flags |= One << ZExtOffs; } 2139276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2140276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isSExt() const { return Flags & SExt; } 2141276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setSExt() { Flags |= One << SExtOffs; } 2142276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2143276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isInReg() const { return Flags & InReg; } 2144276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setInReg() { Flags |= One << InRegOffs; } 2145276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2146276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isSRet() const { return Flags & SRet; } 2147276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setSRet() { Flags |= One << SRetOffs; } 2148276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2149276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isByVal() const { return Flags & ByVal; } 2150276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByVal() { Flags |= One << ByValOffs; } 2151276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2152276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isNest() const { return Flags & Nest; } 2153276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setNest() { Flags |= One << NestOffs; } 2154276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2155276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getByValAlign() const { 215694bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned) 215794bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2); 2158276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2159276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByValAlign(unsigned A) { 2160276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~ByValAlign) | 2161276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands (uint64_t(Log2_32(A) + 1) << ByValAlignOffs); 2162276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2163c0cb28fd3abee9a8b40856990e04f1af2f9bd7b8Nicolas Geoffray 21646ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray bool isSplit() const { return Flags & Split; } 21656ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray void setSplit() { Flags |= One << SplitOffs; } 2166276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2167276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getOrigAlign() const { 216894bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned) 216994bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2); 2170276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2171276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setOrigAlign(unsigned A) { 2172276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~OrigAlign) | 2173276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands (uint64_t(Log2_32(A) + 1) << OrigAlignOffs); 2174276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2175276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2176276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getByValSize() const { 217794bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned)((Flags & ByValSize) >> ByValSizeOffs); 2178276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2179276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByValSize(unsigned S) { 2180276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs); 2181276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2182276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2183276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4". 2184276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands std::string getArgFlagsString(); 2185276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2186276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// getRawBits - Represent the flags as a bunch of bits. 2187276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands uint64_t getRawBits() const { return Flags; } 2188276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands }; 2189276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands} 2190276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2191276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands/// ARG_FLAGSSDNode - Leaf node holding parameter flags. 2192276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsclass ARG_FLAGSSDNode : public SDNode { 2193276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ISD::ArgFlagsTy TheFlags; 2194276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsprotected: 2195276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands friend class SelectionDAG; 2196276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags) 2197276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands : SDNode(ISD::ARG_FLAGS, getSDVTList(MVT::Other)), TheFlags(Flags) { 2198276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2199276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandspublic: 2200276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ISD::ArgFlagsTy getArgFlags() const { return TheFlags; } 2201276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2202276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static bool classof(const ARG_FLAGSSDNode *) { return true; } 2203276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static bool classof(const SDNode *N) { 2204276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands return N->getOpcode() == ISD::ARG_FLAGS; 2205276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2206276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands}; 2207276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2208095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman/// CallSDNode - Node for calls -- ISD::CALL. 2209095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanclass CallSDNode : public SDNode { 2210095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned CallingConv; 2211095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman bool IsVarArg; 2212095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman bool IsTailCall; 221386098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // We might eventually want a full-blown Attributes for the result; that 221486098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // will expand the size of the representation. At the moment we only 221586098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // need Inreg. 221686098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen bool Inreg; 2217095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanprotected: 2218095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman friend class SelectionDAG; 221986098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen CallSDNode(unsigned cc, bool isvararg, bool istailcall, bool isinreg, 2220095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDVTList VTs, const SDValue *Operands, unsigned numOperands) 2221095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman : SDNode(ISD::CALL, VTs, Operands, numOperands), 222286098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall), 222386098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen Inreg(isinreg) {} 2224095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanpublic: 2225095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getCallingConv() const { return CallingConv; } 2226095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned isVarArg() const { return IsVarArg; } 2227095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned isTailCall() const { return IsTailCall; } 222886098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen unsigned isInreg() const { return Inreg; } 2229095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2230095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// Set this call to not be marked as a tail call. Normally setter 2231095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// methods in SDNodes are unsafe because it breaks the CSE map, 22325eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman /// but we don't include the tail call flag for calls so it's ok 22335eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman /// in this case. 2234095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman void setNotTailCall() { IsTailCall = false; } 2235095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2236095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getChain() const { return getOperand(0); } 2237095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getCallee() const { return getOperand(1); } 2238095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2239095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getNumArgs() const { return (getNumOperands() - 2) / 2; } 2240095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getArg(unsigned i) const { return getOperand(2+2*i); } 2241095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getArgFlagsVal(unsigned i) const { 2242095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return getOperand(3+2*i); 2243095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2244095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman ISD::ArgFlagsTy getArgFlags(unsigned i) const { 2245095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return cast<ARG_FLAGSSDNode>(getArgFlagsVal(i).getNode())->getArgFlags(); 2246095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2247095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2248095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getNumRetVals() const { return getNumValues() - 1; } 2249095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman MVT getRetValType(unsigned i) const { return getValueType(i); } 2250095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2251095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman static bool classof(const CallSDNode *) { return true; } 2252095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman static bool classof(const SDNode *N) { 2253095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return N->getOpcode() == ISD::CALL; 2254095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2255095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman}; 2256095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 225783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands/// VTSDNode - This class is used to represent MVT's, which are used 225815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations. 225915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode { 226083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT ValueType; 226115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerprotected: 226215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner friend class SelectionDAG; 226383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands explicit VTSDNode(MVT VT) 2264bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner : SDNode(ISD::VALUETYPE, getSDVTList(MVT::Other)), ValueType(VT) { 226563e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 226615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic: 226715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 226883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getVT() const { return ValueType; } 226915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 227015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const VTSDNode *) { return true; } 227115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const SDNode *N) { 227215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner return N->getOpcode() == ISD::VALUETYPE; 227315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner } 227415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner}; 227515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 22769de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode 22779de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// 227828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass LSBaseSDNode : public MemSDNode { 22799de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelprotected: 22809de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Operand array for load and store 22819de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel /*! 22829de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel \note Moving this array to the base class captures more 22839de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel common functionality shared between LoadSDNode and 22849de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel StoreSDNode 22859de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel */ 22869cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[4]; 22879de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic: 2288475871a144eb604ddaf37503397ba0941442e5fbDan Gohman LSBaseSDNode(ISD::NodeType NodeTy, SDValue *Operands, unsigned numOperands, 228983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDVTList VTs, ISD::MemIndexedMode AM, MVT VT, 2290b625f2f8960de32bc973092aaee8ac62863006feDan Gohman const Value *SV, int SVO, unsigned Align, bool Vol) 2291ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman : MemSDNode(NodeTy, VTs, VT, SV, SVO, Align, Vol) { 2292ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman SubclassData = AM; 2293e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(Ops, Operands, numOperands); 2294b625f2f8960de32bc973092aaee8ac62863006feDan Gohman assert(Align != 0 && "Loads and stores should have non-zero aligment"); 2295437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) && 2296437d452adbc1ec58e73d9fd0dbfe345c69289a23Dan Gohman "Only indexed loads and stores have a non-undef offset operand"); 2297b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 22989de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 2299475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { 230063602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); 230163602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner } 23029de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 2303ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// getAddressingMode - Return the addressing mode for this load or store: 2304ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// unindexed, pre-inc, pre-dec, post-inc, or post-dec. 2305ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman ISD::MemIndexedMode getAddressingMode() const { 2306ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman return ISD::MemIndexedMode(SubclassData & 7); 2307ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 2308b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 2309b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isIndexed - Return true if this is a pre/post inc/dec load/store. 2310ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; } 2311b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 2312b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. 2313ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; } 2314b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 231513d57320bd212483463d4f8992d5787b29eda5dfBill Wendling static bool classof(const LSBaseSDNode *) { return true; } 2316b625f2f8960de32bc973092aaee8ac62863006feDan Gohman static bool classof(const SDNode *N) { 2317b625f2f8960de32bc973092aaee8ac62863006feDan Gohman return N->getOpcode() == ISD::LOAD || 2318b625f2f8960de32bc973092aaee8ac62863006feDan Gohman N->getOpcode() == ISD::STORE; 2319b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 23209de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel}; 23219de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 232224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes. 232324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 23249de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode { 232524446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 232624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 2327475871a144eb604ddaf37503397ba0941442e5fbDan Gohman LoadSDNode(SDValue *ChainPtrOff, SDVTList VTs, 232883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT, 232995c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 2330b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::LOAD, ChainPtrOff, 3, 2331ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman VTs, AM, LVT, SV, O, Align, Vol) { 2332ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman SubclassData |= (unsigned short)ETy << 3; 2333ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 233424446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 233524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2336ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// getExtensionType - Return whether this is a plain node, 2337ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// or one of the varieties of value-extending loads. 2338ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman ISD::LoadExtType getExtensionType() const { 2339ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman return ISD::LoadExtType((SubclassData >> 3) & 3); 2340ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 2341ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman 2342475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(1); } 2343475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { return getOperand(2); } 234439354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 234524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const LoadSDNode *) { return true; } 234624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 234724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD; 234824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 234924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 235024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 235124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes. 235224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 23539de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode { 235424446e253a17720f6462288255ab5ebd13b8491fEvan Chengprotected: 235524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 2356475871a144eb604ddaf37503397ba0941442e5fbDan Gohman StoreSDNode(SDValue *ChainValuePtrOff, SDVTList VTs, 235783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands ISD::MemIndexedMode AM, bool isTrunc, MVT SVT, 235824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 2359b625f2f8960de32bc973092aaee8ac62863006feDan Gohman : LSBaseSDNode(ISD::STORE, ChainValuePtrOff, 4, 2360ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman VTs, AM, SVT, SV, O, Align, Vol) { 2361ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman SubclassData |= (unsigned short)isTrunc << 3; 2362ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 236324446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 236424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2365ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// isTruncatingStore - Return true if the op does a truncation before store. 2366ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// For integers this is the same as doing a TRUNCATE and storing the result. 2367ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// For floats, it is the same as doing an FP_ROUND and storing the result. 2368ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman bool isTruncatingStore() const { return (SubclassData >> 3) & 1; } 2369ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman 2370475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getValue() const { return getOperand(1); } 2371475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(2); } 2372475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { return getOperand(3); } 237339354cb743c5a1473de7a80b957c61e92cf76852Chris Lattner 23746d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng static bool classof(const StoreSDNode *) { return true; } 237524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 237624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::STORE; 237724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 237824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 237924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 238015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 23811080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { 23821080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNode *Node; 23831080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned Operand; 2384ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 23851080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 23861080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic: 23871080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator==(const SDNodeIterator& x) const { 23881080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Operand == x.Operand; 23891080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 23901080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 23911080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 23921080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNodeIterator &operator=(const SDNodeIterator &I) { 23931080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 23941080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner Operand = I.Operand; 23951080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 23961080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 2397ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 23981080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator*() const { 2399ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOperand(Operand).getNode(); 24001080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24011080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator->() const { return operator*(); } 2402ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 24031080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator& operator++() { // Preincrement 24041080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner ++Operand; 24051080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 24061080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24071080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator operator++(int) { // Postincrement 2408ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SDNodeIterator tmp = *this; ++*this; return tmp; 24091080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24101080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24111080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 24121080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator end (SDNode *N) { 24131080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator(N, N->getNumOperands()); 24141080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24151080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24161080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned getOperand() const { return Operand; } 24171080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNode *getNode() const { return Node; } 24181080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 24191080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24201080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> { 24211080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNode NodeType; 24221080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNodeIterator ChildIteratorType; 24231080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static inline NodeType *getEntryNode(SDNode *N) { return N; } 2424ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_begin(NodeType *N) { 24251080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::begin(N); 24261080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 2427ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_end(NodeType *N) { 24281080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::end(N); 24291080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24301080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 24311080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24320e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// LargestSDNode - The largest SDNode class. 24330e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// 24340e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohmantypedef LoadSDNode LargestSDNode; 24350e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman 2436fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// MostAlignedSDNode - The SDNode class with the greatest alignment 2437fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// requirement. 2438fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// 2439015b714f298ce3122302a4e996b81bd3e8c750cdDan Gohmantypedef ARG_FLAGSSDNode MostAlignedSDNode; 2440b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 2441c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD { 2442186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// isNormalLoad - Returns true if the specified node is a non-extending 2443186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// and unindexed load. 2444186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng inline bool isNormalLoad(const SDNode *N) { 2445c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N); 2446c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD && 2447186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng Ld->getAddressingMode() == ISD::UNINDEXED; 2448186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng } 2449186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng 245024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// isNON_EXTLoad - Returns true if the specified node is a non-extending 245124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// load. 245224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng inline bool isNON_EXTLoad(const SDNode *N) { 2453c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 245424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 245524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 245624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2457c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 2458c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2459c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isEXTLoad(const SDNode *N) { 2460c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 246124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 2462c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 2463c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2464c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 2465c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2466c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isSEXTLoad(const SDNode *N) { 2467c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 246824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 2469c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 2470c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2471c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 2472c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2473c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isZEXTLoad(const SDNode *N) { 2474c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 247524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 2476c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 24778b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 2478c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load. 247902c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// 248002c50e4891841c28b2a743731dfc60744bb78879Evan Cheng inline bool isUNINDEXEDLoad(const SDNode *N) { 2481c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 248202c50e4891841c28b2a743731dfc60744bb78879Evan Cheng cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 248302c50e4891841c28b2a743731dfc60744bb78879Evan Cheng } 248402c50e4891841c28b2a743731dfc60744bb78879Evan Cheng 2485c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isNormalStore - Returns true if the specified node is a non-truncating 2486c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// and unindexed store. 2487c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands inline bool isNormalStore(const SDNode *N) { 2488c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands const StoreSDNode *St = dyn_cast<StoreSDNode>(N); 2489c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return St && !St->isTruncatingStore() && 2490c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands St->getAddressingMode() == ISD::UNINDEXED; 2491c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands } 2492c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands 24938b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 24948b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 24958b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isNON_TRUNCStore(const SDNode *N) { 2496c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore(); 24978b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 24988b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 24998b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isTRUNCStore - Returns true if the specified node is a truncating 25008b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 25018b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isTRUNCStore(const SDNode *N) { 2502c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore(); 2503c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands } 2504c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands 2505c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isUNINDEXEDStore - Returns true if the specified node is an 2506c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// unindexed store. 2507c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands inline bool isUNINDEXEDStore(const SDNode *N) { 2508c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && 2509c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 25108b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 2511c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 2512c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2513c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 251463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace 251563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 251663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif 2517