Do some code refactoring on Jim's scheduler in preparation of the new list
[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 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 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/Pass.h"
19 #include "llvm/CodeGen/ValueTypes.h"
20
21 namespace llvm {
22   class SelectionDAG;
23   class SelectionDAGLowering;
24   class SDOperand;
25   class SSARegMap;
26   class MachineBasicBlock;
27   class MachineFunction;
28   class MachineInstr;
29   class TargetLowering;
30   class FunctionLoweringInfo;
31
32 /// SelectionDAGISel - This is the common base class used for SelectionDAG-based
33 /// pattern-matching instruction selectors.
34 class SelectionDAGISel : public FunctionPass {
35 public:
36   TargetLowering &TLI;
37   SSARegMap *RegMap;
38   SelectionDAG *CurDAG;
39   MachineBasicBlock *BB;
40
41   SelectionDAGISel(TargetLowering &tli) : TLI(tli) {}
42
43   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
44
45   virtual bool runOnFunction(Function &Fn);
46
47   unsigned MakeReg(MVT::ValueType VT);
48
49   virtual void EmitFunctionEntryCode(Function &Fn, MachineFunction &MF) {}
50   virtual void InstructionSelectBasicBlock(SelectionDAG &SD) = 0;
51
52 protected:
53   /// Pick a safe ordering and emit instructions for each target node in the
54   /// graph.
55   void ScheduleAndEmitDAG(SelectionDAG &DAG);
56   
57 private:
58   SDOperand CopyValueToVirtualRegister(SelectionDAGLowering &SDL,
59                                        Value *V, unsigned Reg);
60   void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF,
61                         FunctionLoweringInfo &FuncInfo);
62
63   void BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
64            std::vector<std::pair<MachineInstr*, unsigned> > &PHINodesToUpdate,
65                          FunctionLoweringInfo &FuncInfo);
66   void LowerArguments(BasicBlock *BB, SelectionDAGLowering &SDL,
67                       std::vector<SDOperand> &UnorderedChains);
68 };
69
70 }
71
72 #endif /* LLVM_CODEGEN_SELECTIONDAG_ISEL_H */