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