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