1009cd4e4SKit Barton //===- PPCInstructionSelector.cpp --------------------------------*- C++ -*-==//
2009cd4e4SKit Barton //
3009cd4e4SKit Barton // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4009cd4e4SKit Barton // See https://llvm.org/LICENSE.txt for license information.
5009cd4e4SKit Barton // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6009cd4e4SKit Barton //
7009cd4e4SKit Barton //===----------------------------------------------------------------------===//
8009cd4e4SKit Barton /// \file
9009cd4e4SKit Barton /// This file implements the targeting of the InstructionSelector class for
10009cd4e4SKit Barton /// PowerPC.
11009cd4e4SKit Barton //===----------------------------------------------------------------------===//
12009cd4e4SKit Barton
13009cd4e4SKit Barton #include "PPCInstrInfo.h"
14009cd4e4SKit Barton #include "PPCRegisterBankInfo.h"
15009cd4e4SKit Barton #include "PPCSubtarget.h"
16009cd4e4SKit Barton #include "PPCTargetMachine.h"
17009cd4e4SKit Barton #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
18009cd4e4SKit Barton #include "llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h"
19009cd4e4SKit Barton #include "llvm/CodeGen/MachineFunction.h"
20009cd4e4SKit Barton #include "llvm/IR/IntrinsicsPowerPC.h"
21009cd4e4SKit Barton #include "llvm/Support/Debug.h"
22009cd4e4SKit Barton
23009cd4e4SKit Barton #define DEBUG_TYPE "ppc-gisel"
24009cd4e4SKit Barton
25009cd4e4SKit Barton using namespace llvm;
26009cd4e4SKit Barton
27009cd4e4SKit Barton namespace {
28009cd4e4SKit Barton
29009cd4e4SKit Barton #define GET_GLOBALISEL_PREDICATE_BITSET
30009cd4e4SKit Barton #include "PPCGenGlobalISel.inc"
31009cd4e4SKit Barton #undef GET_GLOBALISEL_PREDICATE_BITSET
32009cd4e4SKit Barton
33009cd4e4SKit Barton class PPCInstructionSelector : public InstructionSelector {
34009cd4e4SKit Barton public:
35009cd4e4SKit Barton PPCInstructionSelector(const PPCTargetMachine &TM, const PPCSubtarget &STI,
36009cd4e4SKit Barton const PPCRegisterBankInfo &RBI);
37009cd4e4SKit Barton
38009cd4e4SKit Barton bool select(MachineInstr &I) override;
getName()39009cd4e4SKit Barton static const char *getName() { return DEBUG_TYPE; }
40009cd4e4SKit Barton
41009cd4e4SKit Barton private:
42009cd4e4SKit Barton /// tblgen generated 'select' implementation that is used as the initial
43009cd4e4SKit Barton /// selector for the patterns that do not require complex C++.
44009cd4e4SKit Barton bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;
45009cd4e4SKit Barton
46009cd4e4SKit Barton const PPCInstrInfo &TII;
47009cd4e4SKit Barton const PPCRegisterInfo &TRI;
48009cd4e4SKit Barton const PPCRegisterBankInfo &RBI;
49009cd4e4SKit Barton
50009cd4e4SKit Barton #define GET_GLOBALISEL_PREDICATES_DECL
51009cd4e4SKit Barton #include "PPCGenGlobalISel.inc"
52009cd4e4SKit Barton #undef GET_GLOBALISEL_PREDICATES_DECL
53009cd4e4SKit Barton
54009cd4e4SKit Barton #define GET_GLOBALISEL_TEMPORARIES_DECL
55009cd4e4SKit Barton #include "PPCGenGlobalISel.inc"
56009cd4e4SKit Barton #undef GET_GLOBALISEL_TEMPORARIES_DECL
57009cd4e4SKit Barton };
58009cd4e4SKit Barton
59009cd4e4SKit Barton } // end anonymous namespace
60009cd4e4SKit Barton
61009cd4e4SKit Barton #define GET_GLOBALISEL_IMPL
62009cd4e4SKit Barton #include "PPCGenGlobalISel.inc"
63009cd4e4SKit Barton #undef GET_GLOBALISEL_IMPL
64009cd4e4SKit Barton
PPCInstructionSelector(const PPCTargetMachine & TM,const PPCSubtarget & STI,const PPCRegisterBankInfo & RBI)65009cd4e4SKit Barton PPCInstructionSelector::PPCInstructionSelector(const PPCTargetMachine &TM,
66009cd4e4SKit Barton const PPCSubtarget &STI,
67009cd4e4SKit Barton const PPCRegisterBankInfo &RBI)
68*f3a344d2SKazu Hirata : TII(*STI.getInstrInfo()), TRI(*STI.getRegisterInfo()), RBI(RBI),
69009cd4e4SKit Barton #define GET_GLOBALISEL_PREDICATES_INIT
70009cd4e4SKit Barton #include "PPCGenGlobalISel.inc"
71009cd4e4SKit Barton #undef GET_GLOBALISEL_PREDICATES_INIT
72009cd4e4SKit Barton #define GET_GLOBALISEL_TEMPORARIES_INIT
73009cd4e4SKit Barton #include "PPCGenGlobalISel.inc"
74009cd4e4SKit Barton #undef GET_GLOBALISEL_TEMPORARIES_INIT
75009cd4e4SKit Barton {
76009cd4e4SKit Barton }
77009cd4e4SKit Barton
select(MachineInstr & I)78009cd4e4SKit Barton bool PPCInstructionSelector::select(MachineInstr &I) {
79009cd4e4SKit Barton if (selectImpl(I, *CoverageInfo))
80009cd4e4SKit Barton return true;
81009cd4e4SKit Barton return false;
82009cd4e4SKit Barton }
83009cd4e4SKit Barton
84009cd4e4SKit Barton namespace llvm {
85009cd4e4SKit Barton InstructionSelector *
createPPCInstructionSelector(const PPCTargetMachine & TM,const PPCSubtarget & Subtarget,const PPCRegisterBankInfo & RBI)86009cd4e4SKit Barton createPPCInstructionSelector(const PPCTargetMachine &TM,
87009cd4e4SKit Barton const PPCSubtarget &Subtarget,
88009cd4e4SKit Barton const PPCRegisterBankInfo &RBI) {
89009cd4e4SKit Barton return new PPCInstructionSelector(TM, Subtarget, RBI);
90009cd4e4SKit Barton }
91009cd4e4SKit Barton } // end namespace llvm
92