1 //== llvm/CodeGen/GlobalISel/InstructionSelect.h -----------------*- C++ -*-==// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 /// \file This file describes the interface of the MachineFunctionPass 9 /// responsible for selecting (possibly generic) machine instructions to 10 /// target-specific instructions. 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECT_H 14 #define LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECT_H 15 16 #include "llvm/CodeGen/GlobalISel/InstructionSelector.h" 17 #include "llvm/CodeGen/MachineFunctionPass.h" 18 19 namespace llvm { 20 21 class BlockFrequencyInfo; 22 class ProfileSummaryInfo; 23 24 /// This pass is responsible for selecting generic machine instructions to 25 /// target-specific instructions. It relies on the InstructionSelector provided 26 /// by the target. 27 /// Selection is done by examining blocks in post-order, and instructions in 28 /// reverse order. 29 /// 30 /// \post for all inst in MF: not isPreISelGenericOpcode(inst.opcode) 31 class InstructionSelect : public MachineFunctionPass { 32 public: 33 static char ID; getPassName()34 StringRef getPassName() const override { return "InstructionSelect"; } 35 36 void getAnalysisUsage(AnalysisUsage &AU) const override; 37 getRequiredProperties()38 MachineFunctionProperties getRequiredProperties() const override { 39 return MachineFunctionProperties() 40 .set(MachineFunctionProperties::Property::IsSSA) 41 .set(MachineFunctionProperties::Property::Legalized) 42 .set(MachineFunctionProperties::Property::RegBankSelected); 43 } 44 getSetProperties()45 MachineFunctionProperties getSetProperties() const override { 46 return MachineFunctionProperties().set( 47 MachineFunctionProperties::Property::Selected); 48 } 49 50 InstructionSelect(CodeGenOpt::Level OL); 51 InstructionSelect(); 52 53 bool runOnMachineFunction(MachineFunction &MF) override; 54 55 protected: 56 BlockFrequencyInfo *BFI = nullptr; 57 ProfileSummaryInfo *PSI = nullptr; 58 59 CodeGenOpt::Level OptLevel = CodeGenOpt::None; 60 }; 61 } // End namespace llvm. 62 63 #endif 64