Initial checkin of the new "fast" instruction selection support. See
[oota-llvm.git] / include / llvm / CodeGen / FastISel.h
1 //===-- FastISel.h - Definition of the FastISel class ---------------------===//
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 defines the FastISel class.
11 //  
12 //===----------------------------------------------------------------------===//
13   
14 #ifndef LLVM_CODEGEN_FASTISEL_H
15 #define LLVM_CODEGEN_FASTISEL_H
16
17 #include "llvm/BasicBlock.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/CodeGen/SelectionDAGNodes.h"
20
21 namespace llvm {
22
23 class MachineBasicBlock;
24 class MachineFunction;
25 class TargetInstrInfo;
26 class TargetRegisterClass;
27
28 /// This file defines the FastISel class. This is a fast-path instruction
29 /// selection class that generates poor code and doesn't support illegal
30 /// types or non-trivial lowering, but runs quickly.
31 class FastISel {
32   MachineBasicBlock *MBB;
33   MachineFunction *MF;
34   const TargetInstrInfo *TII;
35
36 public:
37   FastISel(MachineBasicBlock *mbb, MachineFunction *mf,
38            const TargetInstrInfo *tii)
39     : MBB(mbb), MF(mf), TII(tii) {}
40
41   /// SelectInstructions - Do "fast" instruction selection over the
42   /// LLVM IR instructions in the range [Begin, N) where N is either
43   /// End or the first unsupported instruction. Return N.
44   /// ValueMap is filled in with a mapping of LLVM IR Values to
45   /// register numbers.
46   BasicBlock::iterator
47   SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator End,
48                      DenseMap<const Value*, unsigned> &ValueMap);
49
50 protected:
51   virtual unsigned FastEmit_(MVT::SimpleValueType VT,
52                              ISD::NodeType Opcode);
53   virtual unsigned FastEmit_r(MVT::SimpleValueType VT,
54                               ISD::NodeType Opcode, unsigned Op0);
55   virtual unsigned FastEmit_rr(MVT::SimpleValueType VT,
56                                ISD::NodeType Opcode,
57                                unsigned Op0, unsigned Op1);
58
59   unsigned FastEmitInst_(unsigned MachineInstOpcode,
60                          const TargetRegisterClass *RC);
61   unsigned FastEmitInst_r(unsigned MachineInstOpcode,
62                           const TargetRegisterClass *RC,
63                           unsigned Op0);
64   unsigned FastEmitInst_rr(unsigned MachineInstOpcode,
65                            const TargetRegisterClass *RC,
66                            unsigned Op0, unsigned Op1);
67 };
68
69 }
70
71 #endif