1 //===- MipsInstructionSelector.cpp ------------------------------*- 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 /// \file
10 /// This file implements the targeting of the InstructionSelector class for
11 /// Mips.
12 /// \todo This should be generated by TableGen.
13 //===----------------------------------------------------------------------===//
14 
15 #include "MipsRegisterBankInfo.h"
16 #include "MipsSubtarget.h"
17 #include "MipsTargetMachine.h"
18 #include "llvm/Support/Debug.h"
19 
20 using namespace llvm;
21 
22 namespace {
23 
24 class MipsInstructionSelector : public InstructionSelector {
25 public:
26   MipsInstructionSelector(const MipsTargetMachine &TM, const MipsSubtarget &STI,
27                           const MipsRegisterBankInfo &RBI);
28 
29   bool select(MachineInstr &I, CodeGenCoverage &CoverageInfo) const override;
30 
31 private:
32   const MipsInstrInfo &TII;
33   const MipsRegisterInfo &TRI;
34 };
35 
36 } // end anonymous namespace
37 
38 MipsInstructionSelector::MipsInstructionSelector(
39     const MipsTargetMachine &TM, const MipsSubtarget &STI,
40     const MipsRegisterBankInfo &RBI)
41     : InstructionSelector(), TII(*STI.getInstrInfo()),
42       TRI(*STI.getRegisterInfo()) {}
43 
44 bool MipsInstructionSelector::select(MachineInstr &I,
45                                      CodeGenCoverage &CoverageInfo) const {
46 
47   if (!isPreISelGenericOpcode(I.getOpcode())) {
48     // Not global isel generic opcode.
49     // TODO: select copy
50     return true;
51   }
52 
53   // We didn't select anything.
54   return false;
55 }
56 
57 namespace llvm {
58 InstructionSelector *createMipsInstructionSelector(const MipsTargetMachine &TM,
59                                                    MipsSubtarget &Subtarget,
60                                                    MipsRegisterBankInfo &RBI) {
61   return new MipsInstructionSelector(TM, Subtarget, RBI);
62 }
63 } // end namespace llvm
64