FastISel.h revision 40610241d00e219341ff4b7106c5baff08ad407b
1b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//===-- FastISel.h - Definition of the FastISel class ---------------------===//
2b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//
3b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//                     The LLVM Compiler Infrastructure
4b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//
5b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// This file is distributed under the University of Illinois Open Source
6b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// License. See LICENSE.TXT for details.
7b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//
8b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//===----------------------------------------------------------------------===//
9b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//
10b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman// This file defines the FastISel class.
11b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//
12b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman//===----------------------------------------------------------------------===//
13b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
14b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#ifndef LLVM_CODEGEN_FASTISEL_H
15b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#define LLVM_CODEGEN_FASTISEL_H
16b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
17b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#include "llvm/BasicBlock.h"
18b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#include "llvm/ADT/DenseMap.h"
19b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#include "llvm/CodeGen/SelectionDAGNodes.h"
20b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
21b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmannamespace llvm {
22b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
23b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass MachineBasicBlock;
24b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass MachineFunction;
25b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass TargetInstrInfo;
26b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass TargetRegisterClass;
27b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
2840610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// FastISel - This is a fast-path instruction selection class that
2940610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// generates poor code and doesn't support illegal types or non-trivial
3040610241d00e219341ff4b7106c5baff08ad407bDan Gohman/// lowering, but runs quickly.
31b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanclass FastISel {
32b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  MachineBasicBlock *MBB;
33b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  MachineFunction *MF;
34b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  const TargetInstrInfo *TII;
35b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
36b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanpublic:
37b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  /// SelectInstructions - Do "fast" instruction selection over the
38b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  /// LLVM IR instructions in the range [Begin, N) where N is either
39b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  /// End or the first unsupported instruction. Return N.
40b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  /// ValueMap is filled in with a mapping of LLVM IR Values to
41b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  /// register numbers.
42b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  BasicBlock::iterator
43b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator End,
44b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                     DenseMap<const Value*, unsigned> &ValueMap);
45b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
46b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohmanprotected:
47e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman  FastISel(MachineBasicBlock *mbb, MachineFunction *mf,
48e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman           const TargetInstrInfo *tii)
49e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman    : MBB(mbb), MF(mf), TII(tii) {}
50e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman
51e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman  virtual ~FastISel();
52e285a74f7cf9dd3ccf4fe758576cf83301f8a43eDan Gohman
53b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  virtual unsigned FastEmit_(MVT::SimpleValueType VT,
54b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                             ISD::NodeType Opcode);
55b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  virtual unsigned FastEmit_r(MVT::SimpleValueType VT,
56b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                              ISD::NodeType Opcode, unsigned Op0);
57b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  virtual unsigned FastEmit_rr(MVT::SimpleValueType VT,
58b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                               ISD::NodeType Opcode,
59b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                               unsigned Op0, unsigned Op1);
60b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
61b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  unsigned FastEmitInst_(unsigned MachineInstOpcode,
62b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                         const TargetRegisterClass *RC);
63b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  unsigned FastEmitInst_r(unsigned MachineInstOpcode,
64b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                          const TargetRegisterClass *RC,
65b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                          unsigned Op0);
66b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman  unsigned FastEmitInst_rr(unsigned MachineInstOpcode,
67b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                           const TargetRegisterClass *RC,
68b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman                           unsigned Op0, unsigned Op1);
69b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman};
70b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
71b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman}
72b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman
73b0cf29c5cfff797284b3660dc233e135feb65d9aDan Gohman#endif
74