Reverting r56249. On further investigation, this functionality isn't needed.
[oota-llvm.git] / include / llvm / CodeGen / SelectionDAGISel.h
1 //===-- llvm/CodeGen/SelectionDAGISel.h - Common Base Class------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the SelectionDAGISel class, which is used as the common
11 // base class for SelectionDAG-based instruction selectors.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_SELECTIONDAG_ISEL_H
16 #define LLVM_CODEGEN_SELECTIONDAG_ISEL_H
17
18 #include "llvm/BasicBlock.h"
19 #include "llvm/Pass.h"
20 #include "llvm/Constant.h"
21 #include "llvm/CodeGen/SelectionDAG.h"
22
23 namespace llvm {
24   class FastISel;
25   class SelectionDAGLowering;
26   class SDValue;
27   class MachineRegisterInfo;
28   class MachineBasicBlock;
29   class MachineFunction;
30   class MachineInstr;
31   class TargetLowering;
32   class FunctionLoweringInfo;
33   class HazardRecognizer;
34   class GCFunctionInfo;
35   class ScheduleDAG;
36  
37 /// SelectionDAGISel - This is the common base class used for SelectionDAG-based
38 /// pattern-matching instruction selectors.
39 class SelectionDAGISel : public FunctionPass {
40 public:
41   TargetLowering &TLI;
42   MachineRegisterInfo *RegInfo;
43   FunctionLoweringInfo *FuncInfo;
44   SelectionDAG *CurDAG;
45   SelectionDAGLowering *SDL;
46   MachineBasicBlock *BB;
47   AliasAnalysis *AA;
48   GCFunctionInfo *GFI;
49   bool Fast;
50   std::vector<SDNode*> TopOrder;
51   static char ID;
52
53   explicit SelectionDAGISel(TargetLowering &tli, bool fast = false);
54   virtual ~SelectionDAGISel();
55   
56   TargetLowering &getTargetLowering() { return TLI; }
57
58   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
59
60   virtual bool runOnFunction(Function &Fn);
61
62   unsigned MakeReg(MVT VT);
63
64   virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {}
65   virtual void InstructionSelect() = 0;
66   virtual void InstructionSelectPostProcessing() {}
67   
68   void SelectRootInit() {
69     DAGSize = CurDAG->AssignTopologicalOrder(TopOrder);
70   }
71
72   /// SelectInlineAsmMemoryOperand - Select the specified address as a target
73   /// addressing mode, according to the specified constraint code.  If this does
74   /// not match or is not implemented, return true.  The resultant operands
75   /// (which will appear in the machine instruction) should be added to the
76   /// OutOps vector.
77   virtual bool SelectInlineAsmMemoryOperand(const SDValue &Op,
78                                             char ConstraintCode,
79                                             std::vector<SDValue> &OutOps) {
80     return true;
81   }
82
83   /// CanBeFoldedBy - Returns true if the specific operand node N of U can be
84   /// folded during instruction selection that starts at Root?
85   virtual bool CanBeFoldedBy(SDNode *N, SDNode *U, SDNode *Root) const {
86     return true;
87   }
88   
89   /// CreateTargetHazardRecognizer - Return a newly allocated hazard recognizer
90   /// to use for this target when scheduling the DAG.
91   virtual HazardRecognizer *CreateTargetHazardRecognizer();
92   
93 protected:
94   /// DAGSize - Size of DAG being instruction selected.
95   ///
96   unsigned DAGSize;
97
98   /// SelectInlineAsmMemoryOperands - Calls to this are automatically generated
99   /// by tblgen.  Others should not call it.
100   void SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops);
101
102   // Calls to these predicates are generated by tblgen.
103   bool CheckAndMask(SDValue LHS, ConstantSDNode *RHS,
104                     int64_t DesiredMaskS) const;
105   bool CheckOrMask(SDValue LHS, ConstantSDNode *RHS,
106                     int64_t DesiredMaskS) const;
107   
108 private:
109   void SelectAllBasicBlocks(Function &Fn, MachineFunction &MF);
110   void FinishBasicBlock();
111
112   void SelectBasicBlock(BasicBlock *LLVMBB,
113                         BasicBlock::iterator Begin,
114                         BasicBlock::iterator End);
115   void CodeGenAndEmitDAG();
116   void LowerArguments(BasicBlock *BB);
117   
118   void ComputeLiveOutVRegInfo();
119
120   void HandlePHINodesInSuccessorBlocks(BasicBlock *LLVMBB);
121
122   bool HandlePHINodesInSuccessorBlocksFast(BasicBlock *LLVMBB, FastISel *F);
123
124   /// Pick a safe ordering for instructions for each target node in the
125   /// graph.
126   ScheduleDAG *Schedule();
127 };
128
129 }
130
131 #endif /* LLVM_CODEGEN_SELECTIONDAG_ISEL_H */