Path: blob/main/contrib/llvm-project/llvm/lib/Target/M68k/GISel/M68kInstructionSelector.cpp
35294 views
//===-- M68kInstructionSelector.cpp -----------------------------*- C++ -*-===//1//===----------------------------------------------------------------------===//2/// \file3/// This file implements the targeting of the InstructionSelector class for4/// M68k.5/// \todo This should be generated by TableGen.6//===----------------------------------------------------------------------===//78#include "M68kRegisterBankInfo.h"9#include "M68kSubtarget.h"10#include "M68kTargetMachine.h"11#include "llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h"12#include "llvm/CodeGen/GlobalISel/InstructionSelector.h"13#include "llvm/Support/Debug.h"1415#define DEBUG_TYPE "m68k-isel"1617using namespace llvm;1819#define GET_GLOBALISEL_PREDICATE_BITSET20#include "M68kGenGlobalISel.inc"21#undef GET_GLOBALISEL_PREDICATE_BITSET2223namespace {2425class M68kInstructionSelector : public InstructionSelector {26public:27M68kInstructionSelector(const M68kTargetMachine &TM, const M68kSubtarget &STI,28const M68kRegisterBankInfo &RBI);2930bool select(MachineInstr &I) override;31static const char *getName() { return DEBUG_TYPE; }3233private:34bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;3536const M68kTargetMachine &TM;37const M68kInstrInfo &TII;38const M68kRegisterInfo &TRI;39const M68kRegisterBankInfo &RBI;4041#define GET_GLOBALISEL_PREDICATES_DECL42#include "M68kGenGlobalISel.inc"43#undef GET_GLOBALISEL_PREDICATES_DECL4445#define GET_GLOBALISEL_TEMPORARIES_DECL46#include "M68kGenGlobalISel.inc"47#undef GET_GLOBALISEL_TEMPORARIES_DECL48};4950} // end anonymous namespace5152#define GET_GLOBALISEL_IMPL53#include "M68kGenGlobalISel.inc"54#undef GET_GLOBALISEL_IMPL5556M68kInstructionSelector::M68kInstructionSelector(57const M68kTargetMachine &TM, const M68kSubtarget &STI,58const M68kRegisterBankInfo &RBI)59: InstructionSelector(), TM(TM), TII(*STI.getInstrInfo()),60TRI(*STI.getRegisterInfo()), RBI(RBI),6162#define GET_GLOBALISEL_PREDICATES_INIT63#include "M68kGenGlobalISel.inc"64#undef GET_GLOBALISEL_PREDICATES_INIT65#define GET_GLOBALISEL_TEMPORARIES_INIT66#include "M68kGenGlobalISel.inc"67#undef GET_GLOBALISEL_TEMPORARIES_INIT68{69}7071bool M68kInstructionSelector::select(MachineInstr &I) {72// Certain non-generic instructions also need some special handling.73if (!isPreISelGenericOpcode(I.getOpcode()))74return true;7576if (selectImpl(I, *CoverageInfo))77return true;7879return false;80}8182namespace llvm {83InstructionSelector *84createM68kInstructionSelector(const M68kTargetMachine &TM,85const M68kSubtarget &Subtarget,86const M68kRegisterBankInfo &RBI) {87return new M68kInstructionSelector(TM, Subtarget, RBI);88}89} // end namespace llvm909192