Merge ISD::TRUNCSTORE to ISD::STORE. Switch to using StoreSDNode.
[oota-llvm.git] / include / llvm / CodeGen / SelectionDAG.h
1 //===-- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source 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/CodeGen/SelectionDAGCSEMap.h"
19 #include "llvm/ADT/ilist"
20
21 #include <list>
22 #include <vector>
23 #include <map>
24 #include <set>
25 #include <string>
26
27 namespace llvm {
28   class TargetLowering;
29   class TargetMachine;
30   class MachineDebugInfo;
31   class MachineFunction;
32   class MachineConstantPoolValue;
33
34 /// SelectionDAG class - This is used to represent a portion of an LLVM function
35 /// in a low-level Data Dependence DAG representation suitable for instruction
36 /// selection.  This DAG is constructed as the first step of instruction
37 /// selection in order to allow implementation of machine specific optimizations
38 /// and code simplifications.
39 ///
40 /// The representation used by the SelectionDAG is a target-independent
41 /// representation, which has some similarities to the GCC RTL representation,
42 /// but is significantly more simple, powerful, and is a graph form instead of a
43 /// linear form.
44 ///
45 class SelectionDAG {
46   TargetLowering &TLI;
47   MachineFunction &MF;
48   MachineDebugInfo *DI;
49
50   /// Root - The root of the entire DAG.  EntryNode - The starting token.
51   SDOperand Root, EntryNode;
52
53   /// AllNodes - A linked list of nodes in the current DAG.
54   ilist<SDNode> AllNodes;
55
56   /// CSEMap - This structure is used to memoize nodes, automatically performing
57   /// CSE with existing nodes with a duplicate is requested.
58   SelectionDAGCSEMap CSEMap;
59
60 public:
61   SelectionDAG(TargetLowering &tli, MachineFunction &mf, MachineDebugInfo *di)
62   : TLI(tli), MF(mf), DI(di) {
63     EntryNode = Root = getNode(ISD::EntryToken, MVT::Other);
64   }
65   ~SelectionDAG();
66
67   MachineFunction &getMachineFunction() const { return MF; }
68   const TargetMachine &getTarget() const;
69   TargetLowering &getTargetLoweringInfo() const { return TLI; }
70   MachineDebugInfo *getMachineDebugInfo() const { return DI; }
71
72   /// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
73   ///
74   void viewGraph();
75   
76 #ifndef NDEBUG
77   std::map<const SDNode *, std::string> NodeGraphAttrs;
78 #endif
79
80   /// clearGraphAttrs - Clear all previously defined node graph attributes.
81   /// Intended to be used from a debugging tool (eg. gdb).
82   void clearGraphAttrs();
83   
84   /// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".)
85   ///
86   void setGraphAttrs(const SDNode *N, const char *Attrs);
87   
88   /// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".)
89   /// Used from getNodeAttributes.
90   const std::string getGraphAttrs(const SDNode *N) const;
91   
92   /// setGraphColor - Convenience for setting node color attribute.
93   ///
94   void setGraphColor(const SDNode *N, const char *Color);
95
96   typedef ilist<SDNode>::const_iterator allnodes_const_iterator;
97   allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
98   allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
99   typedef ilist<SDNode>::iterator allnodes_iterator;
100   allnodes_iterator allnodes_begin() { return AllNodes.begin(); }
101   allnodes_iterator allnodes_end() { return AllNodes.end(); }
102   
103   /// getRoot - Return the root tag of the SelectionDAG.
104   ///
105   const SDOperand &getRoot() const { return Root; }
106
107   /// getEntryNode - Return the token chain corresponding to the entry of the
108   /// function.
109   const SDOperand &getEntryNode() const { return EntryNode; }
110
111   /// setRoot - Set the current root tag of the SelectionDAG.
112   ///
113   const SDOperand &setRoot(SDOperand N) { return Root = N; }
114
115   /// Combine - This iterates over the nodes in the SelectionDAG, folding
116   /// certain types of nodes together, or eliminating superfluous nodes.  When
117   /// the AfterLegalize argument is set to 'true', Combine takes care not to
118   /// generate any nodes that will be illegal on the target.
119   void Combine(bool AfterLegalize);
120   
121   /// Legalize - This transforms the SelectionDAG into a SelectionDAG that is
122   /// compatible with the target instruction selector, as indicated by the
123   /// TargetLowering object.
124   ///
125   /// Note that this is an involved process that may invalidate pointers into
126   /// the graph.
127   void Legalize();
128
129   /// RemoveDeadNodes - This method deletes all unreachable nodes in the
130   /// SelectionDAG.
131   void RemoveDeadNodes();
132
133   /// RemoveDeadNode - Remove the specified node from the system. If any of its
134   /// operands then becomes dead, remove them as well. The vector Deleted is
135   /// populated with nodes that are deleted.
136   void RemoveDeadNode(SDNode *N, std::vector<SDNode*> &Deleted);
137   
138   /// DeleteNode - Remove the specified node from the system.  This node must
139   /// have no referrers.
140   void DeleteNode(SDNode *N);
141
142   /// getVTList - Return an SDVTList that represents the list of values
143   /// specified.
144   SDVTList getVTList(MVT::ValueType VT);
145   SDVTList getVTList(MVT::ValueType VT1, MVT::ValueType VT2);
146   SDVTList getVTList(MVT::ValueType VT1, MVT::ValueType VT2,MVT::ValueType VT3);
147   SDVTList getVTList(const MVT::ValueType *VTs, unsigned NumVTs);
148   
149   /// getNodeValueTypes - These are obsolete, use getVTList instead.
150   const MVT::ValueType *getNodeValueTypes(MVT::ValueType VT) {
151     return getVTList(VT).VTs;
152   }
153   const MVT::ValueType *getNodeValueTypes(MVT::ValueType VT1, 
154                                           MVT::ValueType VT2) {
155     return getVTList(VT1, VT2).VTs;
156   }
157   const MVT::ValueType *getNodeValueTypes(MVT::ValueType VT1,MVT::ValueType VT2,
158                                           MVT::ValueType VT3) {
159     return getVTList(VT1, VT2, VT3).VTs;
160   }
161   const MVT::ValueType *getNodeValueTypes(std::vector<MVT::ValueType> &VTList) {
162     return getVTList(&VTList[0], VTList.size()).VTs;
163   }
164   
165   
166   //===--------------------------------------------------------------------===//
167   // Node creation methods.
168   //
169   SDOperand getString(const std::string &Val);
170   SDOperand getConstant(uint64_t Val, MVT::ValueType VT, bool isTarget = false);
171   SDOperand getTargetConstant(uint64_t Val, MVT::ValueType VT) {
172     return getConstant(Val, VT, true);
173   }
174   SDOperand getConstantFP(double Val, MVT::ValueType VT, bool isTarget = false);
175   SDOperand getTargetConstantFP(double Val, MVT::ValueType VT) {
176     return getConstantFP(Val, VT, true);
177   }
178   SDOperand getGlobalAddress(const GlobalValue *GV, MVT::ValueType VT,
179                              int offset = 0, bool isTargetGA = false);
180   SDOperand getTargetGlobalAddress(const GlobalValue *GV, MVT::ValueType VT,
181                                    int offset = 0) {
182     return getGlobalAddress(GV, VT, offset, true);
183   }
184   SDOperand getFrameIndex(int FI, MVT::ValueType VT, bool isTarget = false);
185   SDOperand getTargetFrameIndex(int FI, MVT::ValueType VT) {
186     return getFrameIndex(FI, VT, true);
187   }
188   SDOperand getJumpTable(int JTI, MVT::ValueType VT, bool isTarget = false);
189   SDOperand getTargetJumpTable(int JTI, MVT::ValueType VT) {
190     return getJumpTable(JTI, VT, true);
191   }
192   SDOperand getConstantPool(Constant *C, MVT::ValueType VT,
193                             unsigned Align = 0, int Offs = 0, bool isT=false);
194   SDOperand getTargetConstantPool(Constant *C, MVT::ValueType VT,
195                                   unsigned Align = 0, int Offset = 0) {
196     return getConstantPool(C, VT, Align, Offset, true);
197   }
198   SDOperand getConstantPool(MachineConstantPoolValue *C, MVT::ValueType VT,
199                             unsigned Align = 0, int Offs = 0, bool isT=false);
200   SDOperand getTargetConstantPool(MachineConstantPoolValue *C,
201                                   MVT::ValueType VT, unsigned Align = 0,
202                                   int Offset = 0) {
203     return getConstantPool(C, VT, Align, Offset, true);
204   }
205   SDOperand getBasicBlock(MachineBasicBlock *MBB);
206   SDOperand getExternalSymbol(const char *Sym, MVT::ValueType VT);
207   SDOperand getTargetExternalSymbol(const char *Sym, MVT::ValueType VT);
208   SDOperand getValueType(MVT::ValueType);
209   SDOperand getRegister(unsigned Reg, MVT::ValueType VT);
210
211   SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N) {
212     return getNode(ISD::CopyToReg, MVT::Other, Chain,
213                    getRegister(Reg, N.getValueType()), N);
214   }
215
216   // This version of the getCopyToReg method takes an extra operand, which
217   // indicates that there is potentially an incoming flag value (if Flag is not
218   // null) and that there should be a flag result.
219   SDOperand getCopyToReg(SDOperand Chain, unsigned Reg, SDOperand N,
220                          SDOperand Flag) {
221     const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
222     SDOperand Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag };
223     return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.Val ? 4 : 3);
224   }
225
226   // Similar to last getCopyToReg() except parameter Reg is a SDOperand
227   SDOperand getCopyToReg(SDOperand Chain, SDOperand Reg, SDOperand N,
228                          SDOperand Flag) {
229     const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
230     SDOperand Ops[] = { Chain, Reg, N, Flag };
231     return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.Val ? 4 : 3);
232   }
233   
234   SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT) {
235     const MVT::ValueType *VTs = getNodeValueTypes(VT, MVT::Other);
236     SDOperand Ops[] = { Chain, getRegister(Reg, VT) };
237     return getNode(ISD::CopyFromReg, VTs, 2, Ops, 2);
238   }
239   
240   // This version of the getCopyFromReg method takes an extra operand, which
241   // indicates that there is potentially an incoming flag value (if Flag is not
242   // null) and that there should be a flag result.
243   SDOperand getCopyFromReg(SDOperand Chain, unsigned Reg, MVT::ValueType VT,
244                            SDOperand Flag) {
245     const MVT::ValueType *VTs = getNodeValueTypes(VT, MVT::Other, MVT::Flag);
246     SDOperand Ops[] = { Chain, getRegister(Reg, VT), Flag };
247     return getNode(ISD::CopyFromReg, VTs, 3, Ops, Flag.Val ? 3 : 2);
248   }
249
250   SDOperand getCondCode(ISD::CondCode Cond);
251
252   /// getZeroExtendInReg - Return the expression required to zero extend the Op
253   /// value assuming it was the smaller SrcTy value.
254   SDOperand getZeroExtendInReg(SDOperand Op, MVT::ValueType SrcTy);
255   
256   /// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have
257   /// a flag result (to ensure it's not CSE'd).
258   SDOperand getCALLSEQ_START(SDOperand Chain, SDOperand Op) {
259     const MVT::ValueType *VTs = getNodeValueTypes(MVT::Other, MVT::Flag);
260     SDOperand Ops[] = { Chain,  Op };
261     return getNode(ISD::CALLSEQ_START, VTs, 2, Ops, 2);
262   }
263
264   /// getNode - Gets or creates the specified node.
265   ///
266   SDOperand getNode(unsigned Opcode, MVT::ValueType VT);
267   SDOperand getNode(unsigned Opcode, MVT::ValueType VT, SDOperand N);
268   SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
269                     SDOperand N1, SDOperand N2);
270   SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
271                     SDOperand N1, SDOperand N2, SDOperand N3);
272   SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
273                     SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4);
274   SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
275                     SDOperand N1, SDOperand N2, SDOperand N3, SDOperand N4,
276                     SDOperand N5);
277   SDOperand getNode(unsigned Opcode, MVT::ValueType VT,
278                     const SDOperand *Ops, unsigned NumOps);
279   SDOperand getNode(unsigned Opcode, std::vector<MVT::ValueType> &ResultTys,
280                     const SDOperand *Ops, unsigned NumOps);
281   SDOperand getNode(unsigned Opcode, const MVT::ValueType *VTs, unsigned NumVTs,
282                     const SDOperand *Ops, unsigned NumOps);
283   SDOperand getNode(unsigned Opcode, SDVTList VTs,
284                     const SDOperand *Ops, unsigned NumOps);
285   
286   /// getSetCC - Helper function to make it easier to build SetCC's if you just
287   /// have an ISD::CondCode instead of an SDOperand.
288   ///
289   SDOperand getSetCC(MVT::ValueType VT, SDOperand LHS, SDOperand RHS,
290                      ISD::CondCode Cond) {
291     return getNode(ISD::SETCC, VT, LHS, RHS, getCondCode(Cond));
292   }
293
294   /// getSelectCC - Helper function to make it easier to build SelectCC's if you
295   /// just have an ISD::CondCode instead of an SDOperand.
296   ///
297   SDOperand getSelectCC(SDOperand LHS, SDOperand RHS,
298                         SDOperand True, SDOperand False, ISD::CondCode Cond) {
299     return getNode(ISD::SELECT_CC, True.getValueType(), LHS, RHS, True, False,
300                    getCondCode(Cond));
301   }
302   
303   /// getVAArg - VAArg produces a result and token chain, and takes a pointer
304   /// and a source value as input.
305   SDOperand getVAArg(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
306                      SDOperand SV);
307
308   /// getLoad - Loads are not normal binary operators: their result type is not
309   /// determined by their operands, and they produce a value AND a token chain.
310   ///
311   SDOperand getLoad(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
312                     const Value *SV, int SVOffset, bool isVolatile=false);
313   SDOperand getExtLoad(ISD::LoadExtType ExtType, MVT::ValueType VT,
314                        SDOperand Chain, SDOperand Ptr, const Value *SV,
315                        int SVOffset, MVT::ValueType EVT, bool isVolatile=false);
316   SDOperand getVecLoad(unsigned Count, MVT::ValueType VT, SDOperand Chain, 
317                        SDOperand Ptr, SDOperand SV);
318
319   /// getStore - Helper function to build ISD::STORE nodes.
320   ///
321   SDOperand getStore(SDOperand Chain, SDOperand Value, SDOperand Ptr,
322                      const Value *SV, int SVOffset, bool isVolatile=false);
323   SDOperand getTruncStore(SDOperand Chain, SDOperand Value, SDOperand Ptr,
324                           const Value *SV, int SVOffset, MVT::ValueType TVT,
325                           bool isVolatile=false);
326
327   // getSrcValue - construct a node to track a Value* through the backend
328   SDOperand getSrcValue(const Value* I, int offset = 0);
329
330   /// UpdateNodeOperands - *Mutate* the specified node in-place to have the
331   /// specified operands.  If the resultant node already exists in the DAG,
332   /// this does not modify the specified node, instead it returns the node that
333   /// already exists.  If the resultant node does not exist in the DAG, the
334   /// input node is returned.  As a degenerate case, if you specify the same
335   /// input operands as the node already has, the input node is returned.
336   SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op);
337   SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2);
338   SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
339                                SDOperand Op3);
340   SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
341                                SDOperand Op3, SDOperand Op4);
342   SDOperand UpdateNodeOperands(SDOperand N, SDOperand Op1, SDOperand Op2,
343                                SDOperand Op3, SDOperand Op4, SDOperand Op5);
344   SDOperand UpdateNodeOperands(SDOperand N, SDOperand *Ops, unsigned NumOps);
345   
346   /// SelectNodeTo - These are used for target selectors to *mutate* the
347   /// specified node to have the specified return type, Target opcode, and
348   /// operands.  Note that target opcodes are stored as
349   /// ISD::BUILTIN_OP_END+TargetOpcode in the node opcode field.  The 0th value
350   /// of the resultant node is returned.
351   SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT);
352   SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT, 
353                        SDOperand Op1);
354   SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT, 
355                        SDOperand Op1, SDOperand Op2);
356   SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT, 
357                        SDOperand Op1, SDOperand Op2, SDOperand Op3);
358   SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT,
359                         const SDOperand *Ops, unsigned NumOps);
360   SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1, 
361                        MVT::ValueType VT2, SDOperand Op1, SDOperand Op2);
362   SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT::ValueType VT1,
363                        MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
364                        SDOperand Op3);
365
366
367   /// getTargetNode - These are used for target selectors to create a new node
368   /// with specified return type(s), target opcode, and operands.
369   ///
370   /// Note that getTargetNode returns the resultant node.  If there is already a
371   /// node of the specified opcode and operands, it returns that node instead of
372   /// the current one.
373   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT);
374   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
375                         SDOperand Op1);
376   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
377                         SDOperand Op1, SDOperand Op2);
378   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
379                         SDOperand Op1, SDOperand Op2, SDOperand Op3);
380   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT,
381                         const SDOperand *Ops, unsigned NumOps);
382   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
383                         MVT::ValueType VT2, SDOperand Op1);
384   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
385                         MVT::ValueType VT2, SDOperand Op1, SDOperand Op2);
386   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
387                         MVT::ValueType VT2, SDOperand Op1, SDOperand Op2,
388                         SDOperand Op3);
389   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, 
390                         MVT::ValueType VT2,
391                         const SDOperand *Ops, unsigned NumOps);
392   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1,
393                         MVT::ValueType VT2, MVT::ValueType VT3,
394                         SDOperand Op1, SDOperand Op2);
395   SDNode *getTargetNode(unsigned Opcode, MVT::ValueType VT1, 
396                         MVT::ValueType VT2, MVT::ValueType VT3,
397                         const SDOperand *Ops, unsigned NumOps);
398   
399   /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead.
400   /// This can cause recursive merging of nodes in the DAG.  Use the first
401   /// version if 'From' is known to have a single result, use the second
402   /// if you have two nodes with identical results, use the third otherwise.
403   ///
404   /// These methods all take an optional vector, which (if not null) is 
405   /// populated with any nodes that are deleted from the SelectionDAG, due to
406   /// new equivalences that are discovered.
407   ///
408   void ReplaceAllUsesWith(SDOperand From, SDOperand Op,
409                           std::vector<SDNode*> *Deleted = 0);
410   void ReplaceAllUsesWith(SDNode *From, SDNode *To,
411                           std::vector<SDNode*> *Deleted = 0);
412   void ReplaceAllUsesWith(SDNode *From, const SDOperand *To,
413                           std::vector<SDNode*> *Deleted = 0);
414
415   /// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving
416   /// uses of other values produced by From.Val alone.  The Deleted vector is
417   /// handled the same was as for ReplaceAllUsesWith, but it is required for
418   /// this method.
419   void ReplaceAllUsesOfValueWith(SDOperand From, SDOperand To,
420                                  std::vector<SDNode*> &Deleted);
421
422   /// AssignNodeIds - Assign a unique node id for each node in the DAG based on
423   /// their allnodes order. It returns the maximum id.
424   unsigned AssignNodeIds();
425
426   /// AssignTopologicalOrder - Assign a unique node id for each node in the DAG
427   /// based on their topological order. It returns the maximum id and a vector
428   /// of the SDNodes* in assigned order by reference.
429   unsigned AssignTopologicalOrder(std::vector<SDNode*> &TopOrder);
430
431   /// isCommutativeBinOp - Returns true if the opcode is a commutative binary
432   /// operation.
433   static bool isCommutativeBinOp(unsigned Opcode) {
434     switch (Opcode) {
435     case ISD::ADD:
436     case ISD::MUL:
437     case ISD::MULHU:
438     case ISD::MULHS:
439     case ISD::FADD:
440     case ISD::FMUL:
441     case ISD::AND:
442     case ISD::OR:
443     case ISD::XOR:
444     case ISD::ADDC: 
445     case ISD::ADDE: return true;
446     default: return false;
447     }
448   }
449
450   void dump() const;
451
452 private:
453   void RemoveNodeFromCSEMaps(SDNode *N);
454   SDNode *AddNonLeafNodeToCSEMaps(SDNode *N);
455   SDNode *FindModifiedNodeSlot(SDNode *N, SDOperand Op, void *&InsertPos);
456   SDNode *FindModifiedNodeSlot(SDNode *N, SDOperand Op1, SDOperand Op2,
457                                void *&InsertPos);
458   SDNode *FindModifiedNodeSlot(SDNode *N, const SDOperand *Ops, unsigned NumOps,
459                                void *&InsertPos);
460
461   void DeleteNodeNotInCSEMaps(SDNode *N);
462   
463   /// SimplifySetCC - Try to simplify a setcc built with the specified operands 
464   /// and cc.  If unable to simplify it, return a null SDOperand.
465   SDOperand SimplifySetCC(MVT::ValueType VT, SDOperand N1,
466                           SDOperand N2, ISD::CondCode Cond);
467   
468   // List of non-single value types.
469   std::list<std::vector<MVT::ValueType> > VTList;
470   
471   // Maps to auto-CSE operations.
472   std::vector<CondCodeSDNode*> CondCodeNodes;
473
474   std::vector<SDNode*> ValueTypeNodes;
475   std::map<std::string, SDNode*> ExternalSymbols;
476   std::map<std::string, SDNode*> TargetExternalSymbols;
477   std::map<std::string, StringSDNode*> StringNodes;
478 };
479
480 template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
481   typedef SelectionDAG::allnodes_iterator nodes_iterator;
482   static nodes_iterator nodes_begin(SelectionDAG *G) {
483     return G->allnodes_begin();
484   }
485   static nodes_iterator nodes_end(SelectionDAG *G) {
486     return G->allnodes_end();
487   }
488 };
489
490 }  // end namespace llvm
491
492 #endif