SelectionDAG.h revision df51247725143acb781c224faffd848cc7cf95d8
1//===-- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ---------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the SelectionDAG class, and transitively defines the
11// SDNode class and subclasses.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_SELECTIONDAG_H
16#define LLVM_CODEGEN_SELECTIONDAG_H
17
18#include "llvm/ADT/ilist.h"
19#include "llvm/ADT/DenseSet.h"
20#include "llvm/ADT/StringMap.h"
21#include "llvm/CodeGen/SelectionDAGNodes.h"
22#include "llvm/Support/RecyclingAllocator.h"
23#include "llvm/Target/TargetMachine.h"
24#include <cassert>
25#include <vector>
26#include <map>
27#include <string>
28
29namespace llvm {
30
31class AliasAnalysis;
32class DwarfWriter;
33class FunctionLoweringInfo;
34class MachineConstantPoolValue;
35class MachineFunction;
36class MachineModuleInfo;
37class SDNodeOrdering;
38class TargetLowering;
39
40template<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> {
41private:
42  mutable ilist_half_node<SDNode> Sentinel;
43public:
44  SDNode *createSentinel() const {
45    return static_cast<SDNode*>(&Sentinel);
46  }
47  static void destroySentinel(SDNode *) {}
48
49  SDNode *provideInitialHead() const { return createSentinel(); }
50  SDNode *ensureHead(SDNode*) const { return createSentinel(); }
51  static void noteHead(SDNode*, SDNode*) {}
52
53  static void deleteNode(SDNode *) {
54    assert(0 && "ilist_traits<SDNode> shouldn't see a deleteNode call!");
55  }
56private:
57  static void createNode(const SDNode &);
58};
59
60enum CombineLevel {
61  Unrestricted,   // Combine may create illegal operations and illegal types.
62  NoIllegalTypes, // Combine may create illegal operations but no illegal types.
63  NoIllegalOperations // Combine may only create legal operations and types.
64};
65
66class SelectionDAG;
67void checkForCycles(const SDNode *N);
68void checkForCycles(const SelectionDAG *DAG);
69
70/// SelectionDAG class - This is used to represent a portion of an LLVM function
71/// in a low-level Data Dependence DAG representation suitable for instruction
72/// selection.  This DAG is constructed as the first step of instruction
73/// selection in order to allow implementation of machine specific optimizations
74/// and code simplifications.
75///
76/// The representation used by the SelectionDAG is a target-independent
77/// representation, which has some similarities to the GCC RTL representation,
78/// but is significantly more simple, powerful, and is a graph form instead of a
79/// linear form.
80///
81class SelectionDAG {
82  TargetLowering &TLI;
83  MachineFunction *MF;
84  FunctionLoweringInfo &FLI;
85  MachineModuleInfo *MMI;
86  DwarfWriter *DW;
87  LLVMContext* Context;
88
89  /// EntryNode - The starting token.
90  SDNode EntryNode;
91
92  /// Root - The root of the entire DAG.
93  SDValue Root;
94
95  /// AllNodes - A linked list of nodes in the current DAG.
96  ilist<SDNode> AllNodes;
97
98  /// NodeAllocatorType - The AllocatorType for allocating SDNodes. We use
99  /// pool allocation with recycling.
100  typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode),
101                             AlignOf<MostAlignedSDNode>::Alignment>
102    NodeAllocatorType;
103
104  /// NodeAllocator - Pool allocation for nodes.
105  NodeAllocatorType NodeAllocator;
106
107  /// CSEMap - This structure is used to memoize nodes, automatically performing
108  /// CSE with existing nodes when a duplicate is requested.
109  FoldingSet<SDNode> CSEMap;
110
111  /// OperandAllocator - Pool allocation for machine-opcode SDNode operands.
112  BumpPtrAllocator OperandAllocator;
113
114  /// Allocator - Pool allocation for misc. objects that are created once per
115  /// SelectionDAG.
116  BumpPtrAllocator Allocator;
117
118  /// SDNodeOrdering - The ordering of the SDNodes. It roughly corresponds to
119  /// the ordering of the original LLVM instructions.
120  SDNodeOrdering *Ordering;
121
122  /// VerifyNode - Sanity check the given node.  Aborts if it is invalid.
123  void VerifyNode(SDNode *N);
124
125  /// setGraphColorHelper - Implementation of setSubgraphColor.
126  /// Return whether we had to truncate the search.
127  ///
128  bool setSubgraphColorHelper(SDNode *N, const char *Color,
129                              DenseSet<SDNode *> &visited,
130                              int level, bool &printed);
131
132  void operator=(const SelectionDAG&); // Do not implement.
133  SelectionDAG(const SelectionDAG&);   // Do not implement.
134
135public:
136  SelectionDAG(TargetLowering &tli, FunctionLoweringInfo &fli);
137  ~SelectionDAG();
138
139  /// init - Prepare this SelectionDAG to process code in the given
140  /// MachineFunction.
141  ///
142  void init(MachineFunction &mf, MachineModuleInfo *mmi, DwarfWriter *dw);
143
144  /// clear - Clear state and free memory necessary to make this
145  /// SelectionDAG ready to process a new block.
146  ///
147  void clear();
148
149  MachineFunction &getMachineFunction() const { return *MF; }
150  const TargetMachine &getTarget() const;
151  TargetLowering &getTargetLoweringInfo() const { return TLI; }
152  FunctionLoweringInfo &getFunctionLoweringInfo() const { return FLI; }
153  MachineModuleInfo *getMachineModuleInfo() const { return MMI; }
154  DwarfWriter *getDwarfWriter() const { return DW; }
155  LLVMContext *getContext() const {return Context; }
156
157  /// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
158  ///
159  void viewGraph(const std::string &Title);
160  void viewGraph();
161
162#ifndef NDEBUG
163  std::map<const SDNode *, std::string> NodeGraphAttrs;
164#endif
165
166  /// clearGraphAttrs - Clear all previously defined node graph attributes.
167  /// Intended to be used from a debugging tool (eg. gdb).
168  void clearGraphAttrs();
169
170  /// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".)
171  ///
172  void setGraphAttrs(const SDNode *N, const char *Attrs);
173
174  /// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".)
175  /// Used from getNodeAttributes.
176  const std::string getGraphAttrs(const SDNode *N) const;
177
178  /// setGraphColor - Convenience for setting node color attribute.
179  ///
180  void setGraphColor(const SDNode *N, const char *Color);
181
182  /// setGraphColor - Convenience for setting subgraph color attribute.
183  ///
184  void setSubgraphColor(SDNode *N, const char *Color);
185
186  typedef ilist<SDNode>::const_iterator allnodes_const_iterator;
187  allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
188  allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
189  typedef ilist<SDNode>::iterator allnodes_iterator;
190  allnodes_iterator allnodes_begin() { return AllNodes.begin(); }
191  allnodes_iterator allnodes_end() { return AllNodes.end(); }
192  ilist<SDNode>::size_type allnodes_size() const {
193    return AllNodes.size();
194  }
195
196  /// getRoot - Return the root tag of the SelectionDAG.
197  ///
198  const SDValue &getRoot() const { return Root; }
199
200  /// getEntryNode - Return the token chain corresponding to the entry of the
201  /// function.
202  SDValue getEntryNode() const {
203    return SDValue(const_cast<SDNode *>(&EntryNode), 0);
204  }
205
206  /// setRoot - Set the current root tag of the SelectionDAG.
207  ///
208  const SDValue &setRoot(SDValue N) {
209    assert((!N.getNode() || N.getValueType() == MVT::Other) &&
210           "DAG root value is not a chain!");
211    if (N.getNode())
212      checkForCycles(N.getNode());
213    Root = N;
214    if (N.getNode())
215      checkForCycles(this);
216    return Root;
217  }
218
219  /// Combine - This iterates over the nodes in the SelectionDAG, folding
220  /// certain types of nodes together, or eliminating superfluous nodes.  The
221  /// Level argument controls whether Combine is allowed to produce nodes and
222  /// types that are illegal on the target.
223  void Combine(CombineLevel Level, AliasAnalysis &AA,
224               CodeGenOpt::Level OptLevel);
225
226  /// LegalizeTypes - This transforms the SelectionDAG into a SelectionDAG that
227  /// only uses types natively supported by the target.  Returns "true" if it
228  /// made any changes.
229  ///
230  /// Note that this is an involved process that may invalidate pointers into
231  /// the graph.
232  bool LegalizeTypes();
233
234  /// Legalize - This transforms the SelectionDAG into a SelectionDAG that is
235  /// compatible with the target instruction selector, as indicated by the
236  /// TargetLowering object.
237  ///
238  /// Note that this is an involved process that may invalidate pointers into
239  /// the graph.
240  void Legalize(CodeGenOpt::Level OptLevel);
241
242  /// LegalizeVectors - This transforms the SelectionDAG into a SelectionDAG
243  /// that only uses vector math operations supported by the target.  This is
244  /// necessary as a separate step from Legalize because unrolling a vector
245  /// operation can introduce illegal types, which requires running
246  /// LegalizeTypes again.
247  ///
248  /// This returns true if it made any changes; in that case, LegalizeTypes
249  /// is called again before Legalize.
250  ///
251  /// Note that this is an involved process that may invalidate pointers into
252  /// the graph.
253  bool LegalizeVectors();
254
255  /// RemoveDeadNodes - This method deletes all unreachable nodes in the
256  /// SelectionDAG.
257  void RemoveDeadNodes();
258
259  /// DeleteNode - Remove the specified node from the system.  This node must
260  /// have no referrers.
261  void DeleteNode(SDNode *N);
262
263  /// getVTList - Return an SDVTList that represents the list of values
264  /// specified.
265  SDVTList getVTList(EVT VT);
266  SDVTList getVTList(EVT VT1, EVT VT2);
267  SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3);
268  SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3, EVT VT4);
269  SDVTList getVTList(const EVT *VTs, unsigned NumVTs);
270
271  //===--------------------------------------------------------------------===//
272  // Node creation methods.
273  //
274  SDValue getConstant(uint64_t Val, EVT VT, bool isTarget = false);
275  SDValue getConstant(const APInt &Val, EVT VT, bool isTarget = false);
276  SDValue getConstant(const ConstantInt &Val, EVT VT, bool isTarget = false);
277  SDValue getIntPtrConstant(uint64_t Val, bool isTarget = false);
278  SDValue getTargetConstant(uint64_t Val, EVT VT) {
279    return getConstant(Val, VT, true);
280  }
281  SDValue getTargetConstant(const APInt &Val, EVT VT) {
282    return getConstant(Val, VT, true);
283  }
284  SDValue getTargetConstant(const ConstantInt &Val, EVT VT) {
285    return getConstant(Val, VT, true);
286  }
287  SDValue getConstantFP(double Val, EVT VT, bool isTarget = false);
288  SDValue getConstantFP(const APFloat& Val, EVT VT, bool isTarget = false);
289  SDValue getConstantFP(const ConstantFP &CF, EVT VT, bool isTarget = false);
290  SDValue getTargetConstantFP(double Val, EVT VT) {
291    return getConstantFP(Val, VT, true);
292  }
293  SDValue getTargetConstantFP(const APFloat& Val, EVT VT) {
294    return getConstantFP(Val, VT, true);
295  }
296  SDValue getTargetConstantFP(const ConstantFP &Val, EVT VT) {
297    return getConstantFP(Val, VT, true);
298  }
299  SDValue getGlobalAddress(const GlobalValue *GV, EVT VT,
300                           int64_t offset = 0, bool isTargetGA = false,
301                           unsigned char TargetFlags = 0);
302  SDValue getTargetGlobalAddress(const GlobalValue *GV, EVT VT,
303                                 int64_t offset = 0,
304                                 unsigned char TargetFlags = 0) {
305    return getGlobalAddress(GV, VT, offset, true, TargetFlags);
306  }
307  SDValue getFrameIndex(int FI, EVT VT, bool isTarget = false);
308  SDValue getTargetFrameIndex(int FI, EVT VT) {
309    return getFrameIndex(FI, VT, true);
310  }
311  SDValue getJumpTable(int JTI, EVT VT, bool isTarget = false,
312                       unsigned char TargetFlags = 0);
313  SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags = 0) {
314    return getJumpTable(JTI, VT, true, TargetFlags);
315  }
316  SDValue getConstantPool(Constant *C, EVT VT,
317                          unsigned Align = 0, int Offs = 0, bool isT=false,
318                          unsigned char TargetFlags = 0);
319  SDValue getTargetConstantPool(Constant *C, EVT VT,
320                                unsigned Align = 0, int Offset = 0,
321                                unsigned char TargetFlags = 0) {
322    return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
323  }
324  SDValue getConstantPool(MachineConstantPoolValue *C, EVT VT,
325                          unsigned Align = 0, int Offs = 0, bool isT=false,
326                          unsigned char TargetFlags = 0);
327  SDValue getTargetConstantPool(MachineConstantPoolValue *C,
328                                  EVT VT, unsigned Align = 0,
329                                  int Offset = 0, unsigned char TargetFlags=0) {
330    return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
331  }
332  // When generating a branch to a BB, we don't in general know enough
333  // to provide debug info for the BB at that time, so keep this one around.
334  SDValue getBasicBlock(MachineBasicBlock *MBB);
335  SDValue getBasicBlock(MachineBasicBlock *MBB, DebugLoc dl);
336  SDValue getExternalSymbol(const char *Sym, EVT VT);
337  SDValue getExternalSymbol(const char *Sym, DebugLoc dl, EVT VT);
338  SDValue getTargetExternalSymbol(const char *Sym, EVT VT,
339                                  unsigned char TargetFlags = 0);
340  SDValue getValueType(EVT);
341  SDValue getRegister(unsigned Reg, EVT VT);
342  SDValue getLabel(unsigned Opcode, DebugLoc dl, SDValue Root,
343                   unsigned LabelID);
344  SDValue getBlockAddress(BlockAddress *BA, EVT VT,
345                          bool isTarget = false, unsigned char TargetFlags = 0);
346
347  SDValue getCopyToReg(SDValue Chain, DebugLoc dl, unsigned Reg, SDValue N) {
348    return getNode(ISD::CopyToReg, dl, MVT::Other, Chain,
349                   getRegister(Reg, N.getValueType()), N);
350  }
351
352  // This version of the getCopyToReg method takes an extra operand, which
353  // indicates that there is potentially an incoming flag value (if Flag is not
354  // null) and that there should be a flag result.
355  SDValue getCopyToReg(SDValue Chain, DebugLoc dl, unsigned Reg, SDValue N,
356                       SDValue Flag) {
357    SDVTList VTs = getVTList(MVT::Other, MVT::Flag);
358    SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag };
359    return getNode(ISD::CopyToReg, dl, VTs, Ops, Flag.getNode() ? 4 : 3);
360  }
361
362  // Similar to last getCopyToReg() except parameter Reg is a SDValue
363  SDValue getCopyToReg(SDValue Chain, DebugLoc dl, SDValue Reg, SDValue N,
364                         SDValue Flag) {
365    SDVTList VTs = getVTList(MVT::Other, MVT::Flag);
366    SDValue Ops[] = { Chain, Reg, N, Flag };
367    return getNode(ISD::CopyToReg, dl, VTs, Ops, Flag.getNode() ? 4 : 3);
368  }
369
370  SDValue getCopyFromReg(SDValue Chain, DebugLoc dl, unsigned Reg, EVT VT) {
371    SDVTList VTs = getVTList(VT, MVT::Other);
372    SDValue Ops[] = { Chain, getRegister(Reg, VT) };
373    return getNode(ISD::CopyFromReg, dl, VTs, Ops, 2);
374  }
375
376  // This version of the getCopyFromReg method takes an extra operand, which
377  // indicates that there is potentially an incoming flag value (if Flag is not
378  // null) and that there should be a flag result.
379  SDValue getCopyFromReg(SDValue Chain, DebugLoc dl, unsigned Reg, EVT VT,
380                           SDValue Flag) {
381    SDVTList VTs = getVTList(VT, MVT::Other, MVT::Flag);
382    SDValue Ops[] = { Chain, getRegister(Reg, VT), Flag };
383    return getNode(ISD::CopyFromReg, dl, VTs, Ops, Flag.getNode() ? 3 : 2);
384  }
385
386  SDValue getCondCode(ISD::CondCode Cond);
387
388  /// Returns the ConvertRndSat Note: Avoid using this node because it may
389  /// disappear in the future and most targets don't support it.
390  SDValue getConvertRndSat(EVT VT, DebugLoc dl, SDValue Val, SDValue DTy,
391                           SDValue STy,
392                           SDValue Rnd, SDValue Sat, ISD::CvtCode Code);
393
394  /// getVectorShuffle - Return an ISD::VECTOR_SHUFFLE node.  The number of
395  /// elements in VT, which must be a vector type, must match the number of
396  /// mask elements NumElts.  A integer mask element equal to -1 is treated as
397  /// undefined.
398  SDValue getVectorShuffle(EVT VT, DebugLoc dl, SDValue N1, SDValue N2,
399                           const int *MaskElts);
400
401  /// getSExtOrTrunc - Convert Op, which must be of integer type, to the
402  /// integer type VT, by either sign-extending or truncating it.
403  SDValue getSExtOrTrunc(SDValue Op, DebugLoc DL, EVT VT);
404
405  /// getZExtOrTrunc - Convert Op, which must be of integer type, to the
406  /// integer type VT, by either zero-extending or truncating it.
407  SDValue getZExtOrTrunc(SDValue Op, DebugLoc DL, EVT VT);
408
409  /// getZeroExtendInReg - Return the expression required to zero extend the Op
410  /// value assuming it was the smaller SrcTy value.
411  SDValue getZeroExtendInReg(SDValue Op, DebugLoc DL, EVT SrcTy);
412
413  /// getNOT - Create a bitwise NOT operation as (XOR Val, -1).
414  SDValue getNOT(DebugLoc DL, SDValue Val, EVT VT);
415
416  /// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have
417  /// a flag result (to ensure it's not CSE'd).  CALLSEQ_START does not have a
418  /// useful DebugLoc.
419  SDValue getCALLSEQ_START(SDValue Chain, SDValue Op) {
420    SDVTList VTs = getVTList(MVT::Other, MVT::Flag);
421    SDValue Ops[] = { Chain,  Op };
422    return getNode(ISD::CALLSEQ_START, DebugLoc::getUnknownLoc(),
423                   VTs, Ops, 2);
424  }
425
426  /// getCALLSEQ_END - Return a new CALLSEQ_END node, which always must have a
427  /// flag result (to ensure it's not CSE'd).  CALLSEQ_END does not have
428  /// a useful DebugLoc.
429  SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2,
430                           SDValue InFlag) {
431    SDVTList NodeTys = getVTList(MVT::Other, MVT::Flag);
432    SmallVector<SDValue, 4> Ops;
433    Ops.push_back(Chain);
434    Ops.push_back(Op1);
435    Ops.push_back(Op2);
436    Ops.push_back(InFlag);
437    return getNode(ISD::CALLSEQ_END, DebugLoc::getUnknownLoc(), NodeTys,
438                   &Ops[0],
439                   (unsigned)Ops.size() - (InFlag.getNode() == 0 ? 1 : 0));
440  }
441
442  /// getUNDEF - Return an UNDEF node.  UNDEF does not have a useful DebugLoc.
443  SDValue getUNDEF(EVT VT) {
444    return getNode(ISD::UNDEF, DebugLoc::getUnknownLoc(), VT);
445  }
446
447  /// getGLOBAL_OFFSET_TABLE - Return a GLOBAL_OFFSET_TABLE node.  This does
448  /// not have a useful DebugLoc.
449  SDValue getGLOBAL_OFFSET_TABLE(EVT VT) {
450    return getNode(ISD::GLOBAL_OFFSET_TABLE, DebugLoc::getUnknownLoc(), VT);
451  }
452
453  /// getNode - Gets or creates the specified node.
454  ///
455  SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT);
456  SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT, SDValue N);
457  SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT, SDValue N1, SDValue N2);
458  SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
459                  SDValue N1, SDValue N2, SDValue N3);
460  SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
461                  SDValue N1, SDValue N2, SDValue N3, SDValue N4);
462  SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
463                  SDValue N1, SDValue N2, SDValue N3, SDValue N4,
464                  SDValue N5);
465  SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
466                  const SDUse *Ops, unsigned NumOps);
467  SDValue getNode(unsigned Opcode, DebugLoc DL, EVT VT,
468                  const SDValue *Ops, unsigned NumOps);
469  SDValue getNode(unsigned Opcode, DebugLoc DL,
470                  const std::vector<EVT> &ResultTys,
471                  const SDValue *Ops, unsigned NumOps);
472  SDValue getNode(unsigned Opcode, DebugLoc DL, const EVT *VTs, unsigned NumVTs,
473                  const SDValue *Ops, unsigned NumOps);
474  SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
475                  const SDValue *Ops, unsigned NumOps);
476  SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs);
477  SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs, SDValue N);
478  SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
479                  SDValue N1, SDValue N2);
480  SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
481                  SDValue N1, SDValue N2, SDValue N3);
482  SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
483                  SDValue N1, SDValue N2, SDValue N3, SDValue N4);
484  SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs,
485                  SDValue N1, SDValue N2, SDValue N3, SDValue N4,
486                  SDValue N5);
487
488  /// getStackArgumentTokenFactor - Compute a TokenFactor to force all
489  /// the incoming stack arguments to be loaded from the stack. This is
490  /// used in tail call lowering to protect stack arguments from being
491  /// clobbered.
492  SDValue getStackArgumentTokenFactor(SDValue Chain);
493
494  SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src,
495                    SDValue Size, unsigned Align, bool AlwaysInline,
496                    const Value *DstSV, uint64_t DstSVOff,
497                    const Value *SrcSV, uint64_t SrcSVOff);
498
499  SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src,
500                     SDValue Size, unsigned Align,
501                     const Value *DstSV, uint64_t DstOSVff,
502                     const Value *SrcSV, uint64_t SrcSVOff);
503
504  SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src,
505                    SDValue Size, unsigned Align,
506                    const Value *DstSV, uint64_t DstSVOff);
507
508  /// getSetCC - Helper function to make it easier to build SetCC's if you just
509  /// have an ISD::CondCode instead of an SDValue.
510  ///
511  SDValue getSetCC(DebugLoc DL, EVT VT, SDValue LHS, SDValue RHS,
512                   ISD::CondCode Cond) {
513    return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond));
514  }
515
516  /// getVSetCC - Helper function to make it easier to build VSetCC's nodes
517  /// if you just have an ISD::CondCode instead of an SDValue.
518  ///
519  SDValue getVSetCC(DebugLoc DL, EVT VT, SDValue LHS, SDValue RHS,
520                    ISD::CondCode Cond) {
521    return getNode(ISD::VSETCC, DL, VT, LHS, RHS, getCondCode(Cond));
522  }
523
524  /// getSelectCC - Helper function to make it easier to build SelectCC's if you
525  /// just have an ISD::CondCode instead of an SDValue.
526  ///
527  SDValue getSelectCC(DebugLoc DL, SDValue LHS, SDValue RHS,
528                      SDValue True, SDValue False, ISD::CondCode Cond) {
529    return getNode(ISD::SELECT_CC, DL, True.getValueType(),
530                   LHS, RHS, True, False, getCondCode(Cond));
531  }
532
533  /// getVAArg - VAArg produces a result and token chain, and takes a pointer
534  /// and a source value as input.
535  SDValue getVAArg(EVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr,
536                   SDValue SV);
537
538  /// getAtomic - Gets a node for an atomic op, produces result and chain and
539  /// takes 3 operands
540  SDValue getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain,
541                    SDValue Ptr, SDValue Cmp, SDValue Swp, const Value* PtrVal,
542                    unsigned Alignment=0);
543  SDValue getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain,
544                    SDValue Ptr, SDValue Cmp, SDValue Swp,
545                    MachineMemOperand *MMO);
546
547  /// getAtomic - Gets a node for an atomic op, produces result and chain and
548  /// takes 2 operands.
549  SDValue getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain,
550                    SDValue Ptr, SDValue Val, const Value* PtrVal,
551                    unsigned Alignment = 0);
552  SDValue getAtomic(unsigned Opcode, DebugLoc dl, EVT MemVT, SDValue Chain,
553                    SDValue Ptr, SDValue Val,
554                    MachineMemOperand *MMO);
555
556  /// getMemIntrinsicNode - Creates a MemIntrinsicNode that may produce a
557  /// result and takes a list of operands. Opcode may be INTRINSIC_VOID,
558  /// INTRINSIC_W_CHAIN, or a target-specific opcode with a value not
559  /// less than FIRST_TARGET_MEMORY_OPCODE.
560  SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl,
561                              const EVT *VTs, unsigned NumVTs,
562                              const SDValue *Ops, unsigned NumOps,
563                              EVT MemVT, const Value *srcValue, int SVOff,
564                              unsigned Align = 0, bool Vol = false,
565                              bool ReadMem = true, bool WriteMem = true);
566
567  SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl, SDVTList VTList,
568                              const SDValue *Ops, unsigned NumOps,
569                              EVT MemVT, const Value *srcValue, int SVOff,
570                              unsigned Align = 0, bool Vol = false,
571                              bool ReadMem = true, bool WriteMem = true);
572
573  SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl, SDVTList VTList,
574                              const SDValue *Ops, unsigned NumOps,
575                              EVT MemVT, MachineMemOperand *MMO);
576
577  /// getMergeValues - Create a MERGE_VALUES node from the given operands.
578  SDValue getMergeValues(const SDValue *Ops, unsigned NumOps, DebugLoc dl);
579
580  /// getLoad - Loads are not normal binary operators: their result type is not
581  /// determined by their operands, and they produce a value AND a token chain.
582  ///
583  SDValue getLoad(EVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr,
584                  const Value *SV, int SVOffset, bool isVolatile,
585                  bool isNonTemporal, unsigned Alignment);
586  SDValue getExtLoad(ISD::LoadExtType ExtType, DebugLoc dl, EVT VT,
587                     SDValue Chain, SDValue Ptr, const Value *SV,
588                     int SVOffset, EVT MemVT, bool isVolatile,
589                     bool isNonTemporal, unsigned Alignment);
590  SDValue getIndexedLoad(SDValue OrigLoad, DebugLoc dl, SDValue Base,
591                           SDValue Offset, ISD::MemIndexedMode AM);
592  SDValue getLoad(ISD::MemIndexedMode AM, DebugLoc dl, ISD::LoadExtType ExtType,
593                  EVT VT, SDValue Chain, SDValue Ptr, SDValue Offset,
594                  const Value *SV, int SVOffset, EVT MemVT,
595                  bool isVolatile, bool isNonTemporal, unsigned Alignment);
596  SDValue getLoad(ISD::MemIndexedMode AM, DebugLoc dl, ISD::LoadExtType ExtType,
597                  EVT VT, SDValue Chain, SDValue Ptr, SDValue Offset,
598                  EVT MemVT, MachineMemOperand *MMO);
599
600  /// getStore - Helper function to build ISD::STORE nodes.
601  ///
602  SDValue getStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
603                   const Value *SV, int SVOffset, bool isVolatile,
604                   bool isNonTemporal, unsigned Alignment);
605  SDValue getStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
606                   MachineMemOperand *MMO);
607  SDValue getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
608                        const Value *SV, int SVOffset, EVT TVT,
609                        bool isNonTemporal, bool isVolatile,
610                        unsigned Alignment);
611  SDValue getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr,
612                        EVT TVT, MachineMemOperand *MMO);
613  SDValue getIndexedStore(SDValue OrigStoe, DebugLoc dl, SDValue Base,
614                           SDValue Offset, ISD::MemIndexedMode AM);
615
616  /// getSrcValue - Construct a node to track a Value* through the backend.
617  SDValue getSrcValue(const Value *v);
618
619  /// getShiftAmountOperand - Return the specified value casted to
620  /// the target's desired shift amount type.
621  SDValue getShiftAmountOperand(SDValue Op);
622
623  /// UpdateNodeOperands - *Mutate* the specified node in-place to have the
624  /// specified operands.  If the resultant node already exists in the DAG,
625  /// this does not modify the specified node, instead it returns the node that
626  /// already exists.  If the resultant node does not exist in the DAG, the
627  /// input node is returned.  As a degenerate case, if you specify the same
628  /// input operands as the node already has, the input node is returned.
629  SDValue UpdateNodeOperands(SDValue N, SDValue Op);
630  SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2);
631  SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2,
632                               SDValue Op3);
633  SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2,
634                               SDValue Op3, SDValue Op4);
635  SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2,
636                               SDValue Op3, SDValue Op4, SDValue Op5);
637  SDValue UpdateNodeOperands(SDValue N,
638                               const SDValue *Ops, unsigned NumOps);
639
640  /// SelectNodeTo - These are used for target selectors to *mutate* the
641  /// specified node to have the specified return type, Target opcode, and
642  /// operands.  Note that target opcodes are stored as
643  /// ~TargetOpcode in the node opcode field.  The resultant node is returned.
644  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT);
645  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT, SDValue Op1);
646  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
647                       SDValue Op1, SDValue Op2);
648  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
649                       SDValue Op1, SDValue Op2, SDValue Op3);
650  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
651                       const SDValue *Ops, unsigned NumOps);
652  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, EVT VT2);
653  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
654                       EVT VT2, const SDValue *Ops, unsigned NumOps);
655  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
656                       EVT VT2, EVT VT3, const SDValue *Ops, unsigned NumOps);
657  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
658                       EVT VT2, EVT VT3, EVT VT4, const SDValue *Ops,
659                       unsigned NumOps);
660  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
661                       EVT VT2, SDValue Op1);
662  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
663                       EVT VT2, SDValue Op1, SDValue Op2);
664  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
665                       EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
666  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
667                       EVT VT2, EVT VT3, SDValue Op1, SDValue Op2, SDValue Op3);
668  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs,
669                       const SDValue *Ops, unsigned NumOps);
670
671  /// MorphNodeTo - This *mutates* the specified node to have the specified
672  /// return type, opcode, and operands.
673  SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs,
674                      const SDValue *Ops, unsigned NumOps);
675
676  /// getMachineNode - These are used for target selectors to create a new node
677  /// with specified return type(s), MachineInstr opcode, and operands.
678  ///
679  /// Note that getMachineNode returns the resultant node.  If there is already
680  /// a node of the specified opcode and operands, it returns that node instead
681  /// of the current one.
682  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT);
683  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT,
684                                SDValue Op1);
685  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT,
686                                SDValue Op1, SDValue Op2);
687  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT,
688                         SDValue Op1, SDValue Op2, SDValue Op3);
689  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT,
690                         const SDValue *Ops, unsigned NumOps);
691  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2);
692  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
693                         SDValue Op1);
694  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1,
695                         EVT VT2, SDValue Op1, SDValue Op2);
696  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1,
697                         EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
698  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
699                         const SDValue *Ops, unsigned NumOps);
700  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
701                         EVT VT3, SDValue Op1, SDValue Op2);
702  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
703                         EVT VT3, SDValue Op1, SDValue Op2, SDValue Op3);
704  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
705                         EVT VT3, const SDValue *Ops, unsigned NumOps);
706  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, EVT VT1, EVT VT2,
707                         EVT VT3, EVT VT4, const SDValue *Ops, unsigned NumOps);
708  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl,
709                         const std::vector<EVT> &ResultTys, const SDValue *Ops,
710                         unsigned NumOps);
711  MachineSDNode *getMachineNode(unsigned Opcode, DebugLoc dl, SDVTList VTs,
712                         const SDValue *Ops, unsigned NumOps);
713
714  /// getTargetExtractSubreg - A convenience function for creating
715  /// TargetInstrInfo::EXTRACT_SUBREG nodes.
716  SDValue getTargetExtractSubreg(int SRIdx, DebugLoc DL, EVT VT,
717                                 SDValue Operand);
718
719  /// getTargetInsertSubreg - A convenience function for creating
720  /// TargetInstrInfo::INSERT_SUBREG nodes.
721  SDValue getTargetInsertSubreg(int SRIdx, DebugLoc DL, EVT VT,
722                                SDValue Operand, SDValue Subreg);
723
724  /// getNodeIfExists - Get the specified node if it's already available, or
725  /// else return NULL.
726  SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs,
727                          const SDValue *Ops, unsigned NumOps);
728
729  /// DAGUpdateListener - Clients of various APIs that cause global effects on
730  /// the DAG can optionally implement this interface.  This allows the clients
731  /// to handle the various sorts of updates that happen.
732  class DAGUpdateListener {
733  public:
734    virtual ~DAGUpdateListener();
735
736    /// NodeDeleted - The node N that was deleted and, if E is not null, an
737    /// equivalent node E that replaced it.
738    virtual void NodeDeleted(SDNode *N, SDNode *E) = 0;
739
740    /// NodeUpdated - The node N that was updated.
741    virtual void NodeUpdated(SDNode *N) = 0;
742  };
743
744  /// RemoveDeadNode - Remove the specified node from the system. If any of its
745  /// operands then becomes dead, remove them as well. Inform UpdateListener
746  /// for each node deleted.
747  void RemoveDeadNode(SDNode *N, DAGUpdateListener *UpdateListener = 0);
748
749  /// RemoveDeadNodes - This method deletes the unreachable nodes in the
750  /// given list, and any nodes that become unreachable as a result.
751  void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes,
752                       DAGUpdateListener *UpdateListener = 0);
753
754  /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead.
755  /// This can cause recursive merging of nodes in the DAG.  Use the first
756  /// version if 'From' is known to have a single result, use the second
757  /// if you have two nodes with identical results (or if 'To' has a superset
758  /// of the results of 'From'), use the third otherwise.
759  ///
760  /// These methods all take an optional UpdateListener, which (if not null) is
761  /// informed about nodes that are deleted and modified due to recursive
762  /// changes in the dag.
763  ///
764  /// These functions only replace all existing uses. It's possible that as
765  /// these replacements are being performed, CSE may cause the From node
766  /// to be given new uses. These new uses of From are left in place, and
767  /// not automatically transfered to To.
768  ///
769  void ReplaceAllUsesWith(SDValue From, SDValue Op,
770                          DAGUpdateListener *UpdateListener = 0);
771  void ReplaceAllUsesWith(SDNode *From, SDNode *To,
772                          DAGUpdateListener *UpdateListener = 0);
773  void ReplaceAllUsesWith(SDNode *From, const SDValue *To,
774                          DAGUpdateListener *UpdateListener = 0);
775
776  /// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving
777  /// uses of other values produced by From.Val alone.
778  void ReplaceAllUsesOfValueWith(SDValue From, SDValue To,
779                                 DAGUpdateListener *UpdateListener = 0);
780
781  /// ReplaceAllUsesOfValuesWith - Like ReplaceAllUsesOfValueWith, but
782  /// for multiple values at once. This correctly handles the case where
783  /// there is an overlap between the From values and the To values.
784  void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To,
785                                  unsigned Num,
786                                  DAGUpdateListener *UpdateListener = 0);
787
788  /// AssignTopologicalOrder - Topological-sort the AllNodes list and a
789  /// assign a unique node id for each node in the DAG based on their
790  /// topological order. Returns the number of nodes.
791  unsigned AssignTopologicalOrder();
792
793  /// RepositionNode - Move node N in the AllNodes list to be immediately
794  /// before the given iterator Position. This may be used to update the
795  /// topological ordering when the list of nodes is modified.
796  void RepositionNode(allnodes_iterator Position, SDNode *N) {
797    AllNodes.insert(Position, AllNodes.remove(N));
798  }
799
800  /// isCommutativeBinOp - Returns true if the opcode is a commutative binary
801  /// operation.
802  static bool isCommutativeBinOp(unsigned Opcode) {
803    // FIXME: This should get its info from the td file, so that we can include
804    // target info.
805    switch (Opcode) {
806    case ISD::ADD:
807    case ISD::MUL:
808    case ISD::MULHU:
809    case ISD::MULHS:
810    case ISD::SMUL_LOHI:
811    case ISD::UMUL_LOHI:
812    case ISD::FADD:
813    case ISD::FMUL:
814    case ISD::AND:
815    case ISD::OR:
816    case ISD::XOR:
817    case ISD::SADDO:
818    case ISD::UADDO:
819    case ISD::ADDC:
820    case ISD::ADDE: return true;
821    default: return false;
822    }
823  }
824
825  /// AssignOrdering - Assign an order to the SDNode.
826  void AssignOrdering(const SDNode *SD, unsigned Order);
827
828  /// GetOrdering - Get the order for the SDNode.
829  unsigned GetOrdering(const SDNode *SD) const;
830
831  void dump() const;
832
833  /// CreateStackTemporary - Create a stack temporary, suitable for holding the
834  /// specified value type.  If minAlign is specified, the slot size will have
835  /// at least that alignment.
836  SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1);
837
838  /// CreateStackTemporary - Create a stack temporary suitable for holding
839  /// either of the specified value types.
840  SDValue CreateStackTemporary(EVT VT1, EVT VT2);
841
842  /// FoldConstantArithmetic -
843  SDValue FoldConstantArithmetic(unsigned Opcode,
844                                 EVT VT,
845                                 ConstantSDNode *Cst1,
846                                 ConstantSDNode *Cst2);
847
848  /// FoldSetCC - Constant fold a setcc to true or false.
849  SDValue FoldSetCC(EVT VT, SDValue N1,
850                    SDValue N2, ISD::CondCode Cond, DebugLoc dl);
851
852  /// SignBitIsZero - Return true if the sign bit of Op is known to be zero.  We
853  /// use this predicate to simplify operations downstream.
854  bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const;
855
856  /// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero.  We
857  /// use this predicate to simplify operations downstream.  Op and Mask are
858  /// known to be the same type.
859  bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth = 0)
860    const;
861
862  /// ComputeMaskedBits - Determine which of the bits specified in Mask are
863  /// known to be either zero or one and return them in the KnownZero/KnownOne
864  /// bitsets.  This code only analyzes bits in Mask, in order to short-circuit
865  /// processing.  Targets can implement the computeMaskedBitsForTargetNode
866  /// method in the TargetLowering class to allow target nodes to be understood.
867  void ComputeMaskedBits(SDValue Op, const APInt &Mask, APInt &KnownZero,
868                         APInt &KnownOne, unsigned Depth = 0) const;
869
870  /// ComputeNumSignBits - Return the number of times the sign bit of the
871  /// register is replicated into the other bits.  We know that at least 1 bit
872  /// is always equal to the sign bit (itself), but other cases can give us
873  /// information.  For example, immediately after an "SRA X, 2", we know that
874  /// the top 3 bits are all equal to each other, so we return 3.  Targets can
875  /// implement the ComputeNumSignBitsForTarget method in the TargetLowering
876  /// class to allow target nodes to be understood.
877  unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const;
878
879  /// isKnownNeverNan - Test whether the given SDValue is known to never be NaN.
880  bool isKnownNeverNaN(SDValue Op) const;
881
882  /// isKnownNeverZero - Test whether the given SDValue is known to never be
883  /// positive or negative Zero.
884  bool isKnownNeverZero(SDValue Op) const;
885
886  /// isEqualTo - Test whether two SDValues are known to compare equal. This
887  /// is true if they are the same value, or if one is negative zero and the
888  /// other positive zero.
889  bool isEqualTo(SDValue A, SDValue B) const;
890
891  /// isVerifiedDebugInfoDesc - Returns true if the specified SDValue has
892  /// been verified as a debug information descriptor.
893  bool isVerifiedDebugInfoDesc(SDValue Op) const;
894
895  /// getShuffleScalarElt - Returns the scalar element that will make up the ith
896  /// element of the result of the vector shuffle.
897  SDValue getShuffleScalarElt(const ShuffleVectorSDNode *N, unsigned Idx);
898
899  /// UnrollVectorOp - Utility function used by legalize and lowering to
900  /// "unroll" a vector operation by splitting out the scalars and operating
901  /// on each element individually.  If the ResNE is 0, fully unroll the vector
902  /// op. If ResNE is less than the width of the vector op, unroll up to ResNE.
903  /// If the  ResNE is greater than the width of the vector op, unroll the
904  /// vector op and fill the end of the resulting vector with UNDEFS.
905  SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
906
907  /// isConsecutiveLoad - Return true if LD is loading 'Bytes' bytes from a
908  /// location that is 'Dist' units away from the location that the 'Base' load
909  /// is loading from.
910  bool isConsecutiveLoad(LoadSDNode *LD, LoadSDNode *Base,
911                         unsigned Bytes, int Dist) const;
912
913  /// InferPtrAlignment - Infer alignment of a load / store address. Return 0 if
914  /// it cannot be inferred.
915  unsigned InferPtrAlignment(SDValue Ptr) const;
916
917private:
918  bool RemoveNodeFromCSEMaps(SDNode *N);
919  void AddModifiedNodeToCSEMaps(SDNode *N, DAGUpdateListener *UpdateListener);
920  SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos);
921  SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2,
922                               void *&InsertPos);
923  SDNode *FindModifiedNodeSlot(SDNode *N, const SDValue *Ops, unsigned NumOps,
924                               void *&InsertPos);
925
926  void DeleteNodeNotInCSEMaps(SDNode *N);
927  void DeallocateNode(SDNode *N);
928
929  unsigned getEVTAlignment(EVT MemoryVT) const;
930
931  void allnodes_clear();
932
933  /// VTList - List of non-single value types.
934  std::vector<SDVTList> VTList;
935
936  /// CondCodeNodes - Maps to auto-CSE operations.
937  std::vector<CondCodeSDNode*> CondCodeNodes;
938
939  std::vector<SDNode*> ValueTypeNodes;
940  std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes;
941  StringMap<SDNode*> ExternalSymbols;
942
943  std::map<std::pair<std::string, unsigned char>,SDNode*> TargetExternalSymbols;
944};
945
946template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
947  typedef SelectionDAG::allnodes_iterator nodes_iterator;
948  static nodes_iterator nodes_begin(SelectionDAG *G) {
949    return G->allnodes_begin();
950  }
951  static nodes_iterator nodes_end(SelectionDAG *G) {
952    return G->allnodes_end();
953  }
954};
955
956}  // end namespace llvm
957
958#endif
959