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