SelectionDAG.h revision 77cdf30742284a173fe818417eb482224cdee8d4
1c3aae25116e66c177579b0b79182b09340b19753Chris Lattner//===-- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ---------*- C++ -*-===// 2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// The LLVM Compiler Infrastructure 46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// 57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source 67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details. 7ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===// 9ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 10c3aae25116e66c177579b0b79182b09340b19753Chris Lattner// This file declares the SelectionDAG class, and transitively defines the 11c3aae25116e66c177579b0b79182b09340b19753Chris Lattner// SDNode class and subclasses. 12ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman// 13cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner//===----------------------------------------------------------------------===// 14cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 15cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner#ifndef LLVM_CODEGEN_SELECTIONDAG_H 16cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner#define LLVM_CODEGEN_SELECTIONDAG_H 17cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 18fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman#include "llvm/ADT/ilist.h" 19c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene#include "llvm/ADT/DenseSet.h" 20583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/ADT/FoldingSet.h" 214b84086e89d86fb16f562166d9fea8df37db6be7Dan Gohman#include "llvm/ADT/StringMap.h" 22583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey#include "llvm/CodeGen/SelectionDAGNodes.h" 23b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 24acaf09dbe4a6781163857db1321bbd5795e7d410Dan Gohman#include <cassert> 255892d47a625638a90afeb31dd4f6f80a2f9bacdeChris Lattner#include <vector> 26322812e603705e1c2037313633e72f689524b163Evan Cheng#include <map> 27eb19e40efbd3cae80c908a30cdf4d33450733c45Chris Lattner#include <string> 28d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke 29d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm { 30fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman 31fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass AliasAnalysis; 32fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass TargetLowering; 33fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass TargetMachine; 34fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass MachineModuleInfo; 35fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass MachineFunction; 36fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass MachineConstantPoolValue; 37fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanclass FunctionLoweringInfo; 38fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman 398e4018e2de52c534405d7155c7009d0b35afb861Cedric Venettemplate<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> { 408e4018e2de52c534405d7155c7009d0b35afb861Cedric Venetprivate: 41fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman mutable SDNode Sentinel; 42fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanpublic: 43fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman ilist_traits() : Sentinel(ISD::DELETED_NODE, SDVTList()) {} 44fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman 45fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman SDNode *createSentinel() const { 46fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman return &Sentinel; 47fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman } 48fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman static void destroySentinel(SDNode *) {} 49fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman 50fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman static void deleteNode(SDNode *) { 51fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman assert(0 && "ilist_traits<SDNode> shouldn't see a deleteNode call!"); 52fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman } 53fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohmanprivate: 54fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman static void createNode(const SDNode &); 55fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman}; 56c3aae25116e66c177579b0b79182b09340b19753Chris Lattner 57c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// SelectionDAG class - This is used to represent a portion of an LLVM function 58c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// in a low-level Data Dependence DAG representation suitable for instruction 59c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// selection. This DAG is constructed as the first step of instruction 60c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// selection in order to allow implementation of machine specific optimizations 61c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// and code simplifications. 62c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// 63c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// The representation used by the SelectionDAG is a target-independent 64c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// representation, which has some similarities to the GCC RTL representation, 65c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// but is significantly more simple, powerful, and is a graph form instead of a 66c3aae25116e66c177579b0b79182b09340b19753Chris Lattner/// linear form. 67cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner/// 68cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattnerclass SelectionDAG { 69063287a76b5d1486f498fcf674a26d1155471a3fChris Lattner TargetLowering &TLI; 707c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman MachineFunction *MF; 71ead0d88ad7659dabd66cc3149af97d98256fca84Chris Lattner FunctionLoweringInfo &FLI; 7244c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey MachineModuleInfo *MMI; 73cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 74f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman /// EntryNode - The starting token. 75f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman SDNode EntryNode; 76f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman 77f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman /// Root - The root of the entire DAG. 78f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman SDValue Root; 79cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 80213a16c637926bfc38ba373d3aba6778e181e3ecChris Lattner /// AllNodes - A linked list of nodes in the current DAG. 81fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman ilist<SDNode> AllNodes; 82fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman 83f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman /// NodeAllocatorType - The AllocatorType for allocating SDNodes. We use 84f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman /// pool allocation with recycling. 85f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode), 86f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman AlignOf<MostAlignedSDNode>::Alignment> 87f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman NodeAllocatorType; 88f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman 89f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman /// NodeAllocator - Pool allocation for nodes. 90f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman NodeAllocatorType NodeAllocator; 91691ef2ba066dda14ae4ac0ad645054fbc967785aAndrew Lenharth 92213a16c637926bfc38ba373d3aba6778e181e3ecChris Lattner /// CSEMap - This structure is used to memoize nodes, automatically performing 93213a16c637926bfc38ba373d3aba6778e181e3ecChris Lattner /// CSE with existing nodes with a duplicate is requested. 94583bd47f777fe3eb8305872fa0eadab31e833dffJim Laskey FoldingSet<SDNode> CSEMap; 95213a16c637926bfc38ba373d3aba6778e181e3ecChris Lattner 96f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman /// OperandAllocator - Pool allocation for machine-opcode SDNode operands. 97f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman BumpPtrAllocator OperandAllocator; 98f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman 99e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// Allocator - Pool allocation for misc. objects that are created once per 100e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// SelectionDAG. 101e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman BumpPtrAllocator Allocator; 102e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 103d038e04188047eca4749d025ef1f05f7ae660bcaDuncan Sands /// VerifyNode - Sanity check the given node. Aborts if it is invalid. 104d038e04188047eca4749d025ef1f05f7ae660bcaDuncan Sands void VerifyNode(SDNode *N); 105d038e04188047eca4749d025ef1f05f7ae660bcaDuncan Sands 106c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene /// setGraphColorHelper - Implementation of setSubgraphColor. 107c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene /// Return whether we had to truncate the search. 108c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene /// 109c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene bool setSubgraphColorHelper(SDNode *N, const char *Color, DenseSet<SDNode *> &visited, 110c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene int level, bool &printed); 111c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene 112cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattnerpublic: 1137c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman SelectionDAG(TargetLowering &tli, FunctionLoweringInfo &fli); 114cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner ~SelectionDAG(); 115cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 1167c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman /// init - Prepare this SelectionDAG to process code in the given 1177c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman /// MachineFunction. 1187c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman /// 1197c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman void init(MachineFunction &mf, MachineModuleInfo *mmi); 1207c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman 1217c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman /// clear - Clear state and free memory necessary to make this 122f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman /// SelectionDAG ready to process a new block. 123f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman /// 1247c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman void clear(); 125f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman 1267c3234c6be0dc0bdf4b5d6f848cd728a77f349d7Dan Gohman MachineFunction &getMachineFunction() const { return *MF; } 127063287a76b5d1486f498fcf674a26d1155471a3fChris Lattner const TargetMachine &getTarget() const; 128063287a76b5d1486f498fcf674a26d1155471a3fChris Lattner TargetLowering &getTargetLoweringInfo() const { return TLI; } 129ead0d88ad7659dabd66cc3149af97d98256fca84Chris Lattner FunctionLoweringInfo &getFunctionLoweringInfo() const { return FLI; } 13044c3b9fdd416c79f4b67cde1aecfced5921efd81Jim Laskey MachineModuleInfo *getMachineModuleInfo() const { return MMI; } 131cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 132ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'. 1331080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner /// 134462dc7f4960e5074ddf4769ec8b2ef1ba7a4d2c8Dan Gohman void viewGraph(const std::string &Title); 1350b12aef49087b57d276ed760a83525d1e2602144Dan Gohman void viewGraph(); 136ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey 137ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey#ifndef NDEBUG 138ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey std::map<const SDNode *, std::string> NodeGraphAttrs; 139ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey#endif 1401080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 141ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// clearGraphAttrs - Clear all previously defined node graph attributes. 142ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// Intended to be used from a debugging tool (eg. gdb). 143ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey void clearGraphAttrs(); 144ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey 145ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".) 146ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// 147ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey void setGraphAttrs(const SDNode *N, const char *Attrs); 148ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey 149ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".) 150ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// Used from getNodeAttributes. 151ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey const std::string getGraphAttrs(const SDNode *N) const; 152ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey 153ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// setGraphColor - Convenience for setting node color attribute. 154ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey /// 155ec20402c90b605afeedbcf0e3aabe6f8054f23ddJim Laskey void setGraphColor(const SDNode *N, const char *Color); 1561080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 157c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene /// setGraphColor - Convenience for setting subgraph color attribute. 158c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene /// 159c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene void setSubgraphColor(SDNode *N, const char *Color); 160c5e7e8d87d4a3b10edd5ac93ba1f3cdb4d1b449aDavid Greene 161fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman typedef ilist<SDNode>::const_iterator allnodes_const_iterator; 162b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); } 163b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner allnodes_const_iterator allnodes_end() const { return AllNodes.end(); } 164fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman typedef ilist<SDNode>::iterator allnodes_iterator; 165b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner allnodes_iterator allnodes_begin() { return AllNodes.begin(); } 166b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner allnodes_iterator allnodes_end() { return AllNodes.end(); } 167fed90b6d097d50881afb45e4d79f430db66dd741Dan Gohman ilist<SDNode>::size_type allnodes_size() const { 1680e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman return AllNodes.size(); 1690e5f1306b059b62d7725f324e087efbc8e7a782dDan Gohman } 170b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner 171c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// getRoot - Return the root tag of the SelectionDAG. 172cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner /// 173475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &getRoot() const { return Root; } 174cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 175c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// getEntryNode - Return the token chain corresponding to the entry of the 176c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// function. 177f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman SDValue getEntryNode() const { 178f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman return SDValue(const_cast<SDNode *>(&EntryNode), 0); 179f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman } 180cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 181c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// setRoot - Set the current root tag of the SelectionDAG. 182cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner /// 183475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue &setRoot(SDValue N) { 184ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif assert((!N.getNode() || N.getValueType() == MVT::Other) && 185acaf09dbe4a6781163857db1321bbd5795e7d410Dan Gohman "DAG root value is not a chain!"); 186acaf09dbe4a6781163857db1321bbd5795e7d410Dan Gohman return Root = N; 187acaf09dbe4a6781163857db1321bbd5795e7d410Dan Gohman } 188cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 1891d4d41411190dd9e62764e56713753d4155764ddNate Begeman /// Combine - This iterates over the nodes in the SelectionDAG, folding 1901d4d41411190dd9e62764e56713753d4155764ddNate Begeman /// certain types of nodes together, or eliminating superfluous nodes. When 1911d4d41411190dd9e62764e56713753d4155764ddNate Begeman /// the AfterLegalize argument is set to 'true', Combine takes care not to 1921d4d41411190dd9e62764e56713753d4155764ddNate Begeman /// generate any nodes that will be illegal on the target. 193a267651b7ec4f96e01b31f541d446758bf8da8a9Dan Gohman void Combine(bool AfterLegalize, AliasAnalysis &AA, bool Fast); 1941d4d41411190dd9e62764e56713753d4155764ddNate Begeman 19501d029b82cb08367d81aa10cdc94d05360466649Chris Lattner /// LegalizeTypes - This transforms the SelectionDAG into a SelectionDAG that 19601d029b82cb08367d81aa10cdc94d05360466649Chris Lattner /// only uses types natively supported by the target. 19701d029b82cb08367d81aa10cdc94d05360466649Chris Lattner /// 19801d029b82cb08367d81aa10cdc94d05360466649Chris Lattner /// Note that this is an involved process that may invalidate pointers into 19901d029b82cb08367d81aa10cdc94d05360466649Chris Lattner /// the graph. 20001d029b82cb08367d81aa10cdc94d05360466649Chris Lattner void LegalizeTypes(); 20101d029b82cb08367d81aa10cdc94d05360466649Chris Lattner 202c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// Legalize - This transforms the SelectionDAG into a SelectionDAG that is 203c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// compatible with the target instruction selector, as indicated by the 204c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// TargetLowering object. 205cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner /// 206c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// Note that this is an involved process that may invalidate pointers into 207c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// the graph. 208063287a76b5d1486f498fcf674a26d1155471a3fChris Lattner void Legalize(); 209c3aae25116e66c177579b0b79182b09340b19753Chris Lattner 210d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner /// RemoveDeadNodes - This method deletes all unreachable nodes in the 211190a418bf6b49a4ef1c1980229a2f0d516e8a2cdChris Lattner /// SelectionDAG. 212190a418bf6b49a4ef1c1980229a2f0d516e8a2cdChris Lattner void RemoveDeadNodes(); 213130a6471b90f66e99b1f9f42877fdf611c330ac6Evan Cheng 214130a6471b90f66e99b1f9f42877fdf611c330ac6Evan Cheng /// DeleteNode - Remove the specified node from the system. This node must 215130a6471b90f66e99b1f9f42877fdf611c330ac6Evan Cheng /// have no referrers. 216130a6471b90f66e99b1f9f42877fdf611c330ac6Evan Cheng void DeleteNode(SDNode *N); 217130a6471b90f66e99b1f9f42877fdf611c330ac6Evan Cheng 21870046e920fa37989a041af663ada2b2b646e258fChris Lattner /// getVTList - Return an SDVTList that represents the list of values 21970046e920fa37989a041af663ada2b2b646e258fChris Lattner /// specified. 22083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDVTList getVTList(MVT VT); 22183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDVTList getVTList(MVT VT1, MVT VT2); 22283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDVTList getVTList(MVT VT1, MVT VT2, MVT VT3); 22383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDVTList getVTList(const MVT *VTs, unsigned NumVTs); 22470046e920fa37989a041af663ada2b2b646e258fChris Lattner 22570046e920fa37989a041af663ada2b2b646e258fChris Lattner /// getNodeValueTypes - These are obsolete, use getVTList instead. 22683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *getNodeValueTypes(MVT VT) { 22770046e920fa37989a041af663ada2b2b646e258fChris Lattner return getVTList(VT).VTs; 22870046e920fa37989a041af663ada2b2b646e258fChris Lattner } 22983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *getNodeValueTypes(MVT VT1, MVT VT2) { 23070046e920fa37989a041af663ada2b2b646e258fChris Lattner return getVTList(VT1, VT2).VTs; 23170046e920fa37989a041af663ada2b2b646e258fChris Lattner } 23283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *getNodeValueTypes(MVT VT1, MVT VT2, MVT VT3) { 23370046e920fa37989a041af663ada2b2b646e258fChris Lattner return getVTList(VT1, VT2, VT3).VTs; 23470046e920fa37989a041af663ada2b2b646e258fChris Lattner } 235f877b735ad4987f26cafcbaf22aa4c2199458b5dDan Gohman const MVT *getNodeValueTypes(const std::vector<MVT> &vtList) { 23613d57320bd212483463d4f8992d5787b29eda5dfBill Wendling return getVTList(&vtList[0], (unsigned)vtList.size()).VTs; 23770046e920fa37989a041af663ada2b2b646e258fChris Lattner } 23870046e920fa37989a041af663ada2b2b646e258fChris Lattner 23970046e920fa37989a041af663ada2b2b646e258fChris Lattner 2401b1a49714ef26225a42199cf2930529f31868322Chris Lattner //===--------------------------------------------------------------------===// 24170046e920fa37989a041af663ada2b2b646e258fChris Lattner // Node creation methods. 24270046e920fa37989a041af663ada2b2b646e258fChris Lattner // 243475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getConstant(uint64_t Val, MVT VT, bool isTarget = false); 244475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getConstant(const APInt &Val, MVT VT, bool isTarget = false); 2454fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman SDValue getConstant(const ConstantInt &Val, MVT VT, bool isTarget = false); 246475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getIntPtrConstant(uint64_t Val, bool isTarget = false); 247475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetConstant(uint64_t Val, MVT VT) { 248cbea3045ce0bdd061c494a831d0ce2d5834211ccChris Lattner return getConstant(Val, VT, true); 249cbea3045ce0bdd061c494a831d0ce2d5834211ccChris Lattner } 250475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetConstant(const APInt &Val, MVT VT) { 2516394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman return getConstant(Val, VT, true); 2526394b099e836f56a937cdcc7332c9487b504ca68Dan Gohman } 2534fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman SDValue getTargetConstant(const ConstantInt &Val, MVT VT) { 2544fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman return getConstant(Val, VT, true); 2554fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman } 256475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getConstantFP(double Val, MVT VT, bool isTarget = false); 257475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getConstantFP(const APFloat& Val, MVT VT, bool isTarget = false); 2584fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman SDValue getConstantFP(const ConstantFP &CF, MVT VT, bool isTarget = false); 259475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetConstantFP(double Val, MVT VT) { 260c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner return getConstantFP(Val, VT, true); 261c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner } 262475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetConstantFP(const APFloat& Val, MVT VT) { 263f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen return getConstantFP(Val, VT, true); 264f04afdbb48568ef09f11fd10ac03426101f2dbf8Dale Johannesen } 2654fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman SDValue getTargetConstantFP(const ConstantFP &Val, MVT VT) { 2664fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman return getConstantFP(Val, VT, true); 2674fbd796a1251a27e6590765a0a34876f436a0af9Dan Gohman } 268475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getGlobalAddress(const GlobalValue *GV, MVT VT, 2696520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t offset = 0, bool isTargetGA = false); 270475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetGlobalAddress(const GlobalValue *GV, MVT VT, 2716520e20e4fb31f2e65e25c38b372b19d33a83df4Dan Gohman int64_t offset = 0) { 272cbea3045ce0bdd061c494a831d0ce2d5834211ccChris Lattner return getGlobalAddress(GV, VT, offset, true); 273cbea3045ce0bdd061c494a831d0ce2d5834211ccChris Lattner } 274475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getFrameIndex(int FI, MVT VT, bool isTarget = false); 275475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetFrameIndex(int FI, MVT VT) { 276c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner return getFrameIndex(FI, VT, true); 277c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner } 278475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getJumpTable(int JTI, MVT VT, bool isTarget = false); 279475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetJumpTable(int JTI, MVT VT) { 280c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner return getJumpTable(JTI, VT, true); 281c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner } 282475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getConstantPool(Constant *C, MVT VT, 283c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner unsigned Align = 0, int Offs = 0, bool isT=false); 284475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetConstantPool(Constant *C, MVT VT, 285c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner unsigned Align = 0, int Offset = 0) { 286c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner return getConstantPool(C, VT, Align, Offset, true); 287c9f8f416800784ca6453222b307bc44ad24739b0Chris Lattner } 288475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getConstantPool(MachineConstantPoolValue *C, MVT VT, 289d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng unsigned Align = 0, int Offs = 0, bool isT=false); 290475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTargetConstantPool(MachineConstantPoolValue *C, 29183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands MVT VT, unsigned Align = 0, 292d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng int Offset = 0) { 293d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng return getConstantPool(C, VT, Align, Offset, true); 294d6594ae54cfde4db4d30272192645c0a45fb9902Evan Cheng } 295475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getBasicBlock(MachineBasicBlock *MBB); 296056292fd738924f3f7703725d8f630983794b5a5Bill Wendling SDValue getExternalSymbol(const char *Sym, MVT VT); 297056292fd738924f3f7703725d8f630983794b5a5Bill Wendling SDValue getTargetExternalSymbol(const char *Sym, MVT VT); 298475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getArgFlags(ISD::ArgFlagsTy Flags); 299475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getValueType(MVT); 300475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getRegister(unsigned Reg, MVT VT); 301475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getDbgStopPoint(SDValue Root, unsigned Line, unsigned Col, 3027f460203b0c5350e9b2c592f438e40f7a7de6e45Dan Gohman const CompileUnitDesc *CU); 303475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getLabel(unsigned Opcode, SDValue Root, unsigned LabelID); 304c3aae25116e66c177579b0b79182b09340b19753Chris Lattner 305475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getCopyToReg(SDValue Chain, unsigned Reg, SDValue N) { 306d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner return getNode(ISD::CopyToReg, MVT::Other, Chain, 307d5d0f9bd20d9df07d6b4d41b7e8ed6d33b6a649dChris Lattner getRegister(Reg, N.getValueType()), N); 308cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner } 309cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 310e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner // This version of the getCopyToReg method takes an extra operand, which 311e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner // indicates that there is potentially an incoming flag value (if Flag is not 312e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner // null) and that there should be a flag result. 313475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getCopyToReg(SDValue Chain, unsigned Reg, SDValue N, 314475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Flag) { 31583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag); 316475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag }; 317ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.getNode() ? 4 : 3); 318e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner } 31966a48bbc3565b40ea0e6f2d58cf5e3a8e64802efEvan Cheng 320475871a144eb604ddaf37503397ba0941442e5fbDan Gohman // Similar to last getCopyToReg() except parameter Reg is a SDValue 321475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getCopyToReg(SDValue Chain, SDValue Reg, SDValue N, 322475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Flag) { 32383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag); 324475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Ops[] = { Chain, Reg, N, Flag }; 325ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.getNode() ? 4 : 3); 32666a48bbc3565b40ea0e6f2d58cf5e3a8e64802efEvan Cheng } 327e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner 328475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getCopyFromReg(SDValue Chain, unsigned Reg, MVT VT) { 32983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *VTs = getNodeValueTypes(VT, MVT::Other); 330475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Ops[] = { Chain, getRegister(Reg, VT) }; 3312fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner return getNode(ISD::CopyFromReg, VTs, 2, Ops, 2); 33218c2f13e0f9d0e5d6227cf6d1881e9ee3d1b6109Chris Lattner } 333e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner 334e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner // This version of the getCopyFromReg method takes an extra operand, which 335e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner // indicates that there is potentially an incoming flag value (if Flag is not 336e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner // null) and that there should be a flag result. 337475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getCopyFromReg(SDValue Chain, unsigned Reg, MVT VT, 338475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Flag) { 33983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *VTs = getNodeValueTypes(VT, MVT::Other, MVT::Flag); 340475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Ops[] = { Chain, getRegister(Reg, VT), Flag }; 341ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif return getNode(ISD::CopyFromReg, VTs, 3, Ops, Flag.getNode() ? 3 : 2); 342e3f1026683c38f6605ccaf698b7082f1b0a0f8c8Chris Lattner } 34318c2f13e0f9d0e5d6227cf6d1881e9ee3d1b6109Chris Lattner 344475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getCondCode(ISD::CondCode Cond); 345cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 34677cdf30742284a173fe818417eb482224cdee8d4Mon P Wang /// Returns the ConvertRndSat Note: Avoid using this node because it may 34777cdf30742284a173fe818417eb482224cdee8d4Mon P Wang /// disappear in the future and most targets don't support it. 34877cdf30742284a173fe818417eb482224cdee8d4Mon P Wang SDValue getConvertRndSat(MVT VT, SDValue Val, SDValue DTy, SDValue STy, 34977cdf30742284a173fe818417eb482224cdee8d4Mon P Wang SDValue Rnd, SDValue Sat, ISD::CvtCode Code); 35077cdf30742284a173fe818417eb482224cdee8d4Mon P Wang 3511ccae666f596d5aeca5c9942995763600b622062Chris Lattner /// getZeroExtendInReg - Return the expression required to zero extend the Op 3521ccae666f596d5aeca5c9942995763600b622062Chris Lattner /// value assuming it was the smaller SrcTy value. 353475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getZeroExtendInReg(SDValue Op, MVT SrcTy); 3546a5b6d7633c96c72ca7d5f8ba0c855e4690ada04Chris Lattner 3556a5b6d7633c96c72ca7d5f8ba0c855e4690ada04Chris Lattner /// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have 3566a5b6d7633c96c72ca7d5f8ba0c855e4690ada04Chris Lattner /// a flag result (to ensure it's not CSE'd). 357475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getCALLSEQ_START(SDValue Chain, SDValue Op) { 35883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag); 359475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Ops[] = { Chain, Op }; 3602fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner return getNode(ISD::CALLSEQ_START, VTs, 2, Ops, 2); 3616a5b6d7633c96c72ca7d5f8ba0c855e4690ada04Chris Lattner } 3621ccae666f596d5aeca5c9942995763600b622062Chris Lattner 3630f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling /// getCALLSEQ_END - Return a new CALLSEQ_END node, which always must have a 3640f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling /// flag result (to ensure it's not CSE'd). 365475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, 366475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue InFlag) { 3670f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling SDVTList NodeTys = getVTList(MVT::Other, MVT::Flag); 368475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SmallVector<SDValue, 4> Ops; 3690f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling Ops.push_back(Chain); 3700f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling Ops.push_back(Op1); 3710f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling Ops.push_back(Op2); 3720f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling Ops.push_back(InFlag); 3730f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling return getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0], 374ba36cb5242eb02b12b277f82b9efe497f7da4d7fGabor Greif (unsigned)Ops.size() - (InFlag.getNode() == 0 ? 1 : 0)); 3750f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling } 3760f8d9c04d9feef86cee35cf5fecfb348a6b3de50Bill Wendling 377c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// getNode - Gets or creates the specified node. 378cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner /// 379475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, MVT VT); 380475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, MVT VT, SDValue N); 381475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, MVT VT, SDValue N1, SDValue N2); 382475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, MVT VT, 383475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue N1, SDValue N2, SDValue N3); 384475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, MVT VT, 385475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue N1, SDValue N2, SDValue N3, SDValue N4); 386475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, MVT VT, 387475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue N1, SDValue N2, SDValue N3, SDValue N4, 388475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue N5); 389475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, MVT VT, 390475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 391475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, MVT VT, 3926d9cdd56173fb915a9e3a8f0f6b5a8ed9bed1098Dan Gohman const SDUse *Ops, unsigned NumOps); 393475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, const std::vector<MVT> &ResultTys, 394475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 395475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, const MVT *VTs, unsigned NumVTs, 396475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 397475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, SDVTList VTs); 398475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, SDVTList VTs, SDValue N); 399475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, SDVTList VTs, SDValue N1, SDValue N2); 400475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, SDVTList VTs, 401475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue N1, SDValue N2, SDValue N3); 402475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, SDVTList VTs, 403475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue N1, SDValue N2, SDValue N3, SDValue N4); 404475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, SDVTList VTs, 405475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue N1, SDValue N2, SDValue N3, SDValue N4, 406475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue N5); 407475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getNode(unsigned Opcode, SDVTList VTs, 408475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 409475871a144eb604ddaf37503397ba0941442e5fbDan Gohman 410475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getMemcpy(SDValue Chain, SDValue Dst, SDValue Src, 411475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Size, unsigned Align, 412707e0184233f27e0e9f9aee0309f2daab8cfe7f8Dan Gohman bool AlwaysInline, 4131f13c686df75ddbbe15b208606ece4846d7479a8Dan Gohman const Value *DstSV, uint64_t DstSVOff, 4141f13c686df75ddbbe15b208606ece4846d7479a8Dan Gohman const Value *SrcSV, uint64_t SrcSVOff); 4155c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola 416475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getMemmove(SDValue Chain, SDValue Dst, SDValue Src, 417475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Size, unsigned Align, 4181f13c686df75ddbbe15b208606ece4846d7479a8Dan Gohman const Value *DstSV, uint64_t DstOSVff, 4191f13c686df75ddbbe15b208606ece4846d7479a8Dan Gohman const Value *SrcSV, uint64_t SrcSVOff); 4205c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola 421475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getMemset(SDValue Chain, SDValue Dst, SDValue Src, 422475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Size, unsigned Align, 4231f13c686df75ddbbe15b208606ece4846d7479a8Dan Gohman const Value *DstSV, uint64_t DstSVOff); 4245c0d6ed325417baa5d119af9c2b6790231d8565fRafael Espindola 4257cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner /// getSetCC - Helper function to make it easier to build SetCC's if you just 426475871a144eb604ddaf37503397ba0941442e5fbDan Gohman /// have an ISD::CondCode instead of an SDValue. 4277cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner /// 428475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getSetCC(MVT VT, SDValue LHS, SDValue RHS, 4297cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner ISD::CondCode Cond) { 4307cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner return getNode(ISD::SETCC, VT, LHS, RHS, getCondCode(Cond)); 431b43e9c196542acc80c9e4643809661065710848fNate Begeman } 432b43e9c196542acc80c9e4643809661065710848fNate Begeman 433b43e9c196542acc80c9e4643809661065710848fNate Begeman /// getVSetCC - Helper function to make it easier to build VSetCC's nodes 434475871a144eb604ddaf37503397ba0941442e5fbDan Gohman /// if you just have an ISD::CondCode instead of an SDValue. 435b43e9c196542acc80c9e4643809661065710848fNate Begeman /// 436475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getVSetCC(MVT VT, SDValue LHS, SDValue RHS, 437b43e9c196542acc80c9e4643809661065710848fNate Begeman ISD::CondCode Cond) { 438b43e9c196542acc80c9e4643809661065710848fNate Begeman return getNode(ISD::VSETCC, VT, LHS, RHS, getCondCode(Cond)); 4397cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner } 4409373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman 4419373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman /// getSelectCC - Helper function to make it easier to build SelectCC's if you 442475871a144eb604ddaf37503397ba0941442e5fbDan Gohman /// just have an ISD::CondCode instead of an SDValue. 4439373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman /// 444475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getSelectCC(SDValue LHS, SDValue RHS, 445475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue True, SDValue False, ISD::CondCode Cond) { 4462fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner return getNode(ISD::SELECT_CC, True.getValueType(), LHS, RHS, True, False, 4472fa6d3b1fcadbde90eaee0e8e89aebd81630b662Chris Lattner getCondCode(Cond)); 4489373a81e53ce5f9f2c06c4209b8b886605aece08Nate Begeman } 4497cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner 450acc398c195a697795bff3245943d104eb19192b9Nate Begeman /// getVAArg - VAArg produces a result and token chain, and takes a pointer 451acc398c195a697795bff3245943d104eb19192b9Nate Begeman /// and a source value as input. 452475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getVAArg(MVT VT, SDValue Chain, SDValue Ptr, 453475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue SV); 4547cbd525ba85ebe440d15fa359ec940e404d14906Nate Begeman 455c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang /// getAtomic - Gets a node for an atomic op, produces result and chain and 456c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang /// takes 3 operands 457475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getAtomic(unsigned Opcode, SDValue Chain, SDValue Ptr, 458475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Cmp, SDValue Swp, const Value* PtrVal, 45928873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang unsigned Alignment=0); 460ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 461c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang /// getAtomic - Gets a node for an atomic op, produces result and chain and 462c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang /// takes 2 operands. 463475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getAtomic(unsigned Opcode, SDValue Chain, SDValue Ptr, 464475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Val, const Value* PtrVal, 46528873106309db515d58889a4c4fa3e0a92d1b60eMon P Wang unsigned Alignment = 0); 466ab0b949e0e9de452f3b052b11634ab761e008b23Andrew Lenharth 467c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang /// getMemIntrinsicNode - Creates a MemIntrinsicNode that may produce a 468c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang /// result and takes a list of operands. 469c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang SDValue getMemIntrinsicNode(unsigned Opcode, 470c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang const MVT *VTs, unsigned NumVTs, 471c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang const SDValue *Ops, unsigned NumOps, 472c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MVT MemVT, const Value *srcValue, int SVOff, 473c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang unsigned Align = 0, bool Vol = false, 474c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool ReadMem = true, bool WriteMem = true); 475c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 476c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang SDValue getMemIntrinsicNode(unsigned Opcode, SDVTList VTList, 477c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang const SDValue *Ops, unsigned NumOps, 478c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang MVT MemVT, const Value *srcValue, int SVOff, 479c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang unsigned Align = 0, bool Vol = false, 480c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang bool ReadMem = true, bool WriteMem = true); 481c4d1021ead43cfa7da08a8f7ddc9a059a8ba14c5Mon P Wang 4824bdcb61af33399d4e01fdf3c47ca1f1f5356e370Duncan Sands /// getMergeValues - Create a MERGE_VALUES node from the given operands. 4834bdcb61af33399d4e01fdf3c47ca1f1f5356e370Duncan Sands /// Allowed to return something different (and simpler) if Simplify is true. 484475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getMergeValues(const SDValue *Ops, unsigned NumOps, 4854bdcb61af33399d4e01fdf3c47ca1f1f5356e370Duncan Sands bool Simplify = true); 4864bdcb61af33399d4e01fdf3c47ca1f1f5356e370Duncan Sands 487f9516208e57364ab1e7d8748af1f59a2ea5fb572Duncan Sands /// getMergeValues - Create a MERGE_VALUES node from the given types and ops. 488f9516208e57364ab1e7d8748af1f59a2ea5fb572Duncan Sands /// Allowed to return something different (and simpler) if Simplify is true. 4894bdcb61af33399d4e01fdf3c47ca1f1f5356e370Duncan Sands /// May be faster than the above version if VTs is known and NumOps is large. 490475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getMergeValues(SDVTList VTs, const SDValue *Ops, unsigned NumOps, 491f9516208e57364ab1e7d8748af1f59a2ea5fb572Duncan Sands bool Simplify = true) { 492f9516208e57364ab1e7d8748af1f59a2ea5fb572Duncan Sands if (Simplify && NumOps == 1) 493f9516208e57364ab1e7d8748af1f59a2ea5fb572Duncan Sands return Ops[0]; 494f9516208e57364ab1e7d8748af1f59a2ea5fb572Duncan Sands return getNode(ISD::MERGE_VALUES, VTs, Ops, NumOps); 495f9516208e57364ab1e7d8748af1f59a2ea5fb572Duncan Sands } 496f9516208e57364ab1e7d8748af1f59a2ea5fb572Duncan Sands 497095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// getCall - Create a CALL node from the given information. 498095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman /// 499095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman SDValue getCall(unsigned CallingConv, bool IsVarArgs, bool IsTailCall, 50086098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen bool isInreg, SDVTList VTs, const SDValue *Operands, 50186098bd6a63d2cdf0c9be9ef3151bd2728281fd7Dale Johannesen unsigned NumOperands); 502095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman 503c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// getLoad - Loads are not normal binary operators: their result type is not 504c3aae25116e66c177579b0b79182b09340b19753Chris Lattner /// determined by their operands, and they produce a value AND a token chain. 505cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner /// 506475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getLoad(MVT VT, SDValue Chain, SDValue Ptr, 50795c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb const Value *SV, int SVOffset, bool isVolatile=false, 50895c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb unsigned Alignment=0); 509475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getExtLoad(ISD::LoadExtType ExtType, MVT VT, 510475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Chain, SDValue Ptr, const Value *SV, 51183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands int SVOffset, MVT EVT, bool isVolatile=false, 51295c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb unsigned Alignment=0); 513475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getIndexedLoad(SDValue OrigLoad, SDValue Base, 514475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Offset, ISD::MemIndexedMode AM); 515475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, 516475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT, SDValue Chain, 517475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Ptr, SDValue Offset, 51883ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const Value *SV, int SVOffset, MVT EVT, 519e10efce22502d1a1855d25baf1458660f4ba6f33Duncan Sands bool isVolatile=false, unsigned Alignment=0); 5202d86ea21dd76647cb054fd5d27df9e49efc672b6Andrew Lenharth 521ad071e1cd1a4b880019f1b2e827ee81867815f82Evan Cheng /// getStore - Helper function to build ISD::STORE nodes. 522ad071e1cd1a4b880019f1b2e827ee81867815f82Evan Cheng /// 523475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getStore(SDValue Chain, SDValue Val, SDValue Ptr, 52495c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb const Value *SV, int SVOffset, bool isVolatile=false, 52595c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb unsigned Alignment=0); 526475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getTruncStore(SDValue Chain, SDValue Val, SDValue Ptr, 52783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands const Value *SV, int SVOffset, MVT TVT, 52895c218a83ecf77590b9dc40c636720772d2b5cd7Christopher Lamb bool isVolatile=false, unsigned Alignment=0); 529475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getIndexedStore(SDValue OrigStoe, SDValue Base, 530475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Offset, ISD::MemIndexedMode AM); 531ad071e1cd1a4b880019f1b2e827ee81867815f82Evan Cheng 53269de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // getSrcValue - Construct a node to track a Value* through the backend. 533475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getSrcValue(const Value *v); 53469de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman 53569de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // getMemOperand - Construct a node to track a memory reference 53669de1932b350d7cdfc0ed1f4198d6f78c7822a02Dan Gohman // through the backend. 537475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getMemOperand(const MachineMemOperand &MO); 538cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 539b9aff659e82e4ec1a507e6e7fe7969379a431613Chris Lattner /// UpdateNodeOperands - *Mutate* the specified node in-place to have the 540b9aff659e82e4ec1a507e6e7fe7969379a431613Chris Lattner /// specified operands. If the resultant node already exists in the DAG, 541b9aff659e82e4ec1a507e6e7fe7969379a431613Chris Lattner /// this does not modify the specified node, instead it returns the node that 542b9aff659e82e4ec1a507e6e7fe7969379a431613Chris Lattner /// already exists. If the resultant node does not exist in the DAG, the 543b9aff659e82e4ec1a507e6e7fe7969379a431613Chris Lattner /// input node is returned. As a degenerate case, if you specify the same 544b9aff659e82e4ec1a507e6e7fe7969379a431613Chris Lattner /// input operands as the node already has, the input node is returned. 545475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue UpdateNodeOperands(SDValue N, SDValue Op); 546475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2); 547475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2, 548475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op3); 549475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2, 550475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op3, SDValue Op4); 551475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2, 552475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op3, SDValue Op4, SDValue Op5); 553475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue UpdateNodeOperands(SDValue N, 554475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 5551b95095857b78e12138c22e76c7936611c51355bChris Lattner 5561b95095857b78e12138c22e76c7936611c51355bChris Lattner /// SelectNodeTo - These are used for target selectors to *mutate* the 5571b95095857b78e12138c22e76c7936611c51355bChris Lattner /// specified node to have the specified return type, Target opcode, and 5581b95095857b78e12138c22e76c7936611c51355bChris Lattner /// operands. Note that target opcodes are stored as 559e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// ~TargetOpcode in the node opcode field. The resultant node is returned. 56083ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT); 561475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, SDValue Op1); 56283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, 563475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op1, SDValue Op2); 56483ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, 565475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op1, SDValue Op2, SDValue Op3); 56683ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, 567475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 568cd920d9ecfcefff13c3619a32b58399cac2e3630Dan Gohman SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, MVT VT2); 569cd920d9ecfcefff13c3619a32b58399cac2e3630Dan Gohman SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 570475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, const SDValue *Ops, unsigned NumOps); 571cd920d9ecfcefff13c3619a32b58399cac2e3630Dan Gohman SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 572475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, MVT VT3, const SDValue *Ops, unsigned NumOps); 573cd920d9ecfcefff13c3619a32b58399cac2e3630Dan Gohman SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 574475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, SDValue Op1); 57583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 576475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, SDValue Op1, SDValue Op2); 57783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 578475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); 579cd920d9ecfcefff13c3619a32b58399cac2e3630Dan Gohman SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs, 580475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 581694481ee01bfe507c6e37de0dc1c64cff455eefdEvan Cheng 582e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// MorphNodeTo - These *mutate* the specified node to have the specified 583e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// return type, opcode, and operands. 584e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT); 585475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, SDValue Op1); 586e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, 587475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op1, SDValue Op2); 588e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, 589475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op1, SDValue Op2, SDValue Op3); 590e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, 591475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 592e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, MVT VT2); 593e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 594475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, const SDValue *Ops, unsigned NumOps); 595e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 596475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, MVT VT3, const SDValue *Ops, unsigned NumOps); 597e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 598475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, SDValue Op1); 599e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 600475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, SDValue Op1, SDValue Op2); 601e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 602475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); 603e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, 604475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 605753c8f20e45f6e4198c7cf4096ecc8948a029e9cChris Lattner 6066ae46c4c8757237bca2b78b589c96c37015bc356Evan Cheng /// getTargetNode - These are used for target selectors to create a new node 6076ae46c4c8757237bca2b78b589c96c37015bc356Evan Cheng /// with specified return type(s), target opcode, and operands. 6086ae46c4c8757237bca2b78b589c96c37015bc356Evan Cheng /// 6096ae46c4c8757237bca2b78b589c96c37015bc356Evan Cheng /// Note that getTargetNode returns the resultant node. If there is already a 6106ae46c4c8757237bca2b78b589c96c37015bc356Evan Cheng /// node of the specified opcode and operands, it returns that node instead of 6116ae46c4c8757237bca2b78b589c96c37015bc356Evan Cheng /// the current one. 61283ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT); 613475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode *getTargetNode(unsigned Opcode, MVT VT, SDValue Op1); 614475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode *getTargetNode(unsigned Opcode, MVT VT, SDValue Op1, SDValue Op2); 61583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT, 616475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op1, SDValue Op2, SDValue Op3); 61783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT, 618475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 61983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2); 620475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, SDValue Op1); 62183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT1, 622475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, SDValue Op1, SDValue Op2); 62383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT1, 624475871a144eb604ddaf37503397ba0941442e5fbDan Gohman MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); 62583ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, 626475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 62783ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, 628475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op1, SDValue Op2); 62983ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, 630475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue Op1, SDValue Op2, SDValue Op3); 63183ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, 632475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 63383ec4b6711980242ef3c55a4fa36b2d7a39c1bfbDuncan Sands SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, MVT VT4, 634475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 635f877b735ad4987f26cafcbaf22aa4c2199458b5dDan Gohman SDNode *getTargetNode(unsigned Opcode, const std::vector<MVT> &ResultTys, 636475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 63708b1173971a51eb89d7d6ee0992c39170c86994aEvan Cheng 63808b1173971a51eb89d7d6ee0992c39170c86994aEvan Cheng /// getNodeIfExists - Get the specified node if it's already available, or 63908b1173971a51eb89d7d6ee0992c39170c86994aEvan Cheng /// else return NULL. 64008b1173971a51eb89d7d6ee0992c39170c86994aEvan Cheng SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs, 641475871a144eb604ddaf37503397ba0941442e5fbDan Gohman const SDValue *Ops, unsigned NumOps); 6426542d950609208de3e1cde704c5f89aad864c0d9Chris Lattner 643f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// DAGUpdateListener - Clients of various APIs that cause global effects on 644f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// the DAG can optionally implement this interface. This allows the clients 645f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// to handle the various sorts of updates that happen. 646f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner class DAGUpdateListener { 647f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner public: 648f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner virtual ~DAGUpdateListener(); 649edfcf598faab9ce294712551ecf67093acd1c66eDuncan Sands 650edfcf598faab9ce294712551ecf67093acd1c66eDuncan Sands /// NodeDeleted - The node N that was deleted and, if E is not null, an 651edfcf598faab9ce294712551ecf67093acd1c66eDuncan Sands /// equivalent node E that replaced it. 652edfcf598faab9ce294712551ecf67093acd1c66eDuncan Sands virtual void NodeDeleted(SDNode *N, SDNode *E) = 0; 653edfcf598faab9ce294712551ecf67093acd1c66eDuncan Sands 654edfcf598faab9ce294712551ecf67093acd1c66eDuncan Sands /// NodeUpdated - The node N that was updated. 655f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner virtual void NodeUpdated(SDNode *N) = 0; 656f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner }; 657f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner 658f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// RemoveDeadNode - Remove the specified node from the system. If any of its 659f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// operands then becomes dead, remove them as well. Inform UpdateListener 660f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// for each node deleted. 661f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner void RemoveDeadNode(SDNode *N, DAGUpdateListener *UpdateListener = 0); 662f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner 6630fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman /// RemoveDeadNodes - This method deletes the unreachable nodes in the 6640fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman /// given list, and any nodes that become unreachable as a result. 6650fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes, 6660fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman DAGUpdateListener *UpdateListener = 0); 6670fe9c6e7babb3c0731d9cb864ec498ec4184760fDan Gohman 6686542d950609208de3e1cde704c5f89aad864c0d9Chris Lattner /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead. 66926005b1b672aebd437edc561d381c5dd19a03ddbChris Lattner /// This can cause recursive merging of nodes in the DAG. Use the first 67026005b1b672aebd437edc561d381c5dd19a03ddbChris Lattner /// version if 'From' is known to have a single result, use the second 67126005b1b672aebd437edc561d381c5dd19a03ddbChris Lattner /// if you have two nodes with identical results, use the third otherwise. 6726542d950609208de3e1cde704c5f89aad864c0d9Chris Lattner /// 673f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// These methods all take an optional UpdateListener, which (if not null) is 674f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// informed about nodes that are deleted and modified due to recursive 675f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// changes in the dag. 676fde3f3061d665babeb78443119a09876098fc35eChris Lattner /// 677475871a144eb604ddaf37503397ba0941442e5fbDan Gohman void ReplaceAllUsesWith(SDValue From, SDValue Op, 678f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner DAGUpdateListener *UpdateListener = 0); 679fde3f3061d665babeb78443119a09876098fc35eChris Lattner void ReplaceAllUsesWith(SDNode *From, SDNode *To, 680f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner DAGUpdateListener *UpdateListener = 0); 681475871a144eb604ddaf37503397ba0941442e5fbDan Gohman void ReplaceAllUsesWith(SDNode *From, const SDValue *To, 682f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner DAGUpdateListener *UpdateListener = 0); 683fae9f1cb34d6d2c4dbd007f2d748a70b67776a82Evan Cheng 68480274268b99e5a066825c8cc5aba58dbc5ad0a52Chris Lattner /// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving 685f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner /// uses of other values produced by From.Val alone. 686475871a144eb604ddaf37503397ba0941442e5fbDan Gohman void ReplaceAllUsesOfValueWith(SDValue From, SDValue To, 687f8dc0617baceeba8ccd67c8881eb88eb1be2902cChris Lattner DAGUpdateListener *UpdateListener = 0); 68880274268b99e5a066825c8cc5aba58dbc5ad0a52Chris Lattner 689e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// ReplaceAllUsesOfValuesWith - Like ReplaceAllUsesOfValueWith, but 690e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// for multiple values at once. This correctly handles the case where 691e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman /// there is an overlap between the From values and the To values. 692475871a144eb604ddaf37503397ba0941442e5fbDan Gohman void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, 693e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman unsigned Num, 694e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman DAGUpdateListener *UpdateListener = 0); 695e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman 696f06c835f769aa1cf67801ed1f6bd366a447c18b1Dan Gohman /// AssignTopologicalOrder - Topological-sort the AllNodes list and a 697f06c835f769aa1cf67801ed1f6bd366a447c18b1Dan Gohman /// assign a unique node id for each node in the DAG based on their 698f06c835f769aa1cf67801ed1f6bd366a447c18b1Dan Gohman /// topological order. Returns the number of nodes. 699f06c835f769aa1cf67801ed1f6bd366a447c18b1Dan Gohman unsigned AssignTopologicalOrder(); 700e6f35d8a5cc92d776cf460200e2b815e8c301b14Evan Cheng 7018be6bbe5bfd50945ac6c5542e0f54a0924a5db8dDan Gohman /// RepositionNode - Move node N in the AllNodes list to be immediately 7028be6bbe5bfd50945ac6c5542e0f54a0924a5db8dDan Gohman /// before the given iterator Position. This may be used to update the 7038be6bbe5bfd50945ac6c5542e0f54a0924a5db8dDan Gohman /// topological ordering when the list of nodes is modified. 7048be6bbe5bfd50945ac6c5542e0f54a0924a5db8dDan Gohman void RepositionNode(allnodes_iterator Position, SDNode *N) { 7058be6bbe5bfd50945ac6c5542e0f54a0924a5db8dDan Gohman AllNodes.insert(Position, AllNodes.remove(N)); 7068be6bbe5bfd50945ac6c5542e0f54a0924a5db8dDan Gohman } 7078be6bbe5bfd50945ac6c5542e0f54a0924a5db8dDan Gohman 7081efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng /// isCommutativeBinOp - Returns true if the opcode is a commutative binary 7091efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng /// operation. 7101efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng static bool isCommutativeBinOp(unsigned Opcode) { 7114ae9e0c5301126d7f2d4b2975eb86ed21f7b574dChris Lattner // FIXME: This should get its info from the td file, so that we can include 7124ae9e0c5301126d7f2d4b2975eb86ed21f7b574dChris Lattner // target info. 7131efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng switch (Opcode) { 7141efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::ADD: 7151efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::MUL: 7161efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::MULHU: 7171efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::MULHS: 718b6c7437568f0472548ede2710458f52cfad4532eDan Gohman case ISD::SMUL_LOHI: 719b6c7437568f0472548ede2710458f52cfad4532eDan Gohman case ISD::UMUL_LOHI: 7201efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::FADD: 7211efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::FMUL: 7221efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::AND: 7231efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::OR: 7241efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::XOR: 7251efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::ADDC: 7261efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng case ISD::ADDE: return true; 7271efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng default: return false; 7281efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng } 7291efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng } 7301efba0ecb4d0b3807c48e6e0f74e3ce5c9fad809Evan Cheng 731cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner void dump() const; 732d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattner 73337ce9df0da6cddc3b8bfef9b63d33d058a0f2f15Chris Lattner /// CreateStackTemporary - Create a stack temporary, suitable for holding the 734364d73ddab43b699ab90240f11b7a2eb5cf69bd8Mon P Wang /// specified value type. If minAlign is specified, the slot size will have 735364d73ddab43b699ab90240f11b7a2eb5cf69bd8Mon P Wang /// at least that alignment. 736475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue CreateStackTemporary(MVT VT, unsigned minAlign = 1); 737364d73ddab43b699ab90240f11b7a2eb5cf69bd8Mon P Wang 738f3cbca279db891403659208a99f8e1cceb8c9ea6Bill Wendling /// FoldConstantArithmetic - 739f3cbca279db891403659208a99f8e1cceb8c9ea6Bill Wendling SDValue FoldConstantArithmetic(unsigned Opcode, 740f3cbca279db891403659208a99f8e1cceb8c9ea6Bill Wendling MVT VT, 741f3cbca279db891403659208a99f8e1cceb8c9ea6Bill Wendling ConstantSDNode *Cst1, 742f3cbca279db891403659208a99f8e1cceb8c9ea6Bill Wendling ConstantSDNode *Cst2); 743f3cbca279db891403659208a99f8e1cceb8c9ea6Bill Wendling 74451dabfb28375be7bc5848806ae31cd068b6133f8Chris Lattner /// FoldSetCC - Constant fold a setcc to true or false. 745475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue FoldSetCC(MVT VT, SDValue N1, 746f3cbca279db891403659208a99f8e1cceb8c9ea6Bill Wendling SDValue N2, ISD::CondCode Cond); 74751dabfb28375be7bc5848806ae31cd068b6133f8Chris Lattner 7482e68b6f52d0979575b2f02ed29717d907ba0684cDan Gohman /// SignBitIsZero - Return true if the sign bit of Op is known to be zero. We 7492e68b6f52d0979575b2f02ed29717d907ba0684cDan Gohman /// use this predicate to simplify operations downstream. 750475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const; 7512e68b6f52d0979575b2f02ed29717d907ba0684cDan Gohman 752ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero. We 753ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// use this predicate to simplify operations downstream. Op and Mask are 754ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// known to be the same type. 755475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth = 0) 756ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman const; 757ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman 758ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// ComputeMaskedBits - Determine which of the bits specified in Mask are 759ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// known to be either zero or one and return them in the KnownZero/KnownOne 760ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// bitsets. This code only analyzes bits in Mask, in order to short-circuit 761ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// processing. Targets can implement the computeMaskedBitsForTargetNode 762ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// method in the TargetLowering class to allow target nodes to be understood. 763475871a144eb604ddaf37503397ba0941442e5fbDan Gohman void ComputeMaskedBits(SDValue Op, const APInt &Mask, APInt &KnownZero, 764fd29e0eb060ea8b4d490860329234d2ae5f5952eDan Gohman APInt &KnownOne, unsigned Depth = 0) const; 765fd29e0eb060ea8b4d490860329234d2ae5f5952eDan Gohman 766ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// ComputeNumSignBits - Return the number of times the sign bit of the 767ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// register is replicated into the other bits. We know that at least 1 bit 768ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// is always equal to the sign bit (itself), but other cases can give us 769ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// information. For example, immediately after an "SRA X, 2", we know that 770ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// the top 3 bits are all equal to each other, so we return 3. Targets can 771ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// implement the ComputeNumSignBitsForTarget method in the TargetLowering 772ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman /// class to allow target nodes to be understood. 773475871a144eb604ddaf37503397ba0941442e5fbDan Gohman unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const; 774a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng 775475871a144eb604ddaf37503397ba0941442e5fbDan Gohman /// isVerifiedDebugInfoDesc - Returns true if the specified SDValue has 776a844bdeab31ef04221e7ef59a8467893584cc14dEvan Cheng /// been verified as a debug information descriptor. 777475871a144eb604ddaf37503397ba0941442e5fbDan Gohman bool isVerifiedDebugInfoDesc(SDValue Op) const; 77877f0b7a50a08614b5ffd58f1864b68a9a30d0cb0Evan Cheng 77977f0b7a50a08614b5ffd58f1864b68a9a30d0cb0Evan Cheng /// getShuffleScalarElt - Returns the scalar element that will make up the ith 78077f0b7a50a08614b5ffd58f1864b68a9a30d0cb0Evan Cheng /// element of the result of the vector shuffle. 781475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDValue getShuffleScalarElt(const SDNode *N, unsigned Idx); 782ea859be53ca13a1547c4675549946b74dc3c6f41Dan Gohman 783d1fc96499b7619356c7542200d32da898b79f7c1Chris Lattnerprivate: 784095cc29f321382e1f7d295e262a28197f92c5491Dan Gohman bool RemoveNodeFromCSEMaps(SDNode *N); 7856542d950609208de3e1cde704c5f89aad864c0d9Chris Lattner SDNode *AddNonLeafNodeToCSEMaps(SDNode *N); 786475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos); 787475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2, 788a5682853b9921bbb0dd2ee175c9bd44142d4819eChris Lattner void *&InsertPos); 789475871a144eb604ddaf37503397ba0941442e5fbDan Gohman SDNode *FindModifiedNodeSlot(SDNode *N, const SDValue *Ops, unsigned NumOps, 790a5682853b9921bbb0dd2ee175c9bd44142d4819eChris Lattner void *&InsertPos); 791b9aff659e82e4ec1a507e6e7fe7969379a431613Chris Lattner 792fde3f3061d665babeb78443119a09876098fc35eChris Lattner void DeleteNodeNotInCSEMaps(SDNode *N); 7939c6e70eca9a49c146b26621cbcbb9464ceeac024Dan Gohman 7949c6e70eca9a49c146b26621cbcbb9464ceeac024Dan Gohman unsigned getMVTAlignment(MVT MemoryVT) const; 795f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman 796f350b277f32d7d47f86c0e54f4aec4d470500618Dan Gohman void allnodes_clear(); 7977cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner 798109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner // List of non-single value types. 799e8be6c63915e0389f1eef6b53c64300d13b2ce99Dan Gohman std::vector<SDVTList> VTList; 800109654fae9c5b8b96bd3a829824cdbceb27ced06Chris Lattner 8011cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner // Maps to auto-CSE operations. 8027cf7e3f33f25544d08492d47cc8a1cbba25dc8d7Chris Lattner std::vector<CondCodeSDNode*> CondCodeNodes; 8031cff05c7c216eea0e9173738c2a60b70c2b3c013Chris Lattner 80415e4b01920d6a0ffbe35d3e5aa88a4b42970b6a7Chris Lattner std::vector<SDNode*> ValueTypeNodes; 8058e4eb09b1e3571965f49edcdfb56b1375b1b7551Duncan Sands std::map<MVT, SDNode*, MVT::compareRawBits> ExtendedValueTypeNodes; 806056292fd738924f3f7703725d8f630983794b5a5Bill Wendling StringMap<SDNode*> ExternalSymbols; 807056292fd738924f3f7703725d8f630983794b5a5Bill Wendling StringMap<SDNode*> TargetExternalSymbols; 808cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner}; 809cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 8101080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattnertemplate <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> { 8111080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner typedef SelectionDAG::allnodes_iterator nodes_iterator; 8121080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static nodes_iterator nodes_begin(SelectionDAG *G) { 8131080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return G->allnodes_begin(); 8141080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 8151080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner static nodes_iterator nodes_end(SelectionDAG *G) { 8161080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner return G->allnodes_end(); 8171080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner } 8181080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner}; 8191080b9ee534579c67f7c99364cc6fa11edbcd919Chris Lattner 820b80e2be8894db9f843f32ebaffb9b7fd6b57d206Chris Lattner} // end namespace llvm 821cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner 822cacf462915344c2af25eef1af1f3ee2c7280ff56Chris Lattner#endif 823