1 //===- M68kInstructionSelector.cpp ------------------------------*- C++ -*-===//
2 //===----------------------------------------------------------------------===//
4 /// This file implements the targeting of the InstructionSelector class for
6 /// \todo This should be generated by TableGen.
7 //===----------------------------------------------------------------------===//
9 #include "M68kRegisterBankInfo.h"
10 #include "M68kSubtarget.h"
11 #include "M68kTargetMachine.h"
12 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
13 #include "llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h"
14 #include "llvm/Support/Debug.h"
16 #define DEBUG_TYPE "m68k-isel"
20 #define GET_GLOBALISEL_PREDICATE_BITSET
21 #include "M68kGenGlobalISel.inc"
22 #undef GET_GLOBALISEL_PREDICATE_BITSET
26 class M68kInstructionSelector
: public InstructionSelector
{
28 M68kInstructionSelector(const M68kTargetMachine
&TM
, const M68kSubtarget
&STI
,
29 const M68kRegisterBankInfo
&RBI
);
31 bool select(MachineInstr
&I
) override
;
32 static const char *getName() { return DEBUG_TYPE
; }
35 bool selectImpl(MachineInstr
&I
, CodeGenCoverage
&CoverageInfo
) const;
37 const M68kTargetMachine
&TM
;
38 const M68kInstrInfo
&TII
;
39 const M68kRegisterInfo
&TRI
;
40 const M68kRegisterBankInfo
&RBI
;
42 #define GET_GLOBALISEL_PREDICATES_DECL
43 #include "M68kGenGlobalISel.inc"
44 #undef GET_GLOBALISEL_PREDICATES_DECL
46 #define GET_GLOBALISEL_TEMPORARIES_DECL
47 #include "M68kGenGlobalISel.inc"
48 #undef GET_GLOBALISEL_TEMPORARIES_DECL
51 } // end anonymous namespace
53 #define GET_GLOBALISEL_IMPL
54 #include "M68kGenGlobalISel.inc"
55 #undef GET_GLOBALISEL_IMPL
57 M68kInstructionSelector::M68kInstructionSelector(
58 const M68kTargetMachine
&TM
, const M68kSubtarget
&STI
,
59 const M68kRegisterBankInfo
&RBI
)
60 : InstructionSelector(), TM(TM
), TII(*STI
.getInstrInfo()),
61 TRI(*STI
.getRegisterInfo()), RBI(RBI
),
63 #define GET_GLOBALISEL_PREDICATES_INIT
64 #include "M68kGenGlobalISel.inc"
65 #undef GET_GLOBALISEL_PREDICATES_INIT
66 #define GET_GLOBALISEL_TEMPORARIES_INIT
67 #include "M68kGenGlobalISel.inc"
68 #undef GET_GLOBALISEL_TEMPORARIES_INIT
72 bool M68kInstructionSelector::select(MachineInstr
&I
) {
73 // Certain non-generic instructions also need some special handling.
74 if (!isPreISelGenericOpcode(I
.getOpcode()))
77 if (selectImpl(I
, *CoverageInfo
))
85 createM68kInstructionSelector(const M68kTargetMachine
&TM
,
86 const M68kSubtarget
&Subtarget
,
87 const M68kRegisterBankInfo
&RBI
) {
88 return new M68kInstructionSelector(TM
, Subtarget
, RBI
);
90 } // end namespace llvm