1193323Sed//===-- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ---------*- C++ -*-===// 2193323Sed// 3193323Sed// The LLVM Compiler Infrastructure 4193323Sed// 5193323Sed// This file is distributed under the University of Illinois Open Source 6193323Sed// License. See LICENSE.TXT for details. 7193323Sed// 8193323Sed//===----------------------------------------------------------------------===// 9193323Sed// 10193323Sed// This file declares the SelectionDAG class, and transitively defines the 11193323Sed// SDNode class and subclasses. 12193323Sed// 13193323Sed//===----------------------------------------------------------------------===// 14193323Sed 15193323Sed#ifndef LLVM_CODEGEN_SELECTIONDAG_H 16193323Sed#define LLVM_CODEGEN_SELECTIONDAG_H 17193323Sed 18193323Sed#include "llvm/ADT/DenseSet.h" 19193323Sed#include "llvm/ADT/StringMap.h" 20249423Sdim#include "llvm/ADT/ilist.h" 21249423Sdim#include "llvm/CodeGen/DAGCombine.h" 22193323Sed#include "llvm/CodeGen/SelectionDAGNodes.h" 23198090Srdivacky#include "llvm/Support/RecyclingAllocator.h" 24193323Sed#include "llvm/Target/TargetMachine.h" 25193323Sed#include <cassert> 26193323Sed#include <map> 27193323Sed#include <string> 28249423Sdim#include <vector> 29193323Sed 30193323Sednamespace llvm { 31193323Sed 32193323Sedclass AliasAnalysis; 33201360Srdivackyclass MachineConstantPoolValue; 34193323Sedclass MachineFunction; 35206083Srdivackyclass MDNode; 36205218Srdivackyclass SDDbgValue; 37201360Srdivackyclass TargetLowering; 38208599Srdivackyclass TargetSelectionDAGInfo; 39249423Sdimclass TargetTransformInfo; 40193323Sed 41263508Sdimclass SDVTListNode : public FoldingSetNode { 42263508Sdim friend struct FoldingSetTrait<SDVTListNode>; 43263508Sdim /// FastID - A reference to an Interned FoldingSetNodeID for this node. 44263508Sdim /// The Allocator in SelectionDAG holds the data. 45263508Sdim /// SDVTList contains all types which are frequently accessed in SelectionDAG. 46263508Sdim /// The size of this list is not expected big so it won't introduce memory penalty. 47263508Sdim FoldingSetNodeIDRef FastID; 48263508Sdim const EVT *VTs; 49263508Sdim unsigned int NumVTs; 50263508Sdim /// The hash value for SDVTList is fixed so cache it to avoid hash calculation 51263508Sdim unsigned HashValue; 52263508Sdimpublic: 53263508Sdim SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num) : 54263508Sdim FastID(ID), VTs(VT), NumVTs(Num) { 55263508Sdim HashValue = ID.ComputeHash(); 56263508Sdim } 57263508Sdim SDVTList getSDVTList() { 58263508Sdim SDVTList result = {VTs, NumVTs}; 59263508Sdim return result; 60263508Sdim } 61263508Sdim}; 62263508Sdim 63263508Sdim// Specialize FoldingSetTrait for SDVTListNode 64263508Sdim// To avoid computing temp FoldingSetNodeID and hash value. 65263508Sdimtemplate<> struct FoldingSetTrait<SDVTListNode> : DefaultFoldingSetTrait<SDVTListNode> { 66263508Sdim static void Profile(const SDVTListNode &X, FoldingSetNodeID& ID) { 67263508Sdim ID = X.FastID; 68263508Sdim } 69263508Sdim static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID, 70263508Sdim unsigned IDHash, FoldingSetNodeID &TempID) { 71263508Sdim if (X.HashValue != IDHash) 72263508Sdim return false; 73263508Sdim return ID == X.FastID; 74263508Sdim } 75263508Sdim static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID) { 76263508Sdim return X.HashValue; 77263508Sdim } 78263508Sdim}; 79263508Sdim 80193323Sedtemplate<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> { 81193323Sedprivate: 82198090Srdivacky mutable ilist_half_node<SDNode> Sentinel; 83193323Sedpublic: 84193323Sed SDNode *createSentinel() const { 85193323Sed return static_cast<SDNode*>(&Sentinel); 86193323Sed } 87193323Sed static void destroySentinel(SDNode *) {} 88193323Sed 89193323Sed SDNode *provideInitialHead() const { return createSentinel(); } 90193323Sed SDNode *ensureHead(SDNode*) const { return createSentinel(); } 91193323Sed static void noteHead(SDNode*, SDNode*) {} 92193323Sed 93193323Sed static void deleteNode(SDNode *) { 94234353Sdim llvm_unreachable("ilist_traits<SDNode> shouldn't see a deleteNode call!"); 95193323Sed } 96193323Sedprivate: 97193323Sed static void createNode(const SDNode &); 98193323Sed}; 99193323Sed 100205218Srdivacky/// SDDbgInfo - Keeps track of dbg_value information through SDISel. We do 101205218Srdivacky/// not build SDNodes for these so as not to perturb the generated code; 102206083Srdivacky/// instead the info is kept off to the side in this structure. Each SDNode may 103206083Srdivacky/// have one or more associated dbg_value entries. This information is kept in 104206083Srdivacky/// DbgValMap. 105207618Srdivacky/// Byval parameters are handled separately because they don't use alloca's, 106207618Srdivacky/// which busts the normal mechanism. There is good reason for handling all 107207618Srdivacky/// parameters separately: they may not have code generated for them, they 108207618Srdivacky/// should always go at the beginning of the function regardless of other code 109207618Srdivacky/// motion, and debug info for them is potentially useful even if the parameter 110207618Srdivacky/// is unused. Right now only byval parameters are handled separately. 111205218Srdivackyclass SDDbgInfo { 112206083Srdivacky SmallVector<SDDbgValue*, 32> DbgValues; 113207618Srdivacky SmallVector<SDDbgValue*, 32> ByvalParmDbgValues; 114263508Sdim typedef DenseMap<const SDNode*, SmallVector<SDDbgValue*, 2> > DbgValMapType; 115263508Sdim DbgValMapType DbgValMap; 116205218Srdivacky 117243830Sdim void operator=(const SDDbgInfo&) LLVM_DELETED_FUNCTION; 118243830Sdim SDDbgInfo(const SDDbgInfo&) LLVM_DELETED_FUNCTION; 119205218Srdivackypublic: 120205218Srdivacky SDDbgInfo() {} 121205218Srdivacky 122207618Srdivacky void add(SDDbgValue *V, const SDNode *Node, bool isParameter) { 123207618Srdivacky if (isParameter) { 124207618Srdivacky ByvalParmDbgValues.push_back(V); 125207618Srdivacky } else DbgValues.push_back(V); 126206083Srdivacky if (Node) 127206083Srdivacky DbgValMap[Node].push_back(V); 128205218Srdivacky } 129206083Srdivacky 130274696Sdim /// \brief Invalidate all DbgValues attached to the node and remove 131274696Sdim /// it from the Node-to-DbgValues map. 132274696Sdim void erase(const SDNode *Node); 133274696Sdim 134205218Srdivacky void clear() { 135206083Srdivacky DbgValMap.clear(); 136206083Srdivacky DbgValues.clear(); 137207618Srdivacky ByvalParmDbgValues.clear(); 138205218Srdivacky } 139206083Srdivacky 140206083Srdivacky bool empty() const { 141207618Srdivacky return DbgValues.empty() && ByvalParmDbgValues.empty(); 142205218Srdivacky } 143206083Srdivacky 144224145Sdim ArrayRef<SDDbgValue*> getSDDbgValues(const SDNode *Node) { 145263508Sdim DbgValMapType::iterator I = DbgValMap.find(Node); 146224145Sdim if (I != DbgValMap.end()) 147224145Sdim return I->second; 148224145Sdim return ArrayRef<SDDbgValue*>(); 149206083Srdivacky } 150206083Srdivacky 151263508Sdim typedef SmallVectorImpl<SDDbgValue*>::iterator DbgIterator; 152206083Srdivacky DbgIterator DbgBegin() { return DbgValues.begin(); } 153206083Srdivacky DbgIterator DbgEnd() { return DbgValues.end(); } 154207618Srdivacky DbgIterator ByvalParmDbgBegin() { return ByvalParmDbgValues.begin(); } 155207618Srdivacky DbgIterator ByvalParmDbgEnd() { return ByvalParmDbgValues.end(); } 156205218Srdivacky}; 157205218Srdivacky 158202878Srdivackyclass SelectionDAG; 159202878Srdivackyvoid checkForCycles(const SDNode *N); 160202878Srdivackyvoid checkForCycles(const SelectionDAG *DAG); 161202878Srdivacky 162193323Sed/// SelectionDAG class - This is used to represent a portion of an LLVM function 163193323Sed/// in a low-level Data Dependence DAG representation suitable for instruction 164193323Sed/// selection. This DAG is constructed as the first step of instruction 165193323Sed/// selection in order to allow implementation of machine specific optimizations 166193323Sed/// and code simplifications. 167193323Sed/// 168193323Sed/// The representation used by the SelectionDAG is a target-independent 169193323Sed/// representation, which has some similarities to the GCC RTL representation, 170193323Sed/// but is significantly more simple, powerful, and is a graph form instead of a 171193323Sed/// linear form. 172193323Sed/// 173193323Sedclass SelectionDAG { 174207618Srdivacky const TargetMachine &TM; 175208599Srdivacky const TargetSelectionDAGInfo &TSI; 176249423Sdim const TargetTransformInfo *TTI; 177263508Sdim const TargetLowering *TLI; 178193323Sed MachineFunction *MF; 179206274Srdivacky LLVMContext *Context; 180234353Sdim CodeGenOpt::Level OptLevel; 181193323Sed 182193323Sed /// EntryNode - The starting token. 183193323Sed SDNode EntryNode; 184193323Sed 185193323Sed /// Root - The root of the entire DAG. 186193323Sed SDValue Root; 187193323Sed 188193323Sed /// AllNodes - A linked list of nodes in the current DAG. 189193323Sed ilist<SDNode> AllNodes; 190193323Sed 191193323Sed /// NodeAllocatorType - The AllocatorType for allocating SDNodes. We use 192193323Sed /// pool allocation with recycling. 193193323Sed typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode), 194193323Sed AlignOf<MostAlignedSDNode>::Alignment> 195193323Sed NodeAllocatorType; 196193323Sed 197193323Sed /// NodeAllocator - Pool allocation for nodes. 198193323Sed NodeAllocatorType NodeAllocator; 199193323Sed 200193323Sed /// CSEMap - This structure is used to memoize nodes, automatically performing 201198090Srdivacky /// CSE with existing nodes when a duplicate is requested. 202193323Sed FoldingSet<SDNode> CSEMap; 203193323Sed 204193323Sed /// OperandAllocator - Pool allocation for machine-opcode SDNode operands. 205193323Sed BumpPtrAllocator OperandAllocator; 206193323Sed 207193323Sed /// Allocator - Pool allocation for misc. objects that are created once per 208193323Sed /// SelectionDAG. 209193323Sed BumpPtrAllocator Allocator; 210193323Sed 211205218Srdivacky /// DbgInfo - Tracks dbg_value information through SDISel. 212205218Srdivacky SDDbgInfo *DbgInfo; 213205218Srdivacky 214239462Sdimpublic: 215239462Sdim /// DAGUpdateListener - Clients of various APIs that cause global effects on 216239462Sdim /// the DAG can optionally implement this interface. This allows the clients 217239462Sdim /// to handle the various sorts of updates that happen. 218239462Sdim /// 219239462Sdim /// A DAGUpdateListener automatically registers itself with DAG when it is 220239462Sdim /// constructed, and removes itself when destroyed in RAII fashion. 221239462Sdim struct DAGUpdateListener { 222239462Sdim DAGUpdateListener *const Next; 223239462Sdim SelectionDAG &DAG; 224239462Sdim 225239462Sdim explicit DAGUpdateListener(SelectionDAG &D) 226239462Sdim : Next(D.UpdateListeners), DAG(D) { 227239462Sdim DAG.UpdateListeners = this; 228239462Sdim } 229239462Sdim 230239462Sdim virtual ~DAGUpdateListener() { 231239462Sdim assert(DAG.UpdateListeners == this && 232239462Sdim "DAGUpdateListeners must be destroyed in LIFO order"); 233239462Sdim DAG.UpdateListeners = Next; 234239462Sdim } 235239462Sdim 236239462Sdim /// NodeDeleted - The node N that was deleted and, if E is not null, an 237239462Sdim /// equivalent node E that replaced it. 238239462Sdim virtual void NodeDeleted(SDNode *N, SDNode *E); 239239462Sdim 240239462Sdim /// NodeUpdated - The node N that was updated. 241239462Sdim virtual void NodeUpdated(SDNode *N); 242239462Sdim }; 243239462Sdim 244263508Sdim /// NewNodesMustHaveLegalTypes - When true, additional steps are taken to 245263508Sdim /// ensure that getConstant() and similar functions return DAG nodes that 246263508Sdim /// have legal types. This is important after type legalization since 247263508Sdim /// any illegally typed nodes generated after this point will not experience 248263508Sdim /// type legalization. 249263508Sdim bool NewNodesMustHaveLegalTypes; 250263508Sdim 251239462Sdimprivate: 252239462Sdim /// DAGUpdateListener is a friend so it can manipulate the listener stack. 253239462Sdim friend struct DAGUpdateListener; 254239462Sdim 255239462Sdim /// UpdateListeners - Linked list of registered DAGUpdateListener instances. 256239462Sdim /// This stack is maintained by DAGUpdateListener RAII. 257239462Sdim DAGUpdateListener *UpdateListeners; 258239462Sdim 259193323Sed /// setGraphColorHelper - Implementation of setSubgraphColor. 260193323Sed /// Return whether we had to truncate the search. 261193323Sed /// 262193323Sed bool setSubgraphColorHelper(SDNode *N, const char *Color, 263193323Sed DenseSet<SDNode *> &visited, 264193323Sed int level, bool &printed); 265193323Sed 266243830Sdim void operator=(const SelectionDAG&) LLVM_DELETED_FUNCTION; 267243830Sdim SelectionDAG(const SelectionDAG&) LLVM_DELETED_FUNCTION; 268200581Srdivacky 269193323Sedpublic: 270234353Sdim explicit SelectionDAG(const TargetMachine &TM, llvm::CodeGenOpt::Level); 271193323Sed ~SelectionDAG(); 272193323Sed 273193323Sed /// init - Prepare this SelectionDAG to process code in the given 274193323Sed /// MachineFunction. 275193323Sed /// 276263508Sdim void init(MachineFunction &mf, const TargetTransformInfo *TTI, 277263508Sdim const TargetLowering *TLI); 278193323Sed 279193323Sed /// clear - Clear state and free memory necessary to make this 280193323Sed /// SelectionDAG ready to process a new block. 281193323Sed /// 282193323Sed void clear(); 283193323Sed 284193323Sed MachineFunction &getMachineFunction() const { return *MF; } 285207618Srdivacky const TargetMachine &getTarget() const { return TM; } 286263508Sdim const TargetLowering &getTargetLoweringInfo() const { return *TLI; } 287208599Srdivacky const TargetSelectionDAGInfo &getSelectionDAGInfo() const { return TSI; } 288249423Sdim const TargetTransformInfo *getTargetTransformInfo() const { return TTI; } 289198090Srdivacky LLVMContext *getContext() const {return Context; } 290193323Sed 291193323Sed /// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'. 292193323Sed /// 293193323Sed void viewGraph(const std::string &Title); 294193323Sed void viewGraph(); 295193323Sed 296193323Sed#ifndef NDEBUG 297193323Sed std::map<const SDNode *, std::string> NodeGraphAttrs; 298193323Sed#endif 299193323Sed 300193323Sed /// clearGraphAttrs - Clear all previously defined node graph attributes. 301193323Sed /// Intended to be used from a debugging tool (eg. gdb). 302193323Sed void clearGraphAttrs(); 303193323Sed 304193323Sed /// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".) 305193323Sed /// 306193323Sed void setGraphAttrs(const SDNode *N, const char *Attrs); 307193323Sed 308193323Sed /// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".) 309193323Sed /// Used from getNodeAttributes. 310193323Sed const std::string getGraphAttrs(const SDNode *N) const; 311193323Sed 312193323Sed /// setGraphColor - Convenience for setting node color attribute. 313193323Sed /// 314193323Sed void setGraphColor(const SDNode *N, const char *Color); 315193323Sed 316193323Sed /// setGraphColor - Convenience for setting subgraph color attribute. 317193323Sed /// 318193323Sed void setSubgraphColor(SDNode *N, const char *Color); 319193323Sed 320193323Sed typedef ilist<SDNode>::const_iterator allnodes_const_iterator; 321193323Sed allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); } 322193323Sed allnodes_const_iterator allnodes_end() const { return AllNodes.end(); } 323193323Sed typedef ilist<SDNode>::iterator allnodes_iterator; 324193323Sed allnodes_iterator allnodes_begin() { return AllNodes.begin(); } 325193323Sed allnodes_iterator allnodes_end() { return AllNodes.end(); } 326193323Sed ilist<SDNode>::size_type allnodes_size() const { 327193323Sed return AllNodes.size(); 328193323Sed } 329193323Sed 330193323Sed /// getRoot - Return the root tag of the SelectionDAG. 331193323Sed /// 332193323Sed const SDValue &getRoot() const { return Root; } 333193323Sed 334193323Sed /// getEntryNode - Return the token chain corresponding to the entry of the 335193323Sed /// function. 336193323Sed SDValue getEntryNode() const { 337193323Sed return SDValue(const_cast<SDNode *>(&EntryNode), 0); 338193323Sed } 339193323Sed 340193323Sed /// setRoot - Set the current root tag of the SelectionDAG. 341193323Sed /// 342193323Sed const SDValue &setRoot(SDValue N) { 343193323Sed assert((!N.getNode() || N.getValueType() == MVT::Other) && 344193323Sed "DAG root value is not a chain!"); 345202878Srdivacky if (N.getNode()) 346202878Srdivacky checkForCycles(N.getNode()); 347202878Srdivacky Root = N; 348202878Srdivacky if (N.getNode()) 349202878Srdivacky checkForCycles(this); 350202878Srdivacky return Root; 351193323Sed } 352193323Sed 353193323Sed /// Combine - This iterates over the nodes in the SelectionDAG, folding 354193323Sed /// certain types of nodes together, or eliminating superfluous nodes. The 355193323Sed /// Level argument controls whether Combine is allowed to produce nodes and 356193323Sed /// types that are illegal on the target. 357193323Sed void Combine(CombineLevel Level, AliasAnalysis &AA, 358193323Sed CodeGenOpt::Level OptLevel); 359193323Sed 360193323Sed /// LegalizeTypes - This transforms the SelectionDAG into a SelectionDAG that 361193323Sed /// only uses types natively supported by the target. Returns "true" if it 362193323Sed /// made any changes. 363193323Sed /// 364193323Sed /// Note that this is an involved process that may invalidate pointers into 365193323Sed /// the graph. 366193323Sed bool LegalizeTypes(); 367193323Sed 368193323Sed /// Legalize - This transforms the SelectionDAG into a SelectionDAG that is 369193323Sed /// compatible with the target instruction selector, as indicated by the 370193323Sed /// TargetLowering object. 371193323Sed /// 372193323Sed /// Note that this is an involved process that may invalidate pointers into 373193323Sed /// the graph. 374223017Sdim void Legalize(); 375193323Sed 376193323Sed /// LegalizeVectors - This transforms the SelectionDAG into a SelectionDAG 377193323Sed /// that only uses vector math operations supported by the target. This is 378193323Sed /// necessary as a separate step from Legalize because unrolling a vector 379193323Sed /// operation can introduce illegal types, which requires running 380193323Sed /// LegalizeTypes again. 381193323Sed /// 382193323Sed /// This returns true if it made any changes; in that case, LegalizeTypes 383193323Sed /// is called again before Legalize. 384193323Sed /// 385193323Sed /// Note that this is an involved process that may invalidate pointers into 386193323Sed /// the graph. 387193323Sed bool LegalizeVectors(); 388193323Sed 389193323Sed /// RemoveDeadNodes - This method deletes all unreachable nodes in the 390193323Sed /// SelectionDAG. 391193323Sed void RemoveDeadNodes(); 392193323Sed 393193323Sed /// DeleteNode - Remove the specified node from the system. This node must 394193323Sed /// have no referrers. 395193323Sed void DeleteNode(SDNode *N); 396193323Sed 397193323Sed /// getVTList - Return an SDVTList that represents the list of values 398193323Sed /// specified. 399198090Srdivacky SDVTList getVTList(EVT VT); 400198090Srdivacky SDVTList getVTList(EVT VT1, EVT VT2); 401198090Srdivacky SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3); 402198090Srdivacky SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3, EVT VT4); 403198090Srdivacky SDVTList getVTList(const EVT *VTs, unsigned NumVTs); 404193323Sed 405193323Sed //===--------------------------------------------------------------------===// 406193323Sed // Node creation methods. 407193323Sed // 408198090Srdivacky SDValue getConstant(uint64_t Val, EVT VT, bool isTarget = false); 409198090Srdivacky SDValue getConstant(const APInt &Val, EVT VT, bool isTarget = false); 410198090Srdivacky SDValue getConstant(const ConstantInt &Val, EVT VT, bool isTarget = false); 411193323Sed SDValue getIntPtrConstant(uint64_t Val, bool isTarget = false); 412198090Srdivacky SDValue getTargetConstant(uint64_t Val, EVT VT) { 413193323Sed return getConstant(Val, VT, true); 414193323Sed } 415198090Srdivacky SDValue getTargetConstant(const APInt &Val, EVT VT) { 416193323Sed return getConstant(Val, VT, true); 417193323Sed } 418198090Srdivacky SDValue getTargetConstant(const ConstantInt &Val, EVT VT) { 419193323Sed return getConstant(Val, VT, true); 420193323Sed } 421208599Srdivacky // The forms below that take a double should only be used for simple 422208599Srdivacky // constants that can be exactly represented in VT. No checks are made. 423198090Srdivacky SDValue getConstantFP(double Val, EVT VT, bool isTarget = false); 424198090Srdivacky SDValue getConstantFP(const APFloat& Val, EVT VT, bool isTarget = false); 425198090Srdivacky SDValue getConstantFP(const ConstantFP &CF, EVT VT, bool isTarget = false); 426198090Srdivacky SDValue getTargetConstantFP(double Val, EVT VT) { 427193323Sed return getConstantFP(Val, VT, true); 428193323Sed } 429198090Srdivacky SDValue getTargetConstantFP(const APFloat& Val, EVT VT) { 430193323Sed return getConstantFP(Val, VT, true); 431193323Sed } 432198090Srdivacky SDValue getTargetConstantFP(const ConstantFP &Val, EVT VT) { 433193323Sed return getConstantFP(Val, VT, true); 434193323Sed } 435263508Sdim SDValue getGlobalAddress(const GlobalValue *GV, SDLoc DL, EVT VT, 436195098Sed int64_t offset = 0, bool isTargetGA = false, 437195098Sed unsigned char TargetFlags = 0); 438263508Sdim SDValue getTargetGlobalAddress(const GlobalValue *GV, SDLoc DL, EVT VT, 439195098Sed int64_t offset = 0, 440195098Sed unsigned char TargetFlags = 0) { 441210299Sed return getGlobalAddress(GV, DL, VT, offset, true, TargetFlags); 442193323Sed } 443198090Srdivacky SDValue getFrameIndex(int FI, EVT VT, bool isTarget = false); 444198090Srdivacky SDValue getTargetFrameIndex(int FI, EVT VT) { 445193323Sed return getFrameIndex(FI, VT, true); 446193323Sed } 447198090Srdivacky SDValue getJumpTable(int JTI, EVT VT, bool isTarget = false, 448195098Sed unsigned char TargetFlags = 0); 449198090Srdivacky SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags = 0) { 450195098Sed return getJumpTable(JTI, VT, true, TargetFlags); 451193323Sed } 452207618Srdivacky SDValue getConstantPool(const Constant *C, EVT VT, 453195098Sed unsigned Align = 0, int Offs = 0, bool isT=false, 454195098Sed unsigned char TargetFlags = 0); 455207618Srdivacky SDValue getTargetConstantPool(const Constant *C, EVT VT, 456195098Sed unsigned Align = 0, int Offset = 0, 457195098Sed unsigned char TargetFlags = 0) { 458195098Sed return getConstantPool(C, VT, Align, Offset, true, TargetFlags); 459193323Sed } 460198090Srdivacky SDValue getConstantPool(MachineConstantPoolValue *C, EVT VT, 461195098Sed unsigned Align = 0, int Offs = 0, bool isT=false, 462195098Sed unsigned char TargetFlags = 0); 463193323Sed SDValue getTargetConstantPool(MachineConstantPoolValue *C, 464198090Srdivacky EVT VT, unsigned Align = 0, 465195098Sed int Offset = 0, unsigned char TargetFlags=0) { 466195098Sed return getConstantPool(C, VT, Align, Offset, true, TargetFlags); 467193323Sed } 468239462Sdim SDValue getTargetIndex(int Index, EVT VT, int64_t Offset = 0, 469239462Sdim unsigned char TargetFlags = 0); 470193323Sed // When generating a branch to a BB, we don't in general know enough 471193323Sed // to provide debug info for the BB at that time, so keep this one around. 472193323Sed SDValue getBasicBlock(MachineBasicBlock *MBB); 473263508Sdim SDValue getBasicBlock(MachineBasicBlock *MBB, SDLoc dl); 474198090Srdivacky SDValue getExternalSymbol(const char *Sym, EVT VT); 475263508Sdim SDValue getExternalSymbol(const char *Sym, SDLoc dl, EVT VT); 476198090Srdivacky SDValue getTargetExternalSymbol(const char *Sym, EVT VT, 477195098Sed unsigned char TargetFlags = 0); 478198090Srdivacky SDValue getValueType(EVT); 479198090Srdivacky SDValue getRegister(unsigned Reg, EVT VT); 480234353Sdim SDValue getRegisterMask(const uint32_t *RegMask); 481263508Sdim SDValue getEHLabel(SDLoc dl, SDValue Root, MCSymbol *Label); 482207618Srdivacky SDValue getBlockAddress(const BlockAddress *BA, EVT VT, 483243830Sdim int64_t Offset = 0, bool isTarget = false, 484243830Sdim unsigned char TargetFlags = 0); 485243830Sdim SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, 486243830Sdim int64_t Offset = 0, 487243830Sdim unsigned char TargetFlags = 0) { 488243830Sdim return getBlockAddress(BA, VT, Offset, true, TargetFlags); 489243830Sdim } 490193323Sed 491263508Sdim SDValue getCopyToReg(SDValue Chain, SDLoc dl, unsigned Reg, SDValue N) { 492193323Sed return getNode(ISD::CopyToReg, dl, MVT::Other, Chain, 493193323Sed getRegister(Reg, N.getValueType()), N); 494193323Sed } 495193323Sed 496193323Sed // This version of the getCopyToReg method takes an extra operand, which 497218893Sdim // indicates that there is potentially an incoming glue value (if Glue is not 498218893Sdim // null) and that there should be a glue result. 499263508Sdim SDValue getCopyToReg(SDValue Chain, SDLoc dl, unsigned Reg, SDValue N, 500218893Sdim SDValue Glue) { 501218893Sdim SDVTList VTs = getVTList(MVT::Other, MVT::Glue); 502218893Sdim SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue }; 503218893Sdim return getNode(ISD::CopyToReg, dl, VTs, Ops, Glue.getNode() ? 4 : 3); 504193323Sed } 505193323Sed 506193323Sed // Similar to last getCopyToReg() except parameter Reg is a SDValue 507263508Sdim SDValue getCopyToReg(SDValue Chain, SDLoc dl, SDValue Reg, SDValue N, 508218893Sdim SDValue Glue) { 509218893Sdim SDVTList VTs = getVTList(MVT::Other, MVT::Glue); 510218893Sdim SDValue Ops[] = { Chain, Reg, N, Glue }; 511218893Sdim return getNode(ISD::CopyToReg, dl, VTs, Ops, Glue.getNode() ? 4 : 3); 512193323Sed } 513193323Sed 514263508Sdim SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT) { 515193323Sed SDVTList VTs = getVTList(VT, MVT::Other); 516193323Sed SDValue Ops[] = { Chain, getRegister(Reg, VT) }; 517193323Sed return getNode(ISD::CopyFromReg, dl, VTs, Ops, 2); 518193323Sed } 519193323Sed 520193323Sed // This version of the getCopyFromReg method takes an extra operand, which 521218893Sdim // indicates that there is potentially an incoming glue value (if Glue is not 522218893Sdim // null) and that there should be a glue result. 523263508Sdim SDValue getCopyFromReg(SDValue Chain, SDLoc dl, unsigned Reg, EVT VT, 524218893Sdim SDValue Glue) { 525218893Sdim SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue); 526218893Sdim SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue }; 527218893Sdim return getNode(ISD::CopyFromReg, dl, VTs, Ops, Glue.getNode() ? 3 : 2); 528193323Sed } 529193323Sed 530193323Sed SDValue getCondCode(ISD::CondCode Cond); 531193323Sed 532193323Sed /// Returns the ConvertRndSat Note: Avoid using this node because it may 533193323Sed /// disappear in the future and most targets don't support it. 534263508Sdim SDValue getConvertRndSat(EVT VT, SDLoc dl, SDValue Val, SDValue DTy, 535193323Sed SDValue STy, 536193323Sed SDValue Rnd, SDValue Sat, ISD::CvtCode Code); 537221345Sdim 538193323Sed /// getVectorShuffle - Return an ISD::VECTOR_SHUFFLE node. The number of 539193323Sed /// elements in VT, which must be a vector type, must match the number of 540193323Sed /// mask elements NumElts. A integer mask element equal to -1 is treated as 541193323Sed /// undefined. 542263508Sdim SDValue getVectorShuffle(EVT VT, SDLoc dl, SDValue N1, SDValue N2, 543193323Sed const int *MaskElts); 544193323Sed 545226633Sdim /// getAnyExtOrTrunc - Convert Op, which must be of integer type, to the 546226633Sdim /// integer type VT, by either any-extending or truncating it. 547263508Sdim SDValue getAnyExtOrTrunc(SDValue Op, SDLoc DL, EVT VT); 548226633Sdim 549198090Srdivacky /// getSExtOrTrunc - Convert Op, which must be of integer type, to the 550198090Srdivacky /// integer type VT, by either sign-extending or truncating it. 551263508Sdim SDValue getSExtOrTrunc(SDValue Op, SDLoc DL, EVT VT); 552198090Srdivacky 553198090Srdivacky /// getZExtOrTrunc - Convert Op, which must be of integer type, to the 554198090Srdivacky /// integer type VT, by either zero-extending or truncating it. 555263508Sdim SDValue getZExtOrTrunc(SDValue Op, SDLoc DL, EVT VT); 556198090Srdivacky 557193323Sed /// getZeroExtendInReg - Return the expression required to zero extend the Op 558193323Sed /// value assuming it was the smaller SrcTy value. 559263508Sdim SDValue getZeroExtendInReg(SDValue Op, SDLoc DL, EVT SrcTy); 560193323Sed 561193323Sed /// getNOT - Create a bitwise NOT operation as (XOR Val, -1). 562263508Sdim SDValue getNOT(SDLoc DL, SDValue Val, EVT VT); 563193323Sed 564193323Sed /// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have 565218893Sdim /// a glue result (to ensure it's not CSE'd). CALLSEQ_START does not have a 566263508Sdim /// useful SDLoc. 567263508Sdim SDValue getCALLSEQ_START(SDValue Chain, SDValue Op, SDLoc DL) { 568218893Sdim SDVTList VTs = getVTList(MVT::Other, MVT::Glue); 569193323Sed SDValue Ops[] = { Chain, Op }; 570263508Sdim return getNode(ISD::CALLSEQ_START, DL, VTs, Ops, 2); 571193323Sed } 572193323Sed 573193323Sed /// getCALLSEQ_END - Return a new CALLSEQ_END node, which always must have a 574218893Sdim /// glue result (to ensure it's not CSE'd). CALLSEQ_END does not have 575263508Sdim /// a useful SDLoc. 576193323Sed SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, 577263508Sdim SDValue InGlue, SDLoc DL) { 578218893Sdim SDVTList NodeTys = getVTList(MVT::Other, MVT::Glue); 579193323Sed SmallVector<SDValue, 4> Ops; 580193323Sed Ops.push_back(Chain); 581193323Sed Ops.push_back(Op1); 582193323Sed Ops.push_back(Op2); 583218893Sdim Ops.push_back(InGlue); 584263508Sdim return getNode(ISD::CALLSEQ_END, DL, NodeTys, &Ops[0], 585218893Sdim (unsigned)Ops.size() - (InGlue.getNode() == 0 ? 1 : 0)); 586193323Sed } 587193323Sed 588263508Sdim /// getUNDEF - Return an UNDEF node. UNDEF does not have a useful SDLoc. 589198090Srdivacky SDValue getUNDEF(EVT VT) { 590263508Sdim return getNode(ISD::UNDEF, SDLoc(), VT); 591193323Sed } 592193323Sed 593193323Sed /// getGLOBAL_OFFSET_TABLE - Return a GLOBAL_OFFSET_TABLE node. This does 594263508Sdim /// not have a useful SDLoc. 595198090Srdivacky SDValue getGLOBAL_OFFSET_TABLE(EVT VT) { 596263508Sdim return getNode(ISD::GLOBAL_OFFSET_TABLE, SDLoc(), VT); 597193323Sed } 598193323Sed 599193323Sed /// getNode - Gets or creates the specified node. 600193323Sed /// 601263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT); 602263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N); 603263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, SDValue N1, SDValue N2); 604263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, 605193323Sed SDValue N1, SDValue N2, SDValue N3); 606263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, 607193323Sed SDValue N1, SDValue N2, SDValue N3, SDValue N4); 608263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, 609193323Sed SDValue N1, SDValue N2, SDValue N3, SDValue N4, 610193323Sed SDValue N5); 611263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, 612193323Sed const SDUse *Ops, unsigned NumOps); 613263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, EVT VT, 614193323Sed const SDValue *Ops, unsigned NumOps); 615263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, 616249423Sdim ArrayRef<EVT> ResultTys, 617193323Sed const SDValue *Ops, unsigned NumOps); 618263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, const EVT *VTs, unsigned NumVTs, 619193323Sed const SDValue *Ops, unsigned NumOps); 620263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs, 621193323Sed const SDValue *Ops, unsigned NumOps); 622263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs); 623263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs, SDValue N); 624263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs, 625193323Sed SDValue N1, SDValue N2); 626263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs, 627193323Sed SDValue N1, SDValue N2, SDValue N3); 628263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs, 629193323Sed SDValue N1, SDValue N2, SDValue N3, SDValue N4); 630263508Sdim SDValue getNode(unsigned Opcode, SDLoc DL, SDVTList VTs, 631193323Sed SDValue N1, SDValue N2, SDValue N3, SDValue N4, 632193323Sed SDValue N5); 633193323Sed 634198090Srdivacky /// getStackArgumentTokenFactor - Compute a TokenFactor to force all 635198090Srdivacky /// the incoming stack arguments to be loaded from the stack. This is 636198090Srdivacky /// used in tail call lowering to protect stack arguments from being 637198090Srdivacky /// clobbered. 638198090Srdivacky SDValue getStackArgumentTokenFactor(SDValue Chain); 639198090Srdivacky 640263508Sdim SDValue getMemcpy(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, 641206274Srdivacky SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, 642218893Sdim MachinePointerInfo DstPtrInfo, 643218893Sdim MachinePointerInfo SrcPtrInfo); 644193323Sed 645263508Sdim SDValue getMemmove(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, 646206274Srdivacky SDValue Size, unsigned Align, bool isVol, 647218893Sdim MachinePointerInfo DstPtrInfo, 648218893Sdim MachinePointerInfo SrcPtrInfo); 649193323Sed 650263508Sdim SDValue getMemset(SDValue Chain, SDLoc dl, SDValue Dst, SDValue Src, 651206274Srdivacky SDValue Size, unsigned Align, bool isVol, 652218893Sdim MachinePointerInfo DstPtrInfo); 653193323Sed 654193323Sed /// getSetCC - Helper function to make it easier to build SetCC's if you just 655193323Sed /// have an ISD::CondCode instead of an SDValue. 656193323Sed /// 657263508Sdim SDValue getSetCC(SDLoc DL, EVT VT, SDValue LHS, SDValue RHS, 658193323Sed ISD::CondCode Cond) { 659226633Sdim assert(LHS.getValueType().isVector() == RHS.getValueType().isVector() && 660226633Sdim "Cannot compare scalars to vectors"); 661226633Sdim assert(LHS.getValueType().isVector() == VT.isVector() && 662226633Sdim "Cannot compare scalars to vectors"); 663263508Sdim assert(Cond != ISD::SETCC_INVALID && 664263508Sdim "Cannot create a setCC of an invalid node."); 665193323Sed return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond)); 666193323Sed } 667193323Sed 668263508Sdim // getSelect - Helper function to make it easier to build Select's if you just 669263508Sdim // have operands and don't want to check for vector. 670263508Sdim SDValue getSelect(SDLoc DL, EVT VT, SDValue Cond, 671263508Sdim SDValue LHS, SDValue RHS) { 672263508Sdim assert(LHS.getValueType() == RHS.getValueType() && 673263508Sdim "Cannot use select on differing types"); 674263508Sdim assert(VT.isVector() == LHS.getValueType().isVector() && 675263508Sdim "Cannot mix vectors and scalars"); 676263508Sdim return getNode(Cond.getValueType().isVector() ? ISD::VSELECT : ISD::SELECT, DL, VT, 677263508Sdim Cond, LHS, RHS); 678263508Sdim } 679263508Sdim 680193323Sed /// getSelectCC - Helper function to make it easier to build SelectCC's if you 681193323Sed /// just have an ISD::CondCode instead of an SDValue. 682193323Sed /// 683263508Sdim SDValue getSelectCC(SDLoc DL, SDValue LHS, SDValue RHS, 684193323Sed SDValue True, SDValue False, ISD::CondCode Cond) { 685193323Sed return getNode(ISD::SELECT_CC, DL, True.getValueType(), 686193323Sed LHS, RHS, True, False, getCondCode(Cond)); 687193323Sed } 688193323Sed 689193323Sed /// getVAArg - VAArg produces a result and token chain, and takes a pointer 690193323Sed /// and a source value as input. 691263508Sdim SDValue getVAArg(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, 692210299Sed SDValue SV, unsigned Align); 693193323Sed 694193323Sed /// getAtomic - Gets a node for an atomic op, produces result and chain and 695193323Sed /// takes 3 operands 696263508Sdim SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDValue Chain, 697218893Sdim SDValue Ptr, SDValue Cmp, SDValue Swp, 698226633Sdim MachinePointerInfo PtrInfo, unsigned Alignment, 699226633Sdim AtomicOrdering Ordering, 700226633Sdim SynchronizationScope SynchScope); 701263508Sdim SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDValue Chain, 702198090Srdivacky SDValue Ptr, SDValue Cmp, SDValue Swp, 703226633Sdim MachineMemOperand *MMO, 704226633Sdim AtomicOrdering Ordering, 705226633Sdim SynchronizationScope SynchScope); 706193323Sed 707226633Sdim /// getAtomic - Gets a node for an atomic op, produces result (if relevant) 708226633Sdim /// and chain and takes 2 operands. 709263508Sdim SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDValue Chain, 710193323Sed SDValue Ptr, SDValue Val, const Value* PtrVal, 711226633Sdim unsigned Alignment, AtomicOrdering Ordering, 712226633Sdim SynchronizationScope SynchScope); 713263508Sdim SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDValue Chain, 714226633Sdim SDValue Ptr, SDValue Val, MachineMemOperand *MMO, 715226633Sdim AtomicOrdering Ordering, 716226633Sdim SynchronizationScope SynchScope); 717193323Sed 718226633Sdim /// getAtomic - Gets a node for an atomic op, produces result and chain and 719226633Sdim /// takes 1 operand. 720263508Sdim SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, EVT VT, 721226633Sdim SDValue Chain, SDValue Ptr, const Value* PtrVal, 722226633Sdim unsigned Alignment, 723226633Sdim AtomicOrdering Ordering, 724226633Sdim SynchronizationScope SynchScope); 725263508Sdim SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, EVT VT, 726226633Sdim SDValue Chain, SDValue Ptr, MachineMemOperand *MMO, 727226633Sdim AtomicOrdering Ordering, 728226633Sdim SynchronizationScope SynchScope); 729226633Sdim 730263508Sdim /// getAtomic - Gets a node for an atomic op, produces result and chain and 731263508Sdim /// takes N operands. 732263508Sdim SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDVTList VTList, 733263508Sdim SDValue* Ops, unsigned NumOps, MachineMemOperand *MMO, 734263508Sdim AtomicOrdering Ordering, 735263508Sdim SynchronizationScope SynchScope); 736263508Sdim 737193323Sed /// getMemIntrinsicNode - Creates a MemIntrinsicNode that may produce a 738198090Srdivacky /// result and takes a list of operands. Opcode may be INTRINSIC_VOID, 739198090Srdivacky /// INTRINSIC_W_CHAIN, or a target-specific opcode with a value not 740198090Srdivacky /// less than FIRST_TARGET_MEMORY_OPCODE. 741263508Sdim SDValue getMemIntrinsicNode(unsigned Opcode, SDLoc dl, 742198090Srdivacky const EVT *VTs, unsigned NumVTs, 743193323Sed const SDValue *Ops, unsigned NumOps, 744218893Sdim EVT MemVT, MachinePointerInfo PtrInfo, 745193323Sed unsigned Align = 0, bool Vol = false, 746193323Sed bool ReadMem = true, bool WriteMem = true); 747193323Sed 748263508Sdim SDValue getMemIntrinsicNode(unsigned Opcode, SDLoc dl, SDVTList VTList, 749193323Sed const SDValue *Ops, unsigned NumOps, 750218893Sdim EVT MemVT, MachinePointerInfo PtrInfo, 751193323Sed unsigned Align = 0, bool Vol = false, 752193323Sed bool ReadMem = true, bool WriteMem = true); 753193323Sed 754263508Sdim SDValue getMemIntrinsicNode(unsigned Opcode, SDLoc dl, SDVTList VTList, 755198090Srdivacky const SDValue *Ops, unsigned NumOps, 756198090Srdivacky EVT MemVT, MachineMemOperand *MMO); 757198090Srdivacky 758193323Sed /// getMergeValues - Create a MERGE_VALUES node from the given operands. 759263508Sdim SDValue getMergeValues(const SDValue *Ops, unsigned NumOps, SDLoc dl); 760193323Sed 761193323Sed /// getLoad - Loads are not normal binary operators: their result type is not 762193323Sed /// determined by their operands, and they produce a value AND a token chain. 763193323Sed /// 764263508Sdim SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, 765218893Sdim MachinePointerInfo PtrInfo, bool isVolatile, 766234353Sdim bool isNonTemporal, bool isInvariant, unsigned Alignment, 767234353Sdim const MDNode *TBAAInfo = 0, const MDNode *Ranges = 0); 768263508Sdim SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, 769263508Sdim MachineMemOperand *MMO); 770263508Sdim SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT, 771218893Sdim SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, 772218893Sdim EVT MemVT, bool isVolatile, 773218893Sdim bool isNonTemporal, unsigned Alignment, 774218893Sdim const MDNode *TBAAInfo = 0); 775263508Sdim SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT, 776263508Sdim SDValue Chain, SDValue Ptr, EVT MemVT, 777263508Sdim MachineMemOperand *MMO); 778263508Sdim SDValue getIndexedLoad(SDValue OrigLoad, SDLoc dl, SDValue Base, 779210299Sed SDValue Offset, ISD::MemIndexedMode AM); 780210299Sed SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, 781263508Sdim EVT VT, SDLoc dl, 782210299Sed SDValue Chain, SDValue Ptr, SDValue Offset, 783218893Sdim MachinePointerInfo PtrInfo, EVT MemVT, 784234353Sdim bool isVolatile, bool isNonTemporal, bool isInvariant, 785234353Sdim unsigned Alignment, const MDNode *TBAAInfo = 0, 786234353Sdim const MDNode *Ranges = 0); 787210299Sed SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, 788263508Sdim EVT VT, SDLoc dl, 789210299Sed SDValue Chain, SDValue Ptr, SDValue Offset, 790198090Srdivacky EVT MemVT, MachineMemOperand *MMO); 791193323Sed 792193323Sed /// getStore - Helper function to build ISD::STORE nodes. 793193323Sed /// 794263508Sdim SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, 795218893Sdim MachinePointerInfo PtrInfo, bool isVolatile, 796218893Sdim bool isNonTemporal, unsigned Alignment, 797218893Sdim const MDNode *TBAAInfo = 0); 798263508Sdim SDValue getStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, 799198090Srdivacky MachineMemOperand *MMO); 800263508Sdim SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, 801218893Sdim MachinePointerInfo PtrInfo, EVT TVT, 802203954Srdivacky bool isNonTemporal, bool isVolatile, 803218893Sdim unsigned Alignment, 804218893Sdim const MDNode *TBAAInfo = 0); 805263508Sdim SDValue getTruncStore(SDValue Chain, SDLoc dl, SDValue Val, SDValue Ptr, 806198090Srdivacky EVT TVT, MachineMemOperand *MMO); 807263508Sdim SDValue getIndexedStore(SDValue OrigStoe, SDLoc dl, SDValue Base, 808193323Sed SDValue Offset, ISD::MemIndexedMode AM); 809193323Sed 810193323Sed /// getSrcValue - Construct a node to track a Value* through the backend. 811193323Sed SDValue getSrcValue(const Value *v); 812193323Sed 813207618Srdivacky /// getMDNode - Return an MDNodeSDNode which holds an MDNode. 814207618Srdivacky SDValue getMDNode(const MDNode *MD); 815221345Sdim 816263508Sdim /// getAddrSpaceCast - Return an AddrSpaceCastSDNode. 817263508Sdim SDValue getAddrSpaceCast(SDLoc dl, EVT VT, SDValue Ptr, 818263508Sdim unsigned SrcAS, unsigned DestAS); 819263508Sdim 820193323Sed /// getShiftAmountOperand - Return the specified value casted to 821193323Sed /// the target's desired shift amount type. 822221345Sdim SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op); 823193323Sed 824193323Sed /// UpdateNodeOperands - *Mutate* the specified node in-place to have the 825193323Sed /// specified operands. If the resultant node already exists in the DAG, 826193323Sed /// this does not modify the specified node, instead it returns the node that 827193323Sed /// already exists. If the resultant node does not exist in the DAG, the 828193323Sed /// input node is returned. As a degenerate case, if you specify the same 829193323Sed /// input operands as the node already has, the input node is returned. 830210299Sed SDNode *UpdateNodeOperands(SDNode *N, SDValue Op); 831210299Sed SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2); 832210299Sed SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2, 833193323Sed SDValue Op3); 834210299Sed SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2, 835193323Sed SDValue Op3, SDValue Op4); 836210299Sed SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2, 837193323Sed SDValue Op3, SDValue Op4, SDValue Op5); 838210299Sed SDNode *UpdateNodeOperands(SDNode *N, 839193323Sed const SDValue *Ops, unsigned NumOps); 840193323Sed 841193323Sed /// SelectNodeTo - These are used for target selectors to *mutate* the 842193323Sed /// specified node to have the specified return type, Target opcode, and 843193323Sed /// operands. Note that target opcodes are stored as 844193323Sed /// ~TargetOpcode in the node opcode field. The resultant node is returned. 845198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT); 846198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT, SDValue Op1); 847198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT, 848193323Sed SDValue Op1, SDValue Op2); 849198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT, 850193323Sed SDValue Op1, SDValue Op2, SDValue Op3); 851198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT, 852193323Sed const SDValue *Ops, unsigned NumOps); 853198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, EVT VT2); 854198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, 855198090Srdivacky EVT VT2, const SDValue *Ops, unsigned NumOps); 856198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, 857198090Srdivacky EVT VT2, EVT VT3, const SDValue *Ops, unsigned NumOps); 858198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1, 859198090Srdivacky EVT VT2, EVT VT3, EVT VT4, const SDValue *Ops, 860193323Sed unsigned NumOps); 861198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, 862198090Srdivacky EVT VT2, SDValue Op1); 863198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, 864198090Srdivacky EVT VT2, SDValue Op1, SDValue Op2); 865198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, 866198090Srdivacky EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); 867198090Srdivacky SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, 868198090Srdivacky EVT VT2, EVT VT3, SDValue Op1, SDValue Op2, SDValue Op3); 869193323Sed SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs, 870193323Sed const SDValue *Ops, unsigned NumOps); 871193323Sed 872204642Srdivacky /// MorphNodeTo - This *mutates* the specified node to have the specified 873193323Sed /// return type, opcode, and operands. 874193323Sed SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, 875193323Sed const SDValue *Ops, unsigned NumOps); 876193323Sed 877198090Srdivacky /// getMachineNode - These are used for target selectors to create a new node 878198090Srdivacky /// with specified return type(s), MachineInstr opcode, and operands. 879193323Sed /// 880198090Srdivacky /// Note that getMachineNode returns the resultant node. If there is already 881198090Srdivacky /// a node of the specified opcode and operands, it returns that node instead 882198090Srdivacky /// of the current one. 883263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT); 884263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT, 885198090Srdivacky SDValue Op1); 886263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT, 887198090Srdivacky SDValue Op1, SDValue Op2); 888263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT, 889251662Sdim SDValue Op1, SDValue Op2, SDValue Op3); 890263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT, 891251662Sdim ArrayRef<SDValue> Ops); 892263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2); 893263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2, 894251662Sdim SDValue Op1); 895263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2, 896251662Sdim SDValue Op1, SDValue Op2); 897263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2, 898251662Sdim SDValue Op1, SDValue Op2, SDValue Op3); 899263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2, 900251662Sdim ArrayRef<SDValue> Ops); 901263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2, 902251662Sdim EVT VT3, SDValue Op1, SDValue Op2); 903263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2, 904251662Sdim EVT VT3, SDValue Op1, SDValue Op2, 905251662Sdim SDValue Op3); 906263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2, 907251662Sdim EVT VT3, ArrayRef<SDValue> Ops); 908263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, EVT VT1, EVT VT2, 909251662Sdim EVT VT3, EVT VT4, ArrayRef<SDValue> Ops); 910263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, 911251662Sdim ArrayRef<EVT> ResultTys, 912251662Sdim ArrayRef<SDValue> Ops); 913263508Sdim MachineSDNode *getMachineNode(unsigned Opcode, SDLoc dl, SDVTList VTs, 914251662Sdim ArrayRef<SDValue> Ops); 915193323Sed 916198090Srdivacky /// getTargetExtractSubreg - A convenience function for creating 917198090Srdivacky /// TargetInstrInfo::EXTRACT_SUBREG nodes. 918263508Sdim SDValue getTargetExtractSubreg(int SRIdx, SDLoc DL, EVT VT, 919198090Srdivacky SDValue Operand); 920198090Srdivacky 921198090Srdivacky /// getTargetInsertSubreg - A convenience function for creating 922198090Srdivacky /// TargetInstrInfo::INSERT_SUBREG nodes. 923263508Sdim SDValue getTargetInsertSubreg(int SRIdx, SDLoc DL, EVT VT, 924198090Srdivacky SDValue Operand, SDValue Subreg); 925198090Srdivacky 926193323Sed /// getNodeIfExists - Get the specified node if it's already available, or 927193323Sed /// else return NULL. 928193323Sed SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs, 929193323Sed const SDValue *Ops, unsigned NumOps); 930193323Sed 931206083Srdivacky /// getDbgValue - Creates a SDDbgValue node. 932206083Srdivacky /// 933206083Srdivacky SDDbgValue *getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R, uint64_t Off, 934206083Srdivacky DebugLoc DL, unsigned O); 935207618Srdivacky SDDbgValue *getDbgValue(MDNode *MDPtr, const Value *C, uint64_t Off, 936206083Srdivacky DebugLoc DL, unsigned O); 937206083Srdivacky SDDbgValue *getDbgValue(MDNode *MDPtr, unsigned FI, uint64_t Off, 938206083Srdivacky DebugLoc DL, unsigned O); 939206083Srdivacky 940193323Sed /// RemoveDeadNode - Remove the specified node from the system. If any of its 941193323Sed /// operands then becomes dead, remove them as well. Inform UpdateListener 942193323Sed /// for each node deleted. 943239462Sdim void RemoveDeadNode(SDNode *N); 944193323Sed 945193323Sed /// RemoveDeadNodes - This method deletes the unreachable nodes in the 946193323Sed /// given list, and any nodes that become unreachable as a result. 947239462Sdim void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes); 948193323Sed 949193323Sed /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead. 950193323Sed /// This can cause recursive merging of nodes in the DAG. Use the first 951193323Sed /// version if 'From' is known to have a single result, use the second 952193323Sed /// if you have two nodes with identical results (or if 'To' has a superset 953193323Sed /// of the results of 'From'), use the third otherwise. 954193323Sed /// 955193323Sed /// These methods all take an optional UpdateListener, which (if not null) is 956193323Sed /// informed about nodes that are deleted and modified due to recursive 957193323Sed /// changes in the dag. 958193323Sed /// 959193323Sed /// These functions only replace all existing uses. It's possible that as 960193323Sed /// these replacements are being performed, CSE may cause the From node 961193323Sed /// to be given new uses. These new uses of From are left in place, and 962221345Sdim /// not automatically transferred to To. 963193323Sed /// 964239462Sdim void ReplaceAllUsesWith(SDValue From, SDValue Op); 965239462Sdim void ReplaceAllUsesWith(SDNode *From, SDNode *To); 966239462Sdim void ReplaceAllUsesWith(SDNode *From, const SDValue *To); 967193323Sed 968193323Sed /// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving 969193323Sed /// uses of other values produced by From.Val alone. 970239462Sdim void ReplaceAllUsesOfValueWith(SDValue From, SDValue To); 971193323Sed 972193323Sed /// ReplaceAllUsesOfValuesWith - Like ReplaceAllUsesOfValueWith, but 973193323Sed /// for multiple values at once. This correctly handles the case where 974193323Sed /// there is an overlap between the From values and the To values. 975193323Sed void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, 976239462Sdim unsigned Num); 977193323Sed 978193323Sed /// AssignTopologicalOrder - Topological-sort the AllNodes list and a 979193323Sed /// assign a unique node id for each node in the DAG based on their 980193323Sed /// topological order. Returns the number of nodes. 981193323Sed unsigned AssignTopologicalOrder(); 982193323Sed 983193323Sed /// RepositionNode - Move node N in the AllNodes list to be immediately 984193323Sed /// before the given iterator Position. This may be used to update the 985193323Sed /// topological ordering when the list of nodes is modified. 986193323Sed void RepositionNode(allnodes_iterator Position, SDNode *N) { 987193323Sed AllNodes.insert(Position, AllNodes.remove(N)); 988193323Sed } 989193323Sed 990193323Sed /// isCommutativeBinOp - Returns true if the opcode is a commutative binary 991193323Sed /// operation. 992193323Sed static bool isCommutativeBinOp(unsigned Opcode) { 993193323Sed // FIXME: This should get its info from the td file, so that we can include 994193323Sed // target info. 995193323Sed switch (Opcode) { 996193323Sed case ISD::ADD: 997193323Sed case ISD::MUL: 998193323Sed case ISD::MULHU: 999193323Sed case ISD::MULHS: 1000193323Sed case ISD::SMUL_LOHI: 1001193323Sed case ISD::UMUL_LOHI: 1002193323Sed case ISD::FADD: 1003193323Sed case ISD::FMUL: 1004193323Sed case ISD::AND: 1005193323Sed case ISD::OR: 1006193323Sed case ISD::XOR: 1007193323Sed case ISD::SADDO: 1008193323Sed case ISD::UADDO: 1009193323Sed case ISD::ADDC: 1010193323Sed case ISD::ADDE: return true; 1011193323Sed default: return false; 1012193323Sed } 1013193323Sed } 1014193323Sed 1015249423Sdim /// Returns an APFloat semantics tag appropriate for the given type. If VT is 1016249423Sdim /// a vector type, the element semantics are returned. 1017249423Sdim static const fltSemantics &EVTToAPFloatSemantics(EVT VT) { 1018249423Sdim switch (VT.getScalarType().getSimpleVT().SimpleTy) { 1019249423Sdim default: llvm_unreachable("Unknown FP format"); 1020249423Sdim case MVT::f16: return APFloat::IEEEhalf; 1021249423Sdim case MVT::f32: return APFloat::IEEEsingle; 1022249423Sdim case MVT::f64: return APFloat::IEEEdouble; 1023249423Sdim case MVT::f80: return APFloat::x87DoubleExtended; 1024249423Sdim case MVT::f128: return APFloat::IEEEquad; 1025249423Sdim case MVT::ppcf128: return APFloat::PPCDoubleDouble; 1026249423Sdim } 1027249423Sdim } 1028249423Sdim 1029206083Srdivacky /// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the 1030206083Srdivacky /// value is produced by SD. 1031207618Srdivacky void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter); 1032205218Srdivacky 1033206083Srdivacky /// GetDbgValues - Get the debug values which reference the given SDNode. 1034224145Sdim ArrayRef<SDDbgValue*> GetDbgValues(const SDNode* SD) { 1035206083Srdivacky return DbgInfo->getSDDbgValues(SD); 1036206083Srdivacky } 1037221345Sdim 1038218893Sdim /// TransferDbgValues - Transfer SDDbgValues. 1039218893Sdim void TransferDbgValues(SDValue From, SDValue To); 1040205218Srdivacky 1041206083Srdivacky /// hasDebugValues - Return true if there are any SDDbgValue nodes associated 1042206083Srdivacky /// with this SelectionDAG. 1043206083Srdivacky bool hasDebugValues() const { return !DbgInfo->empty(); } 1044205218Srdivacky 1045206083Srdivacky SDDbgInfo::DbgIterator DbgBegin() { return DbgInfo->DbgBegin(); } 1046206083Srdivacky SDDbgInfo::DbgIterator DbgEnd() { return DbgInfo->DbgEnd(); } 1047221345Sdim SDDbgInfo::DbgIterator ByvalParmDbgBegin() { 1048221345Sdim return DbgInfo->ByvalParmDbgBegin(); 1049207618Srdivacky } 1050221345Sdim SDDbgInfo::DbgIterator ByvalParmDbgEnd() { 1051221345Sdim return DbgInfo->ByvalParmDbgEnd(); 1052207618Srdivacky } 1053205218Srdivacky 1054193323Sed void dump() const; 1055193323Sed 1056193323Sed /// CreateStackTemporary - Create a stack temporary, suitable for holding the 1057193323Sed /// specified value type. If minAlign is specified, the slot size will have 1058193323Sed /// at least that alignment. 1059198090Srdivacky SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1); 1060193323Sed 1061193323Sed /// CreateStackTemporary - Create a stack temporary suitable for holding 1062193323Sed /// either of the specified value types. 1063198090Srdivacky SDValue CreateStackTemporary(EVT VT1, EVT VT2); 1064193323Sed 1065193323Sed /// FoldConstantArithmetic - 1066249423Sdim SDValue FoldConstantArithmetic(unsigned Opcode, EVT VT, 1067249423Sdim SDNode *Cst1, SDNode *Cst2); 1068193323Sed 1069193323Sed /// FoldSetCC - Constant fold a setcc to true or false. 1070198090Srdivacky SDValue FoldSetCC(EVT VT, SDValue N1, 1071263508Sdim SDValue N2, ISD::CondCode Cond, SDLoc dl); 1072193323Sed 1073193323Sed /// SignBitIsZero - Return true if the sign bit of Op is known to be zero. We 1074193323Sed /// use this predicate to simplify operations downstream. 1075193323Sed bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const; 1076193323Sed 1077193323Sed /// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero. We 1078193323Sed /// use this predicate to simplify operations downstream. Op and Mask are 1079193323Sed /// known to be the same type. 1080193323Sed bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth = 0) 1081193323Sed const; 1082193323Sed 1083193323Sed /// ComputeMaskedBits - Determine which of the bits specified in Mask are 1084193323Sed /// known to be either zero or one and return them in the KnownZero/KnownOne 1085193323Sed /// bitsets. This code only analyzes bits in Mask, in order to short-circuit 1086193323Sed /// processing. Targets can implement the computeMaskedBitsForTargetNode 1087193323Sed /// method in the TargetLowering class to allow target nodes to be understood. 1088234353Sdim void ComputeMaskedBits(SDValue Op, APInt &KnownZero, APInt &KnownOne, 1089234353Sdim unsigned Depth = 0) const; 1090193323Sed 1091193323Sed /// ComputeNumSignBits - Return the number of times the sign bit of the 1092193323Sed /// register is replicated into the other bits. We know that at least 1 bit 1093193323Sed /// is always equal to the sign bit (itself), but other cases can give us 1094193323Sed /// information. For example, immediately after an "SRA X, 2", we know that 1095193323Sed /// the top 3 bits are all equal to each other, so we return 3. Targets can 1096193323Sed /// implement the ComputeNumSignBitsForTarget method in the TargetLowering 1097193323Sed /// class to allow target nodes to be understood. 1098193323Sed unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const; 1099193323Sed 1100218893Sdim /// isBaseWithConstantOffset - Return true if the specified operand is an 1101218893Sdim /// ISD::ADD with a ConstantSDNode on the right-hand side, or if it is an 1102218893Sdim /// ISD::OR with a ConstantSDNode that is guaranteed to have the same 1103218893Sdim /// semantics as an ADD. This handles the equivalence: 1104218893Sdim /// X|Cst == X+Cst iff X&Cst = 0. 1105218893Sdim bool isBaseWithConstantOffset(SDValue Op) const; 1106221345Sdim 1107198090Srdivacky /// isKnownNeverNan - Test whether the given SDValue is known to never be NaN. 1108198090Srdivacky bool isKnownNeverNaN(SDValue Op) const; 1109198090Srdivacky 1110204642Srdivacky /// isKnownNeverZero - Test whether the given SDValue is known to never be 1111204642Srdivacky /// positive or negative Zero. 1112204642Srdivacky bool isKnownNeverZero(SDValue Op) const; 1113204642Srdivacky 1114204642Srdivacky /// isEqualTo - Test whether two SDValues are known to compare equal. This 1115204642Srdivacky /// is true if they are the same value, or if one is negative zero and the 1116204642Srdivacky /// other positive zero. 1117204642Srdivacky bool isEqualTo(SDValue A, SDValue B) const; 1118204642Srdivacky 1119199989Srdivacky /// UnrollVectorOp - Utility function used by legalize and lowering to 1120199989Srdivacky /// "unroll" a vector operation by splitting out the scalars and operating 1121199989Srdivacky /// on each element individually. If the ResNE is 0, fully unroll the vector 1122199989Srdivacky /// op. If ResNE is less than the width of the vector op, unroll up to ResNE. 1123199989Srdivacky /// If the ResNE is greater than the width of the vector op, unroll the 1124199989Srdivacky /// vector op and fill the end of the resulting vector with UNDEFS. 1125199989Srdivacky SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0); 1126199989Srdivacky 1127221345Sdim /// isConsecutiveLoad - Return true if LD is loading 'Bytes' bytes from a 1128221345Sdim /// location that is 'Dist' units away from the location that the 'Base' load 1129200581Srdivacky /// is loading from. 1130200581Srdivacky bool isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base, 1131200581Srdivacky unsigned Bytes, int Dist) const; 1132200581Srdivacky 1133200581Srdivacky /// InferPtrAlignment - Infer alignment of a load / store address. Return 0 if 1134200581Srdivacky /// it cannot be inferred. 1135200581Srdivacky unsigned InferPtrAlignment(SDValue Ptr) const; 1136200581Srdivacky 1137263508Sdim /// GetSplitDestVTs - Compute the VTs needed for the low/hi parts of a type 1138263508Sdim /// which is split (or expanded) into two not necessarily identical pieces. 1139263508Sdim std::pair<EVT, EVT> GetSplitDestVTs(const EVT &VT) const; 1140263508Sdim 1141263508Sdim /// SplitVector - Split the vector with EXTRACT_SUBVECTOR using the provides 1142263508Sdim /// VTs and return the low/high part. 1143263508Sdim std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL, 1144263508Sdim const EVT &LoVT, const EVT &HiVT); 1145263508Sdim 1146263508Sdim /// SplitVector - Split the vector with EXTRACT_SUBVECTOR and return the 1147263508Sdim /// low/high part. 1148263508Sdim std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL) { 1149263508Sdim EVT LoVT, HiVT; 1150263508Sdim llvm::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType()); 1151263508Sdim return SplitVector(N, DL, LoVT, HiVT); 1152263508Sdim } 1153263508Sdim 1154263508Sdim /// SplitVectorOperand - Split the node's operand with EXTRACT_SUBVECTOR and 1155263508Sdim /// return the low/high part. 1156263508Sdim std::pair<SDValue, SDValue> SplitVectorOperand(const SDNode *N, unsigned OpNo) 1157263508Sdim { 1158263508Sdim return SplitVector(N->getOperand(OpNo), SDLoc(N)); 1159263508Sdim } 1160263508Sdim 1161193323Sedprivate: 1162193323Sed bool RemoveNodeFromCSEMaps(SDNode *N); 1163239462Sdim void AddModifiedNodeToCSEMaps(SDNode *N); 1164193323Sed SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos); 1165193323Sed SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2, 1166193323Sed void *&InsertPos); 1167193323Sed SDNode *FindModifiedNodeSlot(SDNode *N, const SDValue *Ops, unsigned NumOps, 1168193323Sed void *&InsertPos); 1169263508Sdim SDNode *UpdadeSDLocOnMergedSDNode(SDNode *N, SDLoc loc); 1170193323Sed 1171193323Sed void DeleteNodeNotInCSEMaps(SDNode *N); 1172193323Sed void DeallocateNode(SDNode *N); 1173193323Sed 1174198090Srdivacky unsigned getEVTAlignment(EVT MemoryVT) const; 1175193323Sed 1176193323Sed void allnodes_clear(); 1177193323Sed 1178193323Sed /// VTList - List of non-single value types. 1179263508Sdim FoldingSet<SDVTListNode> VTListMap; 1180193323Sed 1181193323Sed /// CondCodeNodes - Maps to auto-CSE operations. 1182193323Sed std::vector<CondCodeSDNode*> CondCodeNodes; 1183193323Sed 1184193323Sed std::vector<SDNode*> ValueTypeNodes; 1185198090Srdivacky std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes; 1186193323Sed StringMap<SDNode*> ExternalSymbols; 1187221345Sdim 1188195098Sed std::map<std::pair<std::string, unsigned char>,SDNode*> TargetExternalSymbols; 1189193323Sed}; 1190193323Sed 1191193323Sedtemplate <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> { 1192193323Sed typedef SelectionDAG::allnodes_iterator nodes_iterator; 1193193323Sed static nodes_iterator nodes_begin(SelectionDAG *G) { 1194193323Sed return G->allnodes_begin(); 1195193323Sed } 1196193323Sed static nodes_iterator nodes_end(SelectionDAG *G) { 1197193323Sed return G->allnodes_end(); 1198193323Sed } 1199193323Sed}; 1200193323Sed 1201193323Sed} // end namespace llvm 1202193323Sed 1203193323Sed#endif 1204