SelectionDAGNodes.h revision f5a5546f435a261c93078defb41ed18d9cafd7d3
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" 279008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman#include "llvm/ADT/SmallVector.h" 28fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/STLExtras.h" 29d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng#include "llvm/CodeGen/ValueTypes.h" 3036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman#include "llvm/CodeGen/MachineMemOperand.h" 310e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/Allocator.h" 320e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman#include "llvm/Support/RecyclingAllocator.h" 3339931a3dbac1aa2fe2ec14f26001c8c29102940cJeff Cohen#include "llvm/Support/DataTypes.h" 341e86a66b00b94adc4ad6977ef6b47c516ac62cecDevang Patel#include "llvm/Support/DebugLoc.h" 3563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#include <cassert> 36de551f91d8816632a76a065084caab9fab6aacffDan Gohman#include <climits> 3763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 3863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace llvm { 3963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 4063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SelectionDAG; 4163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalValue; 4263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass MachineBasicBlock; 43d6594ae54cfde4db4d30272192645c0a45fb9902Evan Chengclass MachineConstantPoolValue; 4463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass SDNode; 4583489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patelclass Value; 4676c1b97e4020faace8c95a127f1eab66c278fb58Chris Lattnertemplate <typename T> struct DenseMapInfo; 4763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnertemplate <typename T> struct simplify_type; 488e4018e2de52c534405d7155c7009d0b35afb861Cedric Venettemplate <typename T> struct ilist_traits; 4963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 500b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SDVTList - This represents a list of ValueType's that has been intern'd by 510b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// a SelectionDAG. Instances of this simple value class are returned by 520b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// SelectionDAG::getVTList(...). 530b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner/// 540b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattnerstruct SDVTList { 5583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *VTs; 56168840662e66ef8eaff6cd6a9389c4451f606e73Dan Gohman unsigned int NumVTs; 570b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner}; 580b3e525a3a6b55b66dc5676675712b26e4c1ed9fChris Lattner 5963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// ISD namespace - This namespace contains an enum which represents all of the 6063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// SelectionDAG node types and value types. 6163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner/// 6263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnernamespace ISD { 63d0b82b301d700217a716526f9329bb031e0d6578Anton Korobeynikov 6463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 654f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// ISD::NodeType enum - This enum defines the target-independent operators 664f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// for a SelectionDAG. 6763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// 684f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// Targets may also define target-dependent operator codes for SDNodes. For 694f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// example, on x86, these are the enum values in the X86ISD namespace. 704f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// Targets should aim to use target-independent operators to model their 714f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// instruction sets as much as possible, and only use target-dependent 724f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// operators when they have special requirements. 734f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// 744f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// Finally, during and after selection proper, SNodes may use special 754f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// operator codes that correspond directly with MachineInstr opcodes. These 764f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// are used to represent selected instructions. See the isMachineOpcode() 774f80178a104f03929e7e7ec782971830cf4cca01Dan Gohman /// and getMachineOpcode() member functions of SDNode. 78f70dab704929cfeaae4fa6bd69b9037cd75a0d48Dan Gohman /// 7963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner enum NodeType { 80f49f0cdb48a9e6525b44f8f4b210558df106ff4eDan Gohman // DELETED_NODE - This is an illegal value that is used to catch 813258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner // errors. This opcode is not a legal opcode for any node. 823258ed6a361bf405a89f7af0b1885841d9909516Chris Lattner DELETED_NODE, 83fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 848a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // EntryToken - This is the marker used to indicate the start of the region. 858a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner EntryToken, 868a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner 87b2ab0e7471df7126a5b63fe8414b95c9584a0214Bill Wendling // TokenFactor - This node takes multiple tokens as input and produces a 888a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // single token result. This is used to represent the fact that the operand 898a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // operators are independent of each other. 908a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner TokenFactor, 91fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 92fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // AssertSext, AssertZext - These nodes record if a register contains a 93fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // value that has already been zero or sign extended from a narrower type. 94fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // These nodes take two operands. The first is the node that has already 95f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // been extended, and the second is a value type node indicating the width 96f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman // of the extension 97f7f3d321916c1ef3a82b2a175a368a148b1ede46Nate Begeman AssertSext, AssertZext, 98ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 998a496fcffdcba757412fc5cc6c772260ccfde000Chris Lattner // Various leaf nodes. 1007f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman BasicBlock, VALUETYPE, ARG_FLAGS, CONDCODE, Register, 1011ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng Constant, ConstantFP, 102b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio GlobalAddress, GlobalTLSAddress, FrameIndex, 103056292fd738924f3f7703725d8f630983794b5a5Bill Wendling JumpTable, ConstantPool, ExternalSymbol, 1041ab7d859cf5c490612799d7e132c0b1c39f8f497Evan Cheng 10582c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth // The address of the GOT 10682c3d8f81ab20dc7571f29ffc46a5bb1b7ed8323Andrew Lenharth GLOBAL_OFFSET_TABLE, 107fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 108bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and 109bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // llvm.returnaddress on the DAG. These nodes take one operand, the index 110bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // of the frame or return address to return. An index of zero corresponds 111bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // to the current function's frame or return address, an index of one to the 112bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman // parent's frame or return address, and so on. 113bcc5f36765e8111c13873a0c0dc874c92385d808Nate Begeman FRAMEADDR, RETURNADDR, 1142365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 1152365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // FRAME_TO_ARGS_OFFSET - This node represents offset from frame pointer to 1162365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // first (possible) on-stack argument. This is needed for correct stack 1172365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // adjustment during unwind. 1182365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov FRAME_TO_ARGS_OFFSET, 119fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 120f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EXCEPTIONADDR(INCHAIN) - This node represents the 121f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // address of the exception block on entry to an landing pad block. 122f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EXCEPTIONADDR, 123fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 124f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents 125f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey // the selection index of the exception thrown. 126f09f2e304dc82010d2e02a9b40a8c5fb0091490cJim Laskey EHSELECTION, 127beec30eaf301bd6882cd06800b5175b94f033f9dAndrew Lenharth 1282365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // OUTCHAIN = EH_RETURN(INCHAIN, OFFSET, HANDLER) - This node represents 1292365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // 'eh_return' gcc dwarf builtin, which is used to return from 1302365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // exception. The general meaning is: adjust stack by OFFSET and pass 1312365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov // execution to HANDLER. Many platform-related details also :) 1322365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov EH_RETURN, 1332365f51ed03afe6993bae962fdc2e5a956a64cd5Anton Korobeynikov 134ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // TargetConstant* - Like Constant*, but the DAG does not do any folding or 135ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner // simplification of the constant. 136056f9f61d071c6c583951678f2bf543a1316efccChris Lattner TargetConstant, 137ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner TargetConstantFP, 138fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 139f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or 140f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // anything else with this node, and this is valid in the target-specific 141f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner // dag, turning into a GlobalAddress operand. 142f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner TargetGlobalAddress, 143b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio TargetGlobalTLSAddress, 144afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner TargetFrameIndex, 14537efe6764568a3829fee26aba532283131d1a104Nate Begeman TargetJumpTable, 146aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner TargetConstantPool, 147056292fd738924f3f7703725d8f630983794b5a5Bill Wendling TargetExternalSymbol, 148fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 149ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT = INTRINSIC_WO_CHAIN(INTRINSICID, arg1, arg2, ...) 150ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with no side effects. 151ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// The first operand is the ID number of the intrinsic from the 152ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// llvm::Intrinsic namespace. The operands to the intrinsic follow. The 153ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// node has returns the result of the intrinsic. 154ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_WO_CHAIN, 155fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 156ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) 157ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 158ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// returns a result. The first operand is a chain pointer. The second is 159ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// the ID number of the intrinsic from the llvm::Intrinsic namespace. The 160ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// operands to the intrinsic follow. The node has two results, the result 161ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// of the intrinsic and an output chain. 162ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_W_CHAIN, 16363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 164ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) 165ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// This node represents a target intrinsic function with side effects that 166ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// does not return a result. The first operand is a chain pointer. The 167ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// second is the ID number of the intrinsic from the llvm::Intrinsic 168ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner /// namespace. The operands to the intrinsic follow. 169ef8ef916348ad0da964687358e8be614e2470d67Chris Lattner INTRINSIC_VOID, 170fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 171d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner // CopyToReg - This node has three operands: a chain, a register number to 172fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // set to this value, and a value. 17363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyToReg, 17463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // CopyFromReg - This node indicates that the input value is a virtual or 17663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // physical register that is defined outside of the scope of this 177ab2a7542546bf781fa373e20095be0e344f5b3ccDan Gohman // SelectionDAG. The register is available from the RegisterSDNode object. 17863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner CopyFromReg, 17963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 180fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman // UNDEF - An undefined node 181fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman UNDEF, 182fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 183b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node 184b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// represents the formal arguments for a function. CC# is a Constant value 185b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// indicating the calling convention of the function, and ISVARARG is a 186b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// flag that indicates whether the function is varargs or not. This node 187b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// has one result value for each incoming argument, plus one for the output 188b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// chain. It must be custom legalized. See description of CALL node for 189b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// FLAG argument contents explanation. 190fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 191681ee1c1c3f7c3558c29a5bf3a668c1d0784c399Chris Lattner FORMAL_ARGUMENTS, 192fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 193095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// RV1, RV2...RVn, CHAIN = CALL(CHAIN, CALLEE, 194b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// ARG0, FLAG0, ARG1, FLAG1, ... ARGn, FLAGn) 1956c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner /// This node represents a fully general function call, before the legalizer 196b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// runs. This has one result value for each argument / flag pair, plus 197b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// a chain result. It must be custom legalized. Flag argument indicates 198b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// misc. argument attributes. Currently: 199b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 0 - signness 200b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 1 - 'inreg' attribute 201b10308e440c80dd6ffb4b478f741ff7e5f30cb48Anton Korobeynikov /// Bit 2 - 'sret' attribute 202594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 4 - 'byval' attribute 203594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 5 - 'nest' attribute 204594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 6-9 - alignment of byval structures 205594d37e21aea4ef841d9ee5d9c328c4bf1c6bed7Rafael Espindola /// Bit 10-26 - size of byval structures 20613a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// Bits 31:27 - argument ABI alignment in the first argument piece and 20713a3cee13133711eb95174a004dca4421ccd1cd9Lauro Ramos Venancio /// alignment '1' in other argument pieces. 208095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// 209095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// CALL nodes use the CallSDNode subclass of SDNode, which 210095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// additionally carries information about the calling convention, 211095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// whether the call is varargs, and if it's marked as a tail call. 212095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// 2136c0bfc723779366698d3936b63dcddc6164c2d33Chris Lattner CALL, 214fc1b1dad88a256ab5ab16dd548ad82df8efa2ca9Nate Begeman 21525eb043759c23b61769108f78382eb9701c41db2Duncan Sands // EXTRACT_ELEMENT - This is used to get the lower or upper (determined by 216041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // a Constant, which is required to be operand #1) half of the integer or 217041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // float value specified as operand #0. This is only for use before 218041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands // legalization, for values that will be broken into multiple registers. 21963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner EXTRACT_ELEMENT, 22063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 22163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // BUILD_PAIR - This is the opposite of EXTRACT_ELEMENT in some ways. Given 22263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // two values of the same integer value type, this produces a value twice as 22363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner // big. Like EXTRACT_ELEMENT, this can only be used before legalization. 22463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner BUILD_PAIR, 225041cde26eaf4ef6171ff1a44aeedd08d7a1cba6cDuncan Sands 226006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // MERGE_VALUES - This node takes multiple discrete operands and returns 227006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // them all as its individual results. This nodes has exactly the same 228006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // number of inputs and outputs, and is only valid before legalization. 229006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // This node is useful for some pieces of the code generator that want to 230006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner // think about a single node with multiple results, not multiple nodes. 231006e3e3649b2e19762b7bc134292b781569685b0Chris Lattner MERGE_VALUES, 23263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 233615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple integer binary arithmetic operators. 234bede0b7dd7c70792b09f6d38f6f2dfe7c1feb1d1Chris Lattner ADD, SUB, MUL, SDIV, UDIV, SREM, UREM, 235fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 236fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SMUL_LOHI/UMUL_LOHI - Multiply two integers of type iN, producing 237b36904be918b72cc4c714552d42d6a713f27bbf5Duncan Sands // a signed/unsigned value of type i[2*N], and return the full value as 238fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // two results, each of type iN. 239fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SMUL_LOHI, UMUL_LOHI, 240fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman 241fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // SDIVREM/UDIVREM - Divide two integers and produce both a quotient and 242fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman // remainder result. 243fdd04d5ddecb1d1f3030839520109308137b73dcDan Gohman SDIVREM, UDIVREM, 244fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 245874ae251c317788391f9c3f113957802d390a063Dale Johannesen // CARRY_FALSE - This node is used when folding other nodes, 246874ae251c317788391f9c3f113957802d390a063Dale Johannesen // like ADDC/SUBC, which indicate the carry result is always false. 247874ae251c317788391f9c3f113957802d390a063Dale Johannesen CARRY_FALSE, 248874ae251c317788391f9c3f113957802d390a063Dale Johannesen 249551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-setting nodes for multiple precision addition and subtraction. 250551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // These nodes take two operands of the same value type, and produce two 251551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // results. The first result is the normal add or sub result, the second 252874ae251c317788391f9c3f113957802d390a063Dale Johannesen // result is the carry flag result. 253551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDC, SUBC, 254fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 255551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // Carry-using nodes for multiple precision addition and subtraction. These 256551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // nodes take three operands: The first two are the normal lhs and rhs to 257551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // the add or sub, and the third is the input carry flag. These nodes 258551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // produce two results; the normal result of the add or sub, and the output 259551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // carry flag. These nodes both read and write a carry flag to allow them 260551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman // to them to be chained together for add and sub of arbitrarily large 261874ae251c317788391f9c3f113957802d390a063Dale Johannesen // values. 262551bf3f80058a026b6a128dffd5530019e1df1b9Nate Begeman ADDE, SUBE, 263ea7b527aa56ad0fe547d3d99b21e845a49a031cbBill Wendling 264253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition. 265253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // These nodes take two operands: the normal LHS and RHS to the add. They 266253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // produce two results: the normal result of the add, and a boolean that 267253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // indicates if an overflow occured (*not* a flag, because it may be stored 268253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // to memory, etc.). If the type of the boolean is not i1 then the high 26903228089d5235f8c90477f88809139464e9c6ea5Duncan Sands // bits conform to getBooleanContents. 270253174bf50c932abaa680f465e2888c0e5272267Bill Wendling // These nodes are generated from the llvm.[su]add.with.overflow intrinsics. 2711c55a9c0cc355ad72c55ae7665143b9a992d223bBill Wendling SADDO, UADDO, 272ea7b527aa56ad0fe547d3d99b21e845a49a031cbBill Wendling 27374c376529101acbe141a256d0bf23a44eb454c84Bill Wendling // Same for subtraction 27474c376529101acbe141a256d0bf23a44eb454c84Bill Wendling SSUBO, USUBO, 27574c376529101acbe141a256d0bf23a44eb454c84Bill Wendling 27674c376529101acbe141a256d0bf23a44eb454c84Bill Wendling // Same for multiplication 27774c376529101acbe141a256d0bf23a44eb454c84Bill Wendling SMULO, UMULO, 27874c376529101acbe141a256d0bf23a44eb454c84Bill Wendling 279615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner // Simple binary floating point operators. 280615c2d0920862ae7d4d766ee3da660ecf2197308Chris Lattner FADD, FSUB, FMUL, FDIV, FREM, 28138bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner 28238bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(X, Y) - Return the value of X with the sign of Y. NOTE: This 28338bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // DAG node does not require that X and Y have the same type, just that they 28438bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // are both floating point. X and the result must have the same type. 28538bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner // FCOPYSIGN(f32, f64) is allowed. 28638bf3bffe3abfd00169d6dcf4fad7e2197808dbfChris Lattner FCOPYSIGN, 287fa984b61e42c94ad7e66cf2880ca826dba488d30Chris Lattner 2881a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // INT = FGETSIGN(FP) - Return the sign bit of the specified floating point 2891a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner // value as an integer 0/1 value. 2901a3048bb8e0f3de0b4e56704c15c556c71565f4bChris Lattner FGETSIGN, 291fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 292c885165e664f3b465403e1b6ce57ba63f57c5f0cBob Wilson /// BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the 293c885165e664f3b465403e1b6ce57ba63f57c5f0cBob Wilson /// specified, possibly variable, elements. The number of elements is 294c885165e664f3b465403e1b6ce57ba63f57c5f0cBob Wilson /// required to be a power of two. The types of the operands must all be 295c885165e664f3b465403e1b6ce57ba63f57c5f0cBob Wilson /// the same and must match the vector element type, except that integer 296c885165e664f3b465403e1b6ce57ba63f57c5f0cBob Wilson /// types are allowed to be larger than the element type, in which case 297c885165e664f3b465403e1b6ce57ba63f57c5f0cBob Wilson /// the operands are implicitly truncated. 29822232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner BUILD_VECTOR, 299fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 3007f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element 3014f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// at IDX replaced with VAL. If the type of VAL is larger than the vector 3024f069e6db1772a7e6cd8bfc360d819b56557badcDuncan Sands /// element type then VAL is truncated before replacement. 30322232f659bec0f4c23ec46445d3bd3c4deb68686Chris Lattner INSERT_VECTOR_ELT, 3044b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner 3054b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner /// EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR 3067f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// identified by the (potentially variable) element number IDX. 3074b8db6c453fd3a7b07bc7c0e8092018530701ffdChris Lattner EXTRACT_VECTOR_ELT, 308fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 3097f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// CONCAT_VECTORS(VECTOR0, VECTOR1, ...) - Given a number of values of 3107f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector type with the same length and element type, this produces a 3117f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// concatenated vector result value, with length equal to the sum of the 312b6f5b00c3bad3415d3f2ee1a6d5ee5a6f66a4540Dan Gohman /// lengths of the input vectors. 3137f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman CONCAT_VECTORS, 314fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 3157f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an 3167f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// vector value) starting with the (potentially variable) element number 3177f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman /// IDX, which must be a multiple of the result vector length. 3187f32156bb9c017b71971c52fac892fa7b9b06dd2Dan Gohman EXTRACT_SUBVECTOR, 31959c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 320a641575828192c741531d431fbf191e6c1ba17c5Nate Begeman /// VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as 321a641575828192c741531d431fbf191e6c1ba17c5Nate Begeman /// VEC1/VEC2. A VECTOR_SHUFFLE node also contains an array of constant int 322a641575828192c741531d431fbf191e6c1ba17c5Nate Begeman /// values that indicate which value (or undef) each result element will 323a641575828192c741531d431fbf191e6c1ba17c5Nate Begeman /// get. These constant ints are accessible through the 324a641575828192c741531d431fbf191e6c1ba17c5Nate Begeman /// ShuffleVectorSDNode class. This is quite similar to the Altivec 325a641575828192c741531d431fbf191e6c1ba17c5Nate Begeman /// 'vperm' instruction, except that the indices must be constants and are 326a641575828192c741531d431fbf191e6c1ba17c5Nate Begeman /// in terms of the element size of VEC1/VEC2, not in terms of bytes. 32749c6d3eba8869cf945f6c55ea243466e2b406fe8Chris Lattner VECTOR_SHUFFLE, 32859c2e868ff15d77e00c89ad9591a87e84bd0665aDuncan Sands 329210721aecc0916315f61660dc387a96b89ec423bChris Lattner /// SCALAR_TO_VECTOR(VAL) - This represents the operation of loading a 330a95afe2b5fb7a716ff4cc7bb623995a0a4c56411Nate Begeman /// scalar value into element 0 of the resultant vector type. The top 331b10b5ac8d9da43ca2db61401a20af6b676c98438Duncan Sands /// elements 1 to N-1 of the N-element vector are undefined. The type 332b10b5ac8d9da43ca2db61401a20af6b676c98438Duncan Sands /// of the operand must match the vector element type, except when they 333b10b5ac8d9da43ca2db61401a20af6b676c98438Duncan Sands /// are integer types. In this case the operand is allowed to be wider 334b10b5ac8d9da43ca2db61401a20af6b676c98438Duncan Sands /// than the vector element type, and is implicitly truncated to it. 335210721aecc0916315f61660dc387a96b89ec423bChris Lattner SCALAR_TO_VECTOR, 336fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 353fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // 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 355fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // 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 368fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // 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, 394fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 424fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 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, 427fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 448fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // same address (or equivalently for vector format conversions, etc). The 449fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // source and result are required to have the same bit size (e.g. 450fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // 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, 453fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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, 466fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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, 474fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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, 516fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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, 531fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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, 543fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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, 548fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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, 552fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 560fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 561fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // 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, 564fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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, 569fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 588fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // 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, 600fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 624fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel // 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, 658fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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); 681fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 68263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner //===--------------------------------------------------------------------===// 683fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 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. 728fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 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 //===--------------------------------------------------------------------===// 833fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 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 914fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 915572dee71af1313e6742e1dfd5274fff326b9ef1cChris Lattner /// reachesChainWithoutSideEffects - Return true if this operand (which must 916fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 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. 920fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel bool reachesChainWithoutSideEffects(SDValue Dest, 921dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein unsigned Depth = 2) const; 922fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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> { 936fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel static inline SDValue getEmptyKey() { 937fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel return SDValue((SDNode*)-1, -1U); 938dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 939fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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; 977fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 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; } 993fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 } 1011fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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; 1074fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 1089f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// OperandList - The values that are used by this operation. 10900442fbfadbeea21eee9df88dc466d95e040dde6bChris Lattner /// 10919cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse *OperandList; 1092fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 1093f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// ValueList - The types of the values this node defines. SDNode's may 1094f71e843f651ad94e19f85daa947fe24312b40d11Chris Lattner /// define multiple values simultaneously. 109583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *ValueList; 109663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1097e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// UseList - List of uses for this SDNode. 1098e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman SDUse *UseList; 1099dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein 11008f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman /// NumOperands/NumValues - The number of entries in the Operand/Value list. 11018f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman unsigned short NumOperands, NumValues; 11028f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman 11038f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman /// debugLoc - source line information. 11048f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman DebugLoc debugLoc; 11058f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman 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 11240f8b53f19d29013ab18f3d444cea1e6305405611Dan 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 1169fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 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 } 1189fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 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 1259fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// 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); 132880d6977e90c22313d5a62ac28811e0386a806affStuart Hastings void print_types(raw_ostream &OS, const SelectionDAG *G) const; 132980d6977e90c22313d5a62ac28811e0386a806affStuart Hastings void print_details(raw_ostream &OS, const SelectionDAG *G) const; 1330944fac71e082cc2664cc71b4d3f6c72bab7143fbChris Lattner void print(raw_ostream &OS, const SelectionDAG *G = 0) const; 133180d6977e90c22313d5a62ac28811e0386a806affStuart Hastings void printr(raw_ostream &OS, const SelectionDAG *G = 0) const; 133263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner void dump() const; 133380d6977e90c22313d5a62ac28811e0386a806affStuart Hastings void dumpr() const; 1334efe58694050e48b61584b8454434dcd1ad886a71Chris Lattner void dump(const SelectionDAG *G) const; 133563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 133663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *) { return true; } 133763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1338583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// Profile - Gather unique data for the node. 1339583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey /// 1340b8d2f550b84523e8a73198f98e5d450ec3b4fee7Dan Gohman void Profile(FoldingSetNodeID &ID) const; 1341583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey 1342e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// addUse - This method should only be used by the SDUse class. 1343109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner /// 1344e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void addUse(SDUse &U) { U.addToList(&UseList); } 1345e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1346e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmanprotected: 134783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands static SDVTList getSDVTList(MVT VT) { 134863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner SDVTList Ret = { getValueTypeList(VT), 1 }; 134963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner return Ret; 13502d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 135163e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner 1352fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs, const SDValue *Ops, 1353124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen unsigned NumOps) 13543b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen : NodeType(Opc), OperandsNeedDelete(true), SubclassData(0), 13558f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman NodeId(-1), 13563b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen OperandList(NumOps ? new SDUse[NumOps] : 0), 13578f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman ValueList(VTs.VTs), UseList(NULL), 13583b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen NumOperands(NumOps), NumValues(VTs.NumVTs), 13598f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman debugLoc(dl) { 13603b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen for (unsigned i = 0; i != NumOps; ++i) { 13613b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen OperandList[i].setUser(this); 13623b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen OperandList[i].setInitial(Ops[i]); 13633b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen } 13643b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen } 13653b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen 13663b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// This constructor adds no operands itself; operands can be 13673b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen /// set later with InitOperands. 1368124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johannesen SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs) 13693b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen : NodeType(Opc), OperandsNeedDelete(false), SubclassData(0), 13708f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman NodeId(-1), OperandList(0), ValueList(VTs.VTs), UseList(NULL), 13718f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman NumOperands(0), NumValues(VTs.NumVTs), 13728f1174d13d233fe6b8418475df15eeff87a52f37Dan Gohman debugLoc(dl) {} 1373fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 1374e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with 1 operand. 1375e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue &Op0) { 1376e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setUser(this); 1377e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setInitial(Op0); 1378e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = 1; 1379bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner OperandList = Ops; 1380e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman } 1381e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1382e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with 2 operands. 1383e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1) { 1384e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setUser(this); 1385e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setInitial(Op0); 1386e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setUser(this); 1387e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setInitial(Op1); 1388e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = 2; 1389e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList = Ops; 1390e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman } 1391e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1392e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with 3 operands. 1393e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1, 1394e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman const SDValue &Op2) { 1395e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setUser(this); 1396e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setInitial(Op0); 1397e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setUser(this); 1398e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setInitial(Op1); 1399e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[2].setUser(this); 1400e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[2].setInitial(Op2); 1401e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = 3; 1402e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList = Ops; 1403e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman } 1404e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1405e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with 4 operands. 1406e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue &Op0, const SDValue &Op1, 1407e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman const SDValue &Op2, const SDValue &Op3) { 1408e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setUser(this); 1409e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[0].setInitial(Op0); 1410e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setUser(this); 1411e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[1].setInitial(Op1); 1412e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[2].setUser(this); 1413e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[2].setInitial(Op2); 1414e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[3].setUser(this); 1415e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[3].setInitial(Op3); 1416e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = 4; 1417e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList = Ops; 1418e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman } 1419e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1420e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman /// InitOperands - Initialize the operands list of this with N operands. 1421e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman void InitOperands(SDUse *Ops, const SDValue *Vals, unsigned N) { 1422e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman for (unsigned i = 0; i != N; ++i) { 1423e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[i].setUser(this); 1424e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Ops[i].setInitial(Vals[i]); 1425dc1adac582fa120861f18ae7221bfe1421fea59fRoman Levenstein } 1426e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman NumOperands = N; 1427e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman OperandList = Ops; 1428bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 14290fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman 14300fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman /// DropOperands - Release the operands and set this node to have 1431e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// zero operands. 14320fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman void DropOperands(); 143363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 143463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 143563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1436475871a144eb604ddaf37503397ba0941442e5fbDan Gohman// Define inline functions from the SDValue class. 143763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1438475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getOpcode() const { 1439ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOpcode(); 144063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1441475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline MVT SDValue::getValueType() const { 1442ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getValueType(ResNo); 144363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1444475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getNumOperands() const { 1445ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getNumOperands(); 144663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1447475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline const SDValue &SDValue::getOperand(unsigned i) const { 1448ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOperand(i); 144963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} 1450475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline uint64_t SDValue::getConstantOperandVal(unsigned i) const { 1451ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getConstantOperandVal(i); 1452c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 1453475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isTargetOpcode() const { 1454ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->isTargetOpcode(); 14550f66a9172175aa7c3055333358170581c999219bNate Begeman} 1456475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::isMachineOpcode() const { 1457ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->isMachineOpcode(); 1458e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman} 1459475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline unsigned SDValue::getMachineOpcode() const { 1460ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getMachineOpcode(); 14610f66a9172175aa7c3055333358170581c999219bNate Begeman} 1462475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::use_empty() const { 1463ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return !Node->hasAnyUseOfValue(ResNo); 1464e1b50639a860934685dff840e1826b16dbe6a344Dan Gohman} 1465475871a144eb604ddaf37503397ba0941442e5fbDan Gohmaninline bool SDValue::hasOneUse() const { 1466ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->hasNUsesOfValue(1, ResNo); 14677a24cdc4ed5c357e9de4e36a39379e0aa67f6f9cDan Gohman} 1468124c7fdd69bd0eebdec8aab7caa2f8779a56d878Dale Johanneseninline const DebugLoc SDValue::getDebugLoc() const { 14693b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen return Node->getDebugLoc(); 14703b1a9c5bceb40a5cf0aecdaf7a389c72a855b52aDale Johannesen} 147163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1472e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman// Define inline functions from the SDUse class. 1473e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1474e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::set(const SDValue &V) { 1475e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman if (Val.getNode()) removeFromList(); 1476e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Val = V; 1477e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman if (V.getNode()) V.getNode()->addUse(*this); 1478e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman} 1479e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1480e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::setInitial(const SDValue &V) { 1481e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Val = V; 1482e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman V.getNode()->addUse(*this); 1483e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman} 1484e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 1485e7852d014432a06c783de3c350eb96e686f10f92Dan Gohmaninline void SDUse::setNode(SDNode *N) { 1486e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman if (Val.getNode()) removeFromList(); 1487e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman Val.setNode(N); 1488e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman if (N) N->addUse(*this); 1489e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman} 1490e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman 14913f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// UnarySDNode - This class is used for single-operand SDNodes. This is solely 14923f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 14933f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass UnarySDNode : public SDNode { 14949cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Op; 14953f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 14963edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen UnarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X) 14973edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : SDNode(Opc, dl, VTs) { 14983edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen InitOperands(&Op, X); 14993edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 15003f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 15013f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 15023f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// BinarySDNode - This class is used for two-operand SDNodes. This is solely 15033f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 15043f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass BinarySDNode : public SDNode { 15059cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[2]; 15063f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 15073edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen BinarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X, SDValue Y) 15083edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : SDNode(Opc, dl, VTs) { 15093edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen InitOperands(Ops, X, Y); 15103edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 15113f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 15123f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 15133f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// TernarySDNode - This class is used for three-operand SDNodes. This is solely 15143f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner/// to allow co-allocation of node operands with the node itself. 15153f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerclass TernarySDNode : public SDNode { 15169cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[3]; 15173f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattnerpublic: 15183edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen TernarySDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, SDValue X, SDValue Y, 15193edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen SDValue Z) 15203edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : SDNode(Opc, dl, VTs) { 15213edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen InitOperands(Ops, X, Y, Z); 15223edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 15233f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner}; 15243f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 15253f97eb449b08069e3370d4ba7566c60bdbf0babdChris Lattner 1526d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// HandleSDNode - This class is used to form a handle around another node that 1527d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// is persistant and is updated across invocations of replaceAllUsesWith on its 1528d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// operand. This node should be directly created by end-users and not added to 1529d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner/// the AllNodes list. 1530d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerclass HandleSDNode : public SDNode { 15319cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Op; 1532d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattnerpublic: 1533ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling // FIXME: Remove the "noinline" attribute once <rdar://problem/5852746> is 1534ef02b815cb37017d8dbac2f18c75bff0aa317163Bill Wendling // fixed. 153569cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#ifdef __GNUC__ 1536475871a144eb604ddaf37503397ba0941442e5fbDan Gohman explicit __attribute__((__noinline__)) HandleSDNode(SDValue X) 153769cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#else 1538475871a144eb604ddaf37503397ba0941442e5fbDan Gohman explicit HandleSDNode(SDValue X) 153969cedcbcece7e1138c77aac5b34a1377006254c1Bill Wendling#endif 154092570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::HANDLENODE, DebugLoc::getUnknownLoc(), 154192570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(MVT::Other)) { 1542e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(&Op, X); 1543bc2e26241d507ecd6c79598e5175f90852b716b3Chris Lattner } 1544fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel ~HandleSDNode(); 1545e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman const SDValue &getValue() const { return Op; } 1546d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner}; 1547d623e953fc5f46b013994dfa4651cff4d17af159Chris Lattner 154828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang/// Abstact virtual class for operations for memory operations 154928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass MemSDNode : public SDNode { 155028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangprivate: 15511ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman // MemoryVT - VT of in-memory value. 15521ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MVT MemoryVT; 15531ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman 155428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang //! SrcValue - Memory location for alias analysis. 155528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang const Value *SrcValue; 155628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1557492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman //! SVOffset - Memory location offset. Note that base is defined in MemSDNode 1558492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman int SVOffset; 1559492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman 156028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangpublic: 15613edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen MemSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, MVT MemoryVT, 15623edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen const Value *srcValue, int SVOff, 15633edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen unsigned alignment, bool isvolatile); 15643edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen 1565d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman MemSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, const SDValue *Ops, 15663edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen unsigned NumOps, MVT MemoryVT, const Value *srcValue, int SVOff, 15673edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen unsigned alignment, bool isvolatile); 15683edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen 156928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// Returns alignment and volatility of the memory access 1570a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman unsigned getAlignment() const { return (1u << (SubclassData >> 6)) >> 1; } 1571a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman bool isVolatile() const { return (SubclassData >> 5) & 1; } 1572d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman 1573a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman /// getRawSubclassData - Return the SubclassData value, which contains an 1574a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman /// encoding of the alignment and volatile information, as well as bits 1575a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman /// used by subclasses. This function should only be used to compute a 1576a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman /// FoldingSetNodeID value. 1577a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman unsigned getRawSubclassData() const { 1578a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman return SubclassData; 1579a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman } 1580a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman 158128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// Returns the SrcValue and offset that describes the location of the access 158228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang const Value *getSrcValue() const { return SrcValue; } 1583492f276cbc7be564c6af7b302618ee5436e4619cDan Gohman int getSrcValueOffset() const { return SVOffset; } 1584d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman 15851ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman /// getMemoryVT - Return the type of the in-memory value. 15861ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MVT getMemoryVT() const { return MemoryVT; } 1587d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman 158828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// getMemOperand - Return a MachineMemOperand object describing the memory 158928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang /// reference performed by operation. 15901ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman MachineMemOperand getMemOperand() const; 15911ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman 1592475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getChain() const { return getOperand(0); } 1593475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { 15941ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman return getOperand(getOpcode() == ISD::STORE ? 2 : 1); 15951ea58a52a4296afff10e9db1e54928f38e6d74c6Dan Gohman } 159628873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 159728873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Methods to support isa and dyn_cast 159828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const MemSDNode *) { return true; } 159928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const SDNode *N) { 1600c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // For some targets, we lower some target intrinsics to a MemIntrinsicNode 1601c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // with either an intrinsic or a target opcode. 1602e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen return N->getOpcode() == ISD::LOAD || 1603e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen N->getOpcode() == ISD::STORE || 16040b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_CMP_SWAP || 16050b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_SWAP || 16060b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_ADD || 16070b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_SUB || 16080b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_AND || 16090b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_OR || 16100b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_XOR || 16110b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_NAND || 16120b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_MIN || 16130b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_MAX || 16140b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || 16150b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_UMAX || 1616c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_W_CHAIN || 1617c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_VOID || 1618c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->isTargetOpcode(); 1619d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman } 162028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang}; 162128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1622c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// AtomicSDNode - A SDNode reprenting atomic operations. 1623c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// 162428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass AtomicSDNode : public MemSDNode { 16259cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[4]; 1626d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman 1627c53361294957b63a9c1e405256c6f0a81db1685cDan Gohmanpublic: 162828873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Opc: opcode for atomic 162928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // VTL: value type list 163028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Chain: memory chain for operaand 1631475871a144eb604ddaf37503397ba0941442e5fbDan Gohman // Ptr: address to update as a SDValue 163228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Cmp: compare value 163328873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Swp: swap value 163428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // SrcVal: address to update as a Value (used for MemOperand) 163528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Align: alignment of memory 16363edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen AtomicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTL, MVT MemVT, 16373edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen SDValue Chain, SDValue Ptr, 16383edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen SDValue Cmp, SDValue Swp, const Value* SrcVal, 16393edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen unsigned Align=0) 16403edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : MemSDNode(Opc, dl, VTL, MemVT, SrcVal, /*SVOffset=*/0, 16413edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen Align, /*isVolatile=*/true) { 16423edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen InitOperands(Ops, Chain, Ptr, Cmp, Swp); 16433edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 16443edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen AtomicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTL, MVT MemVT, 1645d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman SDValue Chain, SDValue Ptr, 16463edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen SDValue Val, const Value* SrcVal, unsigned Align=0) 16473edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : MemSDNode(Opc, dl, VTL, MemVT, SrcVal, /*SVOffset=*/0, 16483edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen Align, /*isVolatile=*/true) { 16493edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen InitOperands(Ops, Chain, Ptr, Val); 16503edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 1651d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman 1652475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(1); } 1653475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getVal() const { return getOperand(2); } 165428873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 1655d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman bool isCompareAndSwap() const { 1656d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman unsigned Op = getOpcode(); 16570b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman return Op == ISD::ATOMIC_CMP_SWAP; 1658e00a8a2a2e11a37fd1ddf2504bd22d225d0994d0Dale Johannesen } 165928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang 166028873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang // Methods to support isa and dyn_cast 166128873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const AtomicSDNode *) { return true; } 166228873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang static bool classof(const SDNode *N) { 16630b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman return N->getOpcode() == ISD::ATOMIC_CMP_SWAP || 16640b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_SWAP || 16650b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_ADD || 16660b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_SUB || 16670b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_AND || 16680b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_OR || 16690b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_XOR || 16700b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_NAND || 16710b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_MIN || 16720b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_MAX || 16730b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || 16740b1d4a798d1dd2f39521b6b381cd1c1911c9ab52Dan Gohman N->getOpcode() == ISD::ATOMIC_LOAD_UMAX; 167528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang } 1676ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth}; 1677ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 1678c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// MemIntrinsicSDNode - This SDNode is used for target intrinsic that touches 1679c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// memory and need an associated memory operand. 1680c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang/// 1681c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wangclass MemIntrinsicSDNode : public MemSDNode { 1682c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool ReadMem; // Intrinsic reads memory 1683c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool WriteMem; // Intrinsic writes memory 16843dbc4e350216e197e3014452400f43899f7ad620Dan Gohmanpublic: 16853edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen MemIntrinsicSDNode(unsigned Opc, DebugLoc dl, SDVTList VTs, 16863edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen const SDValue *Ops, unsigned NumOps, 16873edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen MVT MemoryVT, const Value *srcValue, int SVO, 16883edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen unsigned Align, bool Vol, bool ReadMem, bool WriteMem) 16893edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : MemSDNode(Opc, dl, VTs, Ops, NumOps, MemoryVT, srcValue, SVO, Align, Vol), 16903edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen ReadMem(ReadMem), WriteMem(WriteMem) { 16913edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 1692c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 1693c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool readMem() const { return ReadMem; } 1694c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool writeMem() const { return WriteMem; } 1695c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 1696c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // Methods to support isa and dyn_cast 1697c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang static bool classof(const MemIntrinsicSDNode *) { return true; } 1698c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang static bool classof(const SDNode *N) { 1699c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // We lower some target intrinsics to their target opcode 1700c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang // early a node with a target opcode can be of this class 1701c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang return N->getOpcode() == ISD::INTRINSIC_W_CHAIN || 1702c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->getOpcode() == ISD::INTRINSIC_VOID || 1703c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang N->isTargetOpcode(); 1704c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang } 1705c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang}; 1706c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 17075a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman/// ShuffleVectorSDNode - This SDNode is used to implement the code generator 17085a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman/// support for the llvm IR shufflevector instruction. It combines elements 17095a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman/// from two input vectors into a new input vector, with the selection and 17105a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman/// ordering of elements determined by an array of integers, referred to as 17115a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman/// the shuffle mask. For input vectors of width N, mask indices of 0..N-1 17125a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman/// refer to elements from the LHS input, and indices from N to 2N-1 the RHS. 17135a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman/// An index of -1 is treated as undef, such that the code generator may put 17145a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman/// any value in the corresponding element of the result. 17159008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begemanclass ShuffleVectorSDNode : public SDNode { 17169008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman SDUse Ops[2]; 17175a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman 17185a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman // The memory for Mask is owned by the SelectionDAG's OperandAllocator, and 17195a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman // is freed when the SelectionDAG object is destroyed. 17205a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman const int *Mask; 17219008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begemanprotected: 17229008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman friend class SelectionDAG; 17235a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman ShuffleVectorSDNode(MVT VT, DebugLoc dl, SDValue N1, SDValue N2, 17245a5ca1519e04310f585197c20e7ae584b7f2d11fNate Begeman const int *M) 17259008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman : SDNode(ISD::VECTOR_SHUFFLE, dl, getSDVTList(VT)), Mask(M) { 17269008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman InitOperands(Ops, N1, N2); 17279008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman } 17289008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begemanpublic: 17299008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman 17309008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman void getMask(SmallVectorImpl<int> &M) const { 17319008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman MVT VT = getValueType(0); 17329008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman M.clear(); 17339008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) 17349008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman M.push_back(Mask[i]); 17359008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman } 17369008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman int getMaskElt(unsigned Idx) const { 17379008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!"); 17389008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman return Mask[Idx]; 17399008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman } 17409008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman 17419008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman bool isSplat() const { return isSplatMask(Mask, getValueType(0)); } 17429008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman int getSplatIndex() const { 17439008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman assert(isSplat() && "Cannot get splat index for non-splat!"); 17449008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman return Mask[0]; 17459008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman } 17469008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman static bool isSplatMask(const int *Mask, MVT VT); 17479008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman 17489008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman static bool classof(const ShuffleVectorSDNode *) { return true; } 17499008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman static bool classof(const SDNode *N) { 17509008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman return N->getOpcode() == ISD::VECTOR_SHUFFLE; 17519008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman } 17529008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman}; 17539008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman 175463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantSDNode : public SDNode { 17554fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantInt *Value; 175663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 17574fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman ConstantSDNode(bool isTarget, const ConstantInt *val, MVT VT) 1758fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 175992570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen DebugLoc::getUnknownLoc(), getSDVTList(VT)), Value(val) { 176063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 176163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 176263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17634fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantInt *getConstantIntValue() const { return Value; } 17644fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const APInt &getAPIntValue() const { return Value->getValue(); } 17654fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman uint64_t getZExtValue() const { return Value->getZExtValue(); } 17667810bfed5570c192e0714a8fd0e5130a0c38dd2eDan Gohman int64_t getSExtValue() const { return Value->getSExtValue(); } 176763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17684fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman bool isNullValue() const { return Value->isNullValue(); } 17694fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman bool isAllOnesValue() const { return Value->isAllOnesValue(); } 177063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 177163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantSDNode *) { return true; } 177263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1773056f9f61d071c6c583951678f2bf543a1316efccChris Lattner return N->getOpcode() == ISD::Constant || 1774056f9f61d071c6c583951678f2bf543a1316efccChris Lattner N->getOpcode() == ISD::TargetConstant; 177563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 177663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 177763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 177863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantFPSDNode : public SDNode { 17794fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantFP *Value; 178063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 17814fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman ConstantFPSDNode(bool isTarget, const ConstantFP *val, MVT VT) 178287503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 178392570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen DebugLoc::getUnknownLoc(), getSDVTList(VT)), Value(val) { 178463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 178563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 178663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 17874fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const APFloat& getValueAPF() const { return Value->getValueAPF(); } 17884fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman const ConstantFP *getConstantFPValue() const { return Value; } 178963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 179063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// isExactlyValue - We don't rely on operator== working on double values, as 179163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 179263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// As such, this method can be used to do an exact bit-for-bit comparison of 179363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner /// two floating point values. 1794c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen 1795c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// We leave the version with the double argument here because it's just so 1796fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel /// convenient to write "2.0" and the like. Without this function we'd 1797c4dd3c3b519aa2c2ed26ce03a4b1fbb992efeacaDale Johannesen /// have to duplicate its logic everywhere it's called. 17989dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen bool isExactlyValue(double V) const { 179923a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen bool ignored; 18009dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen // convert is not supported on this type 18014fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman if (&Value->getValueAPF().getSemantics() == &APFloat::PPCDoubleDouble) 18029dd2ce46c58dd05f0835df77f308396715890d66Dale Johannesen return false; 180384cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner APFloat Tmp(V); 18044fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman Tmp.convert(Value->getValueAPF().getSemantics(), 180523a98551ab65eeb8fe5019df8b7db4891582a4bdDale Johannesen APFloat::rmNearestTiesToEven, &ignored); 180684cd0e7fa30af43c47ad9533d84debb144596e48Chris Lattner return isExactlyValue(Tmp); 180787503a63d5756f1836f66f4c9723ec0ea30ec3caDale Johannesen } 1808e6c1742914149d44360fbf05a653041a672282afDale Johannesen bool isExactlyValue(const APFloat& V) const; 180963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 181083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands bool isValueValidForType(MVT VT, const APFloat& Val); 1811f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen 181263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantFPSDNode *) { return true; } 181363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1814fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel return N->getOpcode() == ISD::ConstantFP || 1815ac0d7238258defe72b1aad53d7f48201b91df795Chris Lattner N->getOpcode() == ISD::TargetConstantFP; 181663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 181763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 181863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 181963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass GlobalAddressSDNode : public SDNode { 182063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *TheGlobal; 18216520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t Offset; 18222a4ed82ce2ba4a02f2a02eb4ed8ce5186f3f93daChris Lattner unsigned char TargetFlags; 182363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 18246520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman GlobalAddressSDNode(bool isTarget, const GlobalValue *GA, MVT VT, 18252a4ed82ce2ba4a02f2a02eb4ed8ce5186f3f93daChris Lattner int64_t o, unsigned char TargetFlags); 182663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 182763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 182863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner GlobalValue *getGlobal() const { return TheGlobal; } 18296520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t getOffset() const { return Offset; } 18302a4ed82ce2ba4a02f2a02eb4ed8ce5186f3f93daChris Lattner unsigned char getTargetFlags() const { return TargetFlags; } 1831a3518a1d6a6a9a7519d3a8d434cde51617c1dc22Sanjiv Gupta // Return the address space this GlobalAddress belongs to. 1832a3518a1d6a6a9a7519d3a8d434cde51617c1dc22Sanjiv Gupta unsigned getAddressSpace() const; 183363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 183463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const GlobalAddressSDNode *) { return true; } 183563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1836f6b184981e429ff03742d66cf7111debd9e2bc61Chris Lattner return N->getOpcode() == ISD::GlobalAddress || 1837b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalAddress || 1838b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::GlobalTLSAddress || 1839b3a0417cad8b625acc3033bd5e24afb9ffd0b084Lauro Ramos Venancio N->getOpcode() == ISD::TargetGlobalTLSAddress; 184063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 184163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 184263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 184363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass FrameIndexSDNode : public SDNode { 184463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int FI; 184563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 184683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands FrameIndexSDNode(int fi, MVT VT, bool isTarg) 1847fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, 184892570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen DebugLoc::getUnknownLoc(), getSDVTList(VT)), FI(fi) { 184963e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 185063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 185163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 185263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner int getIndex() const { return FI; } 185363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 185463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const FrameIndexSDNode *) { return true; } 185563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1856afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner return N->getOpcode() == ISD::FrameIndex || 1857afb2dd43de61f4585e75d1f3ab93a9ac4b3b7592Chris Lattner N->getOpcode() == ISD::TargetFrameIndex; 185863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 185963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 186063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 186137efe6764568a3829fee26aba532283131d1a104Nate Begemanclass JumpTableSDNode : public SDNode { 186237efe6764568a3829fee26aba532283131d1a104Nate Begeman int JTI; 1863f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner unsigned char TargetFlags; 186437efe6764568a3829fee26aba532283131d1a104Nate Begeman friend class SelectionDAG; 1865f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner JumpTableSDNode(int jti, MVT VT, bool isTarg, unsigned char TF) 186692570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, 1867f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner DebugLoc::getUnknownLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) { 186863e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 186937efe6764568a3829fee26aba532283131d1a104Nate Begemanpublic: 1870fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 187159a8cdd36d644fd5d0d7c78c3c02b31f1ba29a95Chris Lattner int getIndex() const { return JTI; } 1872f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner unsigned char getTargetFlags() const { return TargetFlags; } 1873fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 187437efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const JumpTableSDNode *) { return true; } 187537efe6764568a3829fee26aba532283131d1a104Nate Begeman static bool classof(const SDNode *N) { 187637efe6764568a3829fee26aba532283131d1a104Nate Begeman return N->getOpcode() == ISD::JumpTable || 187737efe6764568a3829fee26aba532283131d1a104Nate Begeman N->getOpcode() == ISD::TargetJumpTable; 187837efe6764568a3829fee26aba532283131d1a104Nate Begeman } 187937efe6764568a3829fee26aba532283131d1a104Nate Begeman}; 188037efe6764568a3829fee26aba532283131d1a104Nate Begeman 188163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass ConstantPoolSDNode : public SDNode { 1882d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng union { 1883d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *ConstVal; 1884d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *MachineCPVal; 1885d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } Val; 1886baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int Offset; // It's a MachineConstantPoolValue if top bit is set. 18871606e8e4cd937e6de6681f686c266cf61722d972Evan Cheng unsigned Alignment; // Minimum alignment requirement of CP (not log2 value). 1888f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner unsigned char TargetFlags; 188963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 1890f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner ConstantPoolSDNode(bool isTarget, Constant *c, MVT VT, int o, unsigned Align, 1891f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner unsigned char TF) 1892ab4ed595385d0b9421c0d45c809ec6324cf11f11Chris Lattner : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 189392570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen DebugLoc::getUnknownLoc(), 1894f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align), TargetFlags(TF) { 1895d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1896d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.ConstVal = c; 1897d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1898d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, 1899f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner MVT VT, int o, unsigned Align, unsigned char TF) 1900fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 190192570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen DebugLoc::getUnknownLoc(), 1902f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner getSDVTList(VT)), Offset(o), Alignment(Align), TargetFlags(TF) { 1903d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert((int)Offset >= 0 && "Offset is too large"); 1904d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Val.MachineCPVal = v; 1905de551f91d8816632a76a065084caab9fab6aacffDan Gohman Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1); 1906d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 190763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 1908f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner 190963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1910d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng bool isMachineConstantPoolEntry() const { 1911d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return (int)Offset < 0; 1912d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1913d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1914d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng Constant *getConstVal() const { 1915d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); 1916d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.ConstVal; 1917d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1918d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1919d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng MachineConstantPoolValue *getMachineCPVal() const { 1920d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); 1921d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return Val.MachineCPVal; 1922d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 1923d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 1924baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng int getOffset() const { 1925de551f91d8816632a76a065084caab9fab6aacffDan Gohman return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1)); 1926baf4500b3ab128c78932e36f96086c0487c8c7d1Evan Cheng } 1927fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 1928ef3640aded552279f65bd6d18633e15ffb245157Chris Lattner // Return the alignment of this constant pool object, which is either 0 (for 19291606e8e4cd937e6de6681f686c266cf61722d972Evan Cheng // default alignment) or the desired value. 1930b8973bd8f50d7321635e1e07b81a880a0828d185Evan Cheng unsigned getAlignment() const { return Alignment; } 1931f5a5546f435a261c93078defb41ed18d9cafd7d3Chris Lattner unsigned char getTargetFlags() const { return TargetFlags; } 193263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1933d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng const Type *getType() const; 1934d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng 193563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const ConstantPoolSDNode *) { return true; } 193663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 1937aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner return N->getOpcode() == ISD::ConstantPool || 1938aaaaf79d4aaa172c2f2ae0e327bbae523a045bf5Chris Lattner N->getOpcode() == ISD::TargetConstantPool; 193963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 194063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 194163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 194263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerclass BasicBlockSDNode : public SDNode { 194363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *MBB; 194463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 194592570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen /// Debug info is meaningful and potentially useful here, but we create 194692570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen /// blocks out of order when they're jumped to, which makes it a bit 194792570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen /// harder. Let's see if we need it first. 1948423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit BasicBlockSDNode(MachineBasicBlock *mbb) 194992570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::BasicBlock, DebugLoc::getUnknownLoc(), 195092570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(MVT::Other)), MBB(mbb) { 19513edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 195263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 195363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 195463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner MachineBasicBlock *getBasicBlock() const { return MBB; } 195563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 195663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const BasicBlockSDNode *) { return true; } 195763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 195863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner return N->getOpcode() == ISD::BasicBlock; 195963b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 196063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 196163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 1962a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson/// BuildVectorSDNode - A "pseudo-class" with methods for operating on 1963a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson/// BUILD_VECTORs. 1964a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilsonclass BuildVectorSDNode : public SDNode { 19651a6d31aee6acd2b9b715b4f11f09481608f13179Bob Wilson // These are constructed as SDNodes and then cast to BuildVectorSDNodes. 19661a6d31aee6acd2b9b715b4f11f09481608f13179Bob Wilson explicit BuildVectorSDNode(); // Do not implement 1967a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilsonpublic: 196824e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// isConstantSplat - Check if this is a constant splat, and if so, find the 196924e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// smallest element size that splats the vector. If MinSplatBits is 197024e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// nonzero, the element size must be at least that large. Note that the 197124e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// splat element may be the entire vector (i.e., a one element vector). 197224e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// Returns the splat element value in SplatValue. Any undefined bits in 197324e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// that value are zero, and the corresponding bits in the SplatUndef mask 197424e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// are set. The SplatBitSize value is set to the splat element size in 197524e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// bits. HasAnyUndefs is set to true if any bits in the vector are 197624e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson /// undefined. 197724e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, 197824e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson unsigned &SplatBitSize, bool &HasAnyUndefs, 197924e338e8a3dab2923db30fe63d77a5ac95456ff9Bob Wilson unsigned MinSplatBits = 0); 1980a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson 1981a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson static inline bool classof(const BuildVectorSDNode *) { return true; } 1982a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson static inline bool classof(const SDNode *N) { 1983a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson return N->getOpcode() == ISD::BUILD_VECTOR; 1984a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson } 1985a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson}; 1986a27ea9e89f38e9bcca4d67defb0bae887a16d72cBob Wilson 198714471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// SrcValueSDNode - An SDNode that holds an arbitrary LLVM IR Value. This is 198814471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// used when the SelectionDAG needs to make a simple reference to something 198914471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// in the LLVM IR representation. 199014471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 199114471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// Note that this is not used for carrying alias information; that is done 199214471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// with MemOperandSDNode, which includes a Value which is required to be a 199314471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// pointer, and several other fields specific to memory references. 199414471be9ab531cb677658704ea73b06d4f0b7585Dan Gohman/// 19952d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthclass SrcValueSDNode : public SDNode { 19962d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *V; 19972d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth friend class SelectionDAG; 199869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// Create a SrcValue for a general value. 199969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman explicit SrcValueSDNode(const Value *v) 200092570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::SRCVALUE, DebugLoc::getUnknownLoc(), 200192570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(MVT::Other)), V(v) {} 20022d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 20032d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharthpublic: 200469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman /// getValue - return the contained Value. 20052d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth const Value *getValue() const { return V; } 20062d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 20072d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SrcValueSDNode *) { return true; } 20082d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth static bool classof(const SDNode *N) { 20092d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth return N->getOpcode() == ISD::SRCVALUE; 20102d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth } 20112d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth}; 20122d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 201363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 201436b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman/// MemOperandSDNode - An SDNode that holds a MachineMemOperand. This is 201569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// used to represent a reference to memory after ISD::LOAD 201669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// and ISD::STORE have been lowered. 201769de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman/// 201869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanclass MemOperandSDNode : public SDNode { 201969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman friend class SelectionDAG; 202036b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// Create a MachineMemOperand node 202136b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman explicit MemOperandSDNode(const MachineMemOperand &mo) 202292570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::MEMOPERAND, DebugLoc::getUnknownLoc(), 202392570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(MVT::Other)), MO(mo) {} 202469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 202569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohmanpublic: 202636b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman /// MO - The contained MachineMemOperand. 202736b5c1338a03453ba1c110b120269ca972fb65a3Dan Gohman const MachineMemOperand MO; 202869de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 202969de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const MemOperandSDNode *) { return true; } 203069de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman static bool classof(const SDNode *N) { 203169de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman return N->getOpcode() == ISD::MEMOPERAND; 203269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman } 203369de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman}; 203469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 203569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 2036d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattnerclass RegisterSDNode : public SDNode { 203763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned Reg; 203863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 203983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands RegisterSDNode(unsigned reg, MVT VT) 204092570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::Register, DebugLoc::getUnknownLoc(), 204192570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(VT)), Reg(reg) { 204263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 204363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 204463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 204563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner unsigned getReg() const { return Reg; } 204663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 2047d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner static bool classof(const RegisterSDNode *) { return true; } 204863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 2049d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner return N->getOpcode() == ISD::Register; 205063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 205163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 205263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 20537f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanclass DbgStopPointSDNode : public SDNode { 20547f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman SDUse Chain; 20557f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned Line; 20567f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned Column; 205783489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel Value *CU; 20587f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman friend class SelectionDAG; 2059475871a144eb604ddaf37503397ba0941442e5fbDan Gohman DbgStopPointSDNode(SDValue ch, unsigned l, unsigned c, 206083489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel Value *cu) 206192570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::DBG_STOPPOINT, DebugLoc::getUnknownLoc(), 206292570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(MVT::Other)), Line(l), Column(c), CU(cu) { 2063e7852d014432a06c783de3c350eb96e686f10f92Dan Gohman InitOperands(&Chain, ch); 20647f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman } 20657f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohmanpublic: 20667f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned getLine() const { return Line; } 20677f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman unsigned getColumn() const { return Column; } 206883489bb7700c69b7a4a8da59365c42d3f5c8129bDevang Patel Value *getCompileUnit() const { return CU; } 20697f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman 20707f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman static bool classof(const DbgStopPointSDNode *) { return true; } 20717f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman static bool classof(const SDNode *N) { 20727f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman return N->getOpcode() == ISD::DBG_STOPPOINT; 20737f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman } 20747f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman}; 20757f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman 20764406604047423576e36657c7ede266ca42e79642Dan Gohmanclass LabelSDNode : public SDNode { 20774406604047423576e36657c7ede266ca42e79642Dan Gohman SDUse Chain; 20784406604047423576e36657c7ede266ca42e79642Dan Gohman unsigned LabelID; 20794406604047423576e36657c7ede266ca42e79642Dan Gohman friend class SelectionDAG; 2080472da1424042682ffaf6d9a253b0ff47acc1a572Dale JohannesenLabelSDNode(unsigned NodeTy, DebugLoc dl, SDValue ch, unsigned id) 20813edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : SDNode(NodeTy, dl, getSDVTList(MVT::Other)), LabelID(id) { 20823edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen InitOperands(&Chain, ch); 20833edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 20844406604047423576e36657c7ede266ca42e79642Dan Gohmanpublic: 20854406604047423576e36657c7ede266ca42e79642Dan Gohman unsigned getLabelID() const { return LabelID; } 20864406604047423576e36657c7ede266ca42e79642Dan Gohman 20874406604047423576e36657c7ede266ca42e79642Dan Gohman static bool classof(const LabelSDNode *) { return true; } 20884406604047423576e36657c7ede266ca42e79642Dan Gohman static bool classof(const SDNode *N) { 20894406604047423576e36657c7ede266ca42e79642Dan Gohman return N->getOpcode() == ISD::DBG_LABEL || 20904406604047423576e36657c7ede266ca42e79642Dan Gohman N->getOpcode() == ISD::EH_LABEL; 20914406604047423576e36657c7ede266ca42e79642Dan Gohman } 20924406604047423576e36657c7ede266ca42e79642Dan Gohman}; 20934406604047423576e36657c7ede266ca42e79642Dan Gohman 2094056292fd738924f3f7703725d8f630983794b5a5Bill Wendlingclass ExternalSymbolSDNode : public SDNode { 209563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *Symbol; 20961af2231da64a14d638406d133c7912bfc1c8a9ceChris Lattner unsigned char TargetFlags; 20971af2231da64a14d638406d133c7912bfc1c8a9ceChris Lattner 209863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 20991af2231da64a14d638406d133c7912bfc1c8a9ceChris Lattner ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, MVT VT) 2100056292fd738924f3f7703725d8f630983794b5a5Bill Wendling : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 210192570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen DebugLoc::getUnknownLoc(), 21021af2231da64a14d638406d133c7912bfc1c8a9ceChris Lattner getSDVTList(VT)), Symbol(Sym), TargetFlags(TF) { 21033edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 210463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 2105056292fd738924f3f7703725d8f630983794b5a5Bill Wendling 210663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner const char *getSymbol() const { return Symbol; } 21071af2231da64a14d638406d133c7912bfc1c8a9ceChris Lattner unsigned char getTargetFlags() const { return TargetFlags; } 210863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 2109056292fd738924f3f7703725d8f630983794b5a5Bill Wendling static bool classof(const ExternalSymbolSDNode *) { return true; } 211063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 2111056292fd738924f3f7703725d8f630983794b5a5Bill Wendling return N->getOpcode() == ISD::ExternalSymbol || 2112056292fd738924f3f7703725d8f630983794b5a5Bill Wendling N->getOpcode() == ISD::TargetExternalSymbol; 211363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 211463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 211563b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 21167cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattnerclass CondCodeSDNode : public SDNode { 211763b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner ISD::CondCode Condition; 211863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner friend class SelectionDAG; 2119423c2260f95883f7c84ac962e58ac66c3a11efacDan Gohman explicit CondCodeSDNode(ISD::CondCode Cond) 212092570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::CONDCODE, DebugLoc::getUnknownLoc(), 212192570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(MVT::Other)), Condition(Cond) { 212263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 212363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattnerpublic: 212463b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 21257cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner ISD::CondCode get() const { return Condition; } 212663b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 21277cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner static bool classof(const CondCodeSDNode *) { return true; } 212863b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner static bool classof(const SDNode *N) { 21297cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner return N->getOpcode() == ISD::CONDCODE; 213063b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner } 213163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner}; 21329008ca6b6b4f638cfafccb593cbc5b1d3f5ab877Nate Begeman 213377cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the 213477cdf30742284a173fe818417eb482224cdee8d4Mon P Wang/// future and most targets don't support it. 213577cdf30742284a173fe818417eb482224cdee8d4Mon P Wangclass CvtRndSatSDNode : public SDNode { 213677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang ISD::CvtCode CvtCode; 213777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang friend class SelectionDAG; 2138a04b75710910278334192b389c4c4c62600e162fDale Johannesen explicit CvtRndSatSDNode(MVT VT, DebugLoc dl, const SDValue *Ops, 2139a04b75710910278334192b389c4c4c62600e162fDale Johannesen unsigned NumOps, ISD::CvtCode Code) 2140fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel : SDNode(ISD::CONVERT_RNDSAT, dl, getSDVTList(VT), Ops, NumOps), 2141a04b75710910278334192b389c4c4c62600e162fDale Johannesen CvtCode(Code) { 2142a04b75710910278334192b389c4c4c62600e162fDale Johannesen assert(NumOps == 5 && "wrong number of operations"); 2143a04b75710910278334192b389c4c4c62600e162fDale Johannesen } 214477cdf30742284a173fe818417eb482224cdee8d4Mon P Wangpublic: 214577cdf30742284a173fe818417eb482224cdee8d4Mon P Wang ISD::CvtCode getCvtCode() const { return CvtCode; } 214677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 214777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang static bool classof(const CvtRndSatSDNode *) { return true; } 214877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang static bool classof(const SDNode *N) { 214977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang return N->getOpcode() == ISD::CONVERT_RNDSAT; 215077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang } 215177cdf30742284a173fe818417eb482224cdee8d4Mon P Wang}; 215277cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 2153276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsnamespace ISD { 2154276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands struct ArgFlagsTy { 2155276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands private: 2156276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t NoFlagSet = 0ULL; 2157276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ZExt = 1ULL<<0; ///< Zero extended 2158276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ZExtOffs = 0; 2159276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SExt = 1ULL<<1; ///< Sign extended 2160276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SExtOffs = 1; 2161276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t InReg = 1ULL<<2; ///< Passed in register 2162276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t InRegOffs = 2; 2163276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SRet = 1ULL<<3; ///< Hidden struct-ret ptr 2164276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t SRetOffs = 3; 2165276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByVal = 1ULL<<4; ///< Struct passed by value 2166276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValOffs = 4; 2167276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t Nest = 1ULL<<5; ///< Nested fn static chain 2168276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t NestOffs = 5; 2169276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValAlign = 0xFULL << 6; //< Struct alignment 2170276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValAlignOffs = 6; 21716ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray static const uint64_t Split = 1ULL << 10; 21726ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray static const uint64_t SplitOffs = 10; 2173276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t OrigAlign = 0x1FULL<<27; 2174276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t OrigAlignOffs = 27; 2175276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValSize = 0xffffffffULL << 32; //< Struct size 2176276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t ByValSizeOffs = 32; 2177276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2178276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static const uint64_t One = 1ULL; //< 1 of this type, for shifts 2179276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2180276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands uint64_t Flags; 2181276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands public: 2182276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ArgFlagsTy() : Flags(0) { } 2183276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2184276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isZExt() const { return Flags & ZExt; } 2185276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setZExt() { Flags |= One << ZExtOffs; } 2186276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2187276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isSExt() const { return Flags & SExt; } 2188276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setSExt() { Flags |= One << SExtOffs; } 2189276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2190276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isInReg() const { return Flags & InReg; } 2191276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setInReg() { Flags |= One << InRegOffs; } 2192276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2193276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isSRet() const { return Flags & SRet; } 2194276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setSRet() { Flags |= One << SRetOffs; } 2195276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2196276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isByVal() const { return Flags & ByVal; } 2197276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByVal() { Flags |= One << ByValOffs; } 2198276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2199276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands bool isNest() const { return Flags & Nest; } 2200276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setNest() { Flags |= One << NestOffs; } 2201276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2202276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getByValAlign() const { 2203fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel return (unsigned) 220494bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2); 2205276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2206276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByValAlign(unsigned A) { 2207276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~ByValAlign) | 2208276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands (uint64_t(Log2_32(A) + 1) << ByValAlignOffs); 2209276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2210fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel 22116ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray bool isSplit() const { return Flags & Split; } 22126ccbbd89906157187ac04b2b3237c4aee7acd095Nicolas Geoffray void setSplit() { Flags |= One << SplitOffs; } 2213276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2214276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getOrigAlign() const { 221594bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned) 221694bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2); 2217276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2218276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setOrigAlign(unsigned A) { 2219276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~OrigAlign) | 2220276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands (uint64_t(Log2_32(A) + 1) << OrigAlignOffs); 2221276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2222276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2223276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands unsigned getByValSize() const { 222494bef327aa8ea769cafe310b91bd94d768d2bf85Dale Johannesen return (unsigned)((Flags & ByValSize) >> ByValSizeOffs); 2225276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2226276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands void setByValSize(unsigned S) { 2227276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs); 2228276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2229276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2230276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4". 2231276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands std::string getArgFlagsString(); 2232276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2233276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands /// getRawBits - Represent the flags as a bunch of bits. 2234276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands uint64_t getRawBits() const { return Flags; } 2235276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands }; 2236276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands} 2237276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2238276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands/// ARG_FLAGSSDNode - Leaf node holding parameter flags. 2239276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandsclass ARG_FLAGSSDNode : public SDNode { 2240276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ISD::ArgFlagsTy TheFlags; 2241276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands friend class SelectionDAG; 2242276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands explicit ARG_FLAGSSDNode(ISD::ArgFlagsTy Flags) 224392570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::ARG_FLAGS, DebugLoc::getUnknownLoc(), 224492570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(MVT::Other)), TheFlags(Flags) { 2245276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2246276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sandspublic: 2247276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands ISD::ArgFlagsTy getArgFlags() const { return TheFlags; } 2248276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2249276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static bool classof(const ARG_FLAGSSDNode *) { return true; } 2250276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands static bool classof(const SDNode *N) { 2251276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands return N->getOpcode() == ISD::ARG_FLAGS; 2252276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands } 2253276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands}; 2254276dcbdc8db6614cfd5004dc7dc35e437ddf9c58Duncan Sands 2255095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman/// CallSDNode - Node for calls -- ISD::CALL. 2256095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanclass CallSDNode : public SDNode { 2257095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned CallingConv; 2258095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman bool IsVarArg; 2259095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman bool IsTailCall; 226086098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // We might eventually want a full-blown Attributes for the result; that 226186098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // will expand the size of the representation. At the moment we only 226286098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen // need Inreg. 226386098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen bool Inreg; 2264095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman friend class SelectionDAG; 2265fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel CallSDNode(unsigned cc, DebugLoc dl, bool isvararg, bool istailcall, 2266fdc40a0a696c658d550d894ea03772e5f8af2c94Scott Michel bool isinreg, SDVTList VTs, const SDValue *Operands, 22673edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen unsigned numOperands) 22683edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : SDNode(ISD::CALL, dl, VTs, Operands, numOperands), 22693edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen CallingConv(cc), IsVarArg(isvararg), IsTailCall(istailcall), 22703edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen Inreg(isinreg) {} 2271095cc29f321382e1f7d295e262a28197f92c5491Dan Gohmanpublic: 2272095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getCallingConv() const { return CallingConv; } 2273095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned isVarArg() const { return IsVarArg; } 2274095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned isTailCall() const { return IsTailCall; } 227586098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen unsigned isInreg() const { return Inreg; } 2276095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2277095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// Set this call to not be marked as a tail call. Normally setter 2278095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// methods in SDNodes are unsafe because it breaks the CSE map, 22795eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman /// but we don't include the tail call flag for calls so it's ok 22805eb0cecbc5dd370e33d4e0ab1abee7ce8597ca9cDan Gohman /// in this case. 2281095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman void setNotTailCall() { IsTailCall = false; } 2282095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2283095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getChain() const { return getOperand(0); } 2284095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getCallee() const { return getOperand(1); } 2285095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2286095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getNumArgs() const { return (getNumOperands() - 2) / 2; } 2287095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getArg(unsigned i) const { return getOperand(2+2*i); } 2288095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getArgFlagsVal(unsigned i) const { 2289095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return getOperand(3+2*i); 2290095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2291095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman ISD::ArgFlagsTy getArgFlags(unsigned i) const { 2292095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return cast<ARG_FLAGSSDNode>(getArgFlagsVal(i).getNode())->getArgFlags(); 2293095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2294095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2295095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman unsigned getNumRetVals() const { return getNumValues() - 1; } 2296095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman MVT getRetValType(unsigned i) const { return getValueType(i); } 2297095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 2298095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman static bool classof(const CallSDNode *) { return true; } 2299095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman static bool classof(const SDNode *N) { 2300095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman return N->getOpcode() == ISD::CALL; 2301095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman } 2302095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman}; 2303095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 230483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands/// VTSDNode - This class is used to represent MVT's, which are used 230515e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner/// to parameterize some operations. 230615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerclass VTSDNode : public SDNode { 230783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT ValueType; 230815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner friend class SelectionDAG; 230983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands explicit VTSDNode(MVT VT) 231092570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen : SDNode(ISD::VALUETYPE, DebugLoc::getUnknownLoc(), 231192570c4a1a11cbdaf5ffb13547428dbee1103875Dale Johannesen getSDVTList(MVT::Other)), ValueType(VT) { 231263e3f14df6cf76f1a12de1153e1114f4b20b15a9Chris Lattner } 231315e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattnerpublic: 231415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 231583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT getVT() const { return ValueType; } 231615e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 231715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const VTSDNode *) { return true; } 231815e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner static bool classof(const SDNode *N) { 231915e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner return N->getOpcode() == ISD::VALUETYPE; 232015e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner } 232115e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner}; 232215e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 23239de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// LSBaseSDNode - Base class for LoadSDNode and StoreSDNode 23249de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel/// 232528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wangclass LSBaseSDNode : public MemSDNode { 23269de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel //! Operand array for load and store 23279de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel /*! 23289de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel \note Moving this array to the base class captures more 23299de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel common functionality shared between LoadSDNode and 23309de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel StoreSDNode 23319de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel */ 23329cac5259fe237120a0c347d6d14e549005148f1bRoman Levenstein SDUse Ops[4]; 23339de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelpublic: 2334d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman LSBaseSDNode(ISD::NodeType NodeTy, DebugLoc dl, SDValue *Operands, 2335d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman unsigned numOperands, SDVTList VTs, ISD::MemIndexedMode AM, 23363edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen MVT VT, const Value *SV, int SVO, unsigned Align, bool Vol) 23373edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : MemSDNode(NodeTy, dl, VTs, VT, SV, SVO, Align, Vol) { 23383edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen assert(Align != 0 && "Loads and stores should have non-zero aligment"); 2339a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman SubclassData |= AM << 2; 2340a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman assert(getAddressingMode() == AM && "MemIndexedMode encoding error!"); 2341a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman InitOperands(Ops, Operands, numOperands); 23423edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen assert((getOffset().getOpcode() == ISD::UNDEF || isIndexed()) && 23433edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen "Only indexed loads and stores have a non-undef offset operand"); 23443edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 23459de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 2346475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { 234763602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); 234863602b8a69b2729f0789cd3c920aceef0ece64cbChris Lattner } 23499de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 2350ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// getAddressingMode - Return the addressing mode for this load or store: 2351ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// unindexed, pre-inc, pre-dec, post-inc, or post-dec. 2352ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman ISD::MemIndexedMode getAddressingMode() const { 2353a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman return ISD::MemIndexedMode((SubclassData >> 2) & 7); 2354ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 2355b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 2356b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isIndexed - Return true if this is a pre/post inc/dec load/store. 2357ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; } 2358b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 2359b625f2f8960de32bc973092aaee8ac62863006feDan Gohman /// isUnindexed - Return true if this is NOT a pre/post inc/dec load/store. 2360ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; } 2361b625f2f8960de32bc973092aaee8ac62863006feDan Gohman 236213d57320bd212483463d4f8992d5787b29eda5dfBill Wendling static bool classof(const LSBaseSDNode *) { return true; } 2363b625f2f8960de32bc973092aaee8ac62863006feDan Gohman static bool classof(const SDNode *N) { 2364b625f2f8960de32bc973092aaee8ac62863006feDan Gohman return N->getOpcode() == ISD::LOAD || 2365b625f2f8960de32bc973092aaee8ac62863006feDan Gohman N->getOpcode() == ISD::STORE; 2366b625f2f8960de32bc973092aaee8ac62863006feDan Gohman } 23679de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel}; 23689de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michel 236924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// LoadSDNode - This class is used to represent ISD::LOAD nodes. 237024446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 23719de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass LoadSDNode : public LSBaseSDNode { 237224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 23733edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen LoadSDNode(SDValue *ChainPtrOff, DebugLoc dl, SDVTList VTs, 23743edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen ISD::MemIndexedMode AM, ISD::LoadExtType ETy, MVT LVT, 23753edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 23763edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : LSBaseSDNode(ISD::LOAD, dl, ChainPtrOff, 3, 23773edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen VTs, AM, LVT, SV, O, Align, Vol) { 2378a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman SubclassData |= (unsigned short)ETy; 2379a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman assert(getExtensionType() == ETy && "LoadExtType encoding error!"); 23803edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 238124446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 238224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2383ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// getExtensionType - Return whether this is a plain node, 2384ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// or one of the varieties of value-extending loads. 2385ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman ISD::LoadExtType getExtensionType() const { 2386a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman return ISD::LoadExtType(SubclassData & 3); 2387ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman } 2388ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman 2389475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(1); } 2390475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { return getOperand(2); } 2391d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman 239224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const LoadSDNode *) { return true; } 239324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 239424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::LOAD; 239524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 239624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 239724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 239824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// StoreSDNode - This class is used to represent ISD::STORE nodes. 239924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng/// 24009de5d0dd42463f61c4ee2f9db5f3d08153c0dacfScott Michelclass StoreSDNode : public LSBaseSDNode { 240124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng friend class SelectionDAG; 24023edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen StoreSDNode(SDValue *ChainValuePtrOff, DebugLoc dl, SDVTList VTs, 24033edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen ISD::MemIndexedMode AM, bool isTrunc, MVT SVT, 24043edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen const Value *SV, int O=0, unsigned Align=0, bool Vol=false) 24053edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen : LSBaseSDNode(ISD::STORE, dl, ChainValuePtrOff, 4, 24063edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen VTs, AM, SVT, SV, O, Align, Vol) { 2407a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman SubclassData |= (unsigned short)isTrunc; 2408a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman assert(isTruncatingStore() == isTrunc && "isTrunc encoding error!"); 24093edb43e6208493dec85a2e87942f7a4d59073727Dale Johannesen } 241024446e253a17720f6462288255ab5ebd13b8491fEvan Chengpublic: 241124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2412ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// isTruncatingStore - Return true if the op does a truncation before store. 2413ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// For integers this is the same as doing a TRUNCATE and storing the result. 2414ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman /// For floats, it is the same as doing an FP_ROUND and storing the result. 2415a7ce741ff0ab02510833854bfa6a1c8c265faee3Dan Gohman bool isTruncatingStore() const { return SubclassData & 1; } 2416ea8a8651fae10bfea6149a512c01c0ebade4973fDan Gohman 2417475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getValue() const { return getOperand(1); } 2418475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getBasePtr() const { return getOperand(2); } 2419475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getOffset() const { return getOperand(3); } 2420d254a7fc0c354d165caee7e085ca0a95face4fa3Dan Gohman 24216d0b3295777f0e9e9cce27f3473c19f78e88f700Evan Cheng static bool classof(const StoreSDNode *) { return true; } 242224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng static bool classof(const SDNode *N) { 242324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng return N->getOpcode() == ISD::STORE; 242424446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 242524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng}; 242624446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 242715e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner 24281080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerclass SDNodeIterator : public forward_iterator<SDNode, ptrdiff_t> { 24291080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNode *Node; 24301080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned Operand; 2431ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 24321080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator(SDNode *N, unsigned Op) : Node(N), Operand(Op) {} 24331080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnerpublic: 24341080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator==(const SDNodeIterator& x) const { 24351080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return Operand == x.Operand; 24361080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24371080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } 24381080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24391080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNodeIterator &operator=(const SDNodeIterator &I) { 24401080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner assert(I.Node == Node && "Cannot assign iterators to two different nodes!"); 24411080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner Operand = I.Operand; 24421080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 24431080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 2444ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 24451080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator*() const { 2446ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return Node->getOperand(Operand).getNode(); 24471080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24481080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner pointer operator->() const { return operator*(); } 2449ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman 24501080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator& operator++() { // Preincrement 24511080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner ++Operand; 24521080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return *this; 24531080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24541080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner SDNodeIterator operator++(int) { // Postincrement 2455ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman SDNodeIterator tmp = *this; ++*this; return tmp; 24561080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24571080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24581080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } 24591080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static SDNodeIterator end (SDNode *N) { 24601080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator(N, N->getNumOperands()); 24611080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24621080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24631080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner unsigned getOperand() const { return Operand; } 24641080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner const SDNode *getNode() const { return Node; } 24651080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 24661080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24671080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SDNode*> { 24681080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNode NodeType; 24691080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SDNodeIterator ChildIteratorType; 24701080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static inline NodeType *getEntryNode(SDNode *N) { return N; } 2471ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_begin(NodeType *N) { 24721080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::begin(N); 24731080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 2474ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman static inline ChildIteratorType child_end(NodeType *N) { 24751080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return SDNodeIterator::end(N); 24761080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 24771080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 24781080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 24790e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// LargestSDNode - The largest SDNode class. 24800e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman/// 24810e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohmantypedef LoadSDNode LargestSDNode; 24820e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman 2483fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// MostAlignedSDNode - The SDNode class with the greatest alignment 2484fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// requirement. 2485fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman/// 2486015b714f298ce3122302a4e996b81bd3e8c750cdDan Gohmantypedef ARG_FLAGSSDNode MostAlignedSDNode; 2487b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 2488c548428c5d7328592f4db6f6cd815af18b3152a3Evan Chengnamespace ISD { 2489186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// isNormalLoad - Returns true if the specified node is a non-extending 2490186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng /// and unindexed load. 2491186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng inline bool isNormalLoad(const SDNode *N) { 2492c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N); 2493c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD && 2494186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng Ld->getAddressingMode() == ISD::UNINDEXED; 2495186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng } 2496186edc8fa13d0e02d3c17563ad2bd78ac5963a67Evan Cheng 249724446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// isNON_EXTLoad - Returns true if the specified node is a non-extending 249824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng /// load. 249924446e253a17720f6462288255ab5ebd13b8491fEvan Cheng inline bool isNON_EXTLoad(const SDNode *N) { 2500c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 250124446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; 250224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng } 250324446e253a17720f6462288255ab5ebd13b8491fEvan Cheng 2504c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isEXTLoad - Returns true if the specified node is a EXTLOAD. 2505c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2506c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isEXTLoad(const SDNode *N) { 2507c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 250824446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; 2509c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 2510c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2511c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isSEXTLoad - Returns true if the specified node is a SEXTLOAD. 2512c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2513c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isSEXTLoad(const SDNode *N) { 2514c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 251524446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 2516c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 2517c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2518c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// isZEXTLoad - Returns true if the specified node is a ZEXTLOAD. 2519c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng /// 2520c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng inline bool isZEXTLoad(const SDNode *N) { 2521c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 252224446e253a17720f6462288255ab5ebd13b8491fEvan Cheng cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 2523c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng } 25248b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 2525c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isUNINDEXEDLoad - Returns true if the specified node is an unindexed load. 252602c50e4891841c28b2a743731dfc60744bb78879Evan Cheng /// 252702c50e4891841c28b2a743731dfc60744bb78879Evan Cheng inline bool isUNINDEXEDLoad(const SDNode *N) { 2528c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<LoadSDNode>(N) && 252902c50e4891841c28b2a743731dfc60744bb78879Evan Cheng cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 253002c50e4891841c28b2a743731dfc60744bb78879Evan Cheng } 253102c50e4891841c28b2a743731dfc60744bb78879Evan Cheng 2532c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isNormalStore - Returns true if the specified node is a non-truncating 2533c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// and unindexed store. 2534c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands inline bool isNormalStore(const SDNode *N) { 2535c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands const StoreSDNode *St = dyn_cast<StoreSDNode>(N); 2536c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return St && !St->isTruncatingStore() && 2537c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands St->getAddressingMode() == ISD::UNINDEXED; 2538c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands } 2539c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands 25408b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isNON_TRUNCStore - Returns true if the specified node is a non-truncating 25418b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 25428b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isNON_TRUNCStore(const SDNode *N) { 2543c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && !cast<StoreSDNode>(N)->isTruncatingStore(); 25448b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 25458b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng 25468b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// isTRUNCStore - Returns true if the specified node is a truncating 25478b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng /// store. 25488b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng inline bool isTRUNCStore(const SDNode *N) { 2549c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && cast<StoreSDNode>(N)->isTruncatingStore(); 2550c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands } 2551c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands 2552c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// isUNINDEXEDStore - Returns true if the specified node is an 2553c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands /// unindexed store. 2554c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands inline bool isUNINDEXEDStore(const SDNode *N) { 2555c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands return isa<StoreSDNode>(N) && 2556c8f88cc8c0b4ce1664520d5390c623f2c44e4555Duncan Sands cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; 25578b2794aeff151be8cdbd44786c1d0f94f8f2e427Evan Cheng } 2558c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng} 2559c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 2560c548428c5d7328592f4db6f6cd815af18b3152a3Evan Cheng 256163b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner} // end llvm namespace 256263b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner 256363b570d49b7bf205d48749aae1467ef96152ea7aChris Lattner#endif 2564