Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:24

0001 //== llvm/CodeGen/GlobalISel/InstructionSelect.h -----------------*- C++ -*-==//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 /// \file This file describes the interface of the MachineFunctionPass
0009 /// responsible for selecting (possibly generic) machine instructions to
0010 /// target-specific instructions.
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECT_H
0014 #define LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECT_H
0015 
0016 #include "llvm/ADT/StringRef.h"
0017 #include "llvm/CodeGen/MachineFunction.h"
0018 #include "llvm/CodeGen/MachineFunctionPass.h"
0019 #include "llvm/Support/CodeGen.h"
0020 
0021 namespace llvm {
0022 
0023 class InstructionSelector;
0024 class GISelKnownBits;
0025 class BlockFrequencyInfo;
0026 class ProfileSummaryInfo;
0027 
0028 /// This pass is responsible for selecting generic machine instructions to
0029 /// target-specific instructions.  It relies on the InstructionSelector provided
0030 /// by the target.
0031 /// Selection is done by examining blocks in post-order, and instructions in
0032 /// reverse order.
0033 ///
0034 /// \post for all inst in MF: not isPreISelGenericOpcode(inst.opcode)
0035 class InstructionSelect : public MachineFunctionPass {
0036 public:
0037   static char ID;
0038   StringRef getPassName() const override { return "InstructionSelect"; }
0039 
0040   void getAnalysisUsage(AnalysisUsage &AU) const override;
0041 
0042   MachineFunctionProperties getRequiredProperties() const override {
0043     return MachineFunctionProperties()
0044         .set(MachineFunctionProperties::Property::IsSSA)
0045         .set(MachineFunctionProperties::Property::Legalized)
0046         .set(MachineFunctionProperties::Property::RegBankSelected);
0047   }
0048 
0049   MachineFunctionProperties getSetProperties() const override {
0050     return MachineFunctionProperties().set(
0051         MachineFunctionProperties::Property::Selected);
0052   }
0053 
0054   InstructionSelect(CodeGenOptLevel OL = CodeGenOptLevel::Default,
0055                     char &PassID = ID);
0056 
0057   bool runOnMachineFunction(MachineFunction &MF) override;
0058   bool selectMachineFunction(MachineFunction &MF);
0059   void setInstructionSelector(InstructionSelector *NewISel) { ISel = NewISel; }
0060 
0061 protected:
0062   class MIIteratorMaintainer;
0063 
0064   InstructionSelector *ISel = nullptr;
0065   GISelKnownBits *KB = nullptr;
0066   BlockFrequencyInfo *BFI = nullptr;
0067   ProfileSummaryInfo *PSI = nullptr;
0068 
0069   CodeGenOptLevel OptLevel = CodeGenOptLevel::None;
0070 
0071   bool selectInstr(MachineInstr &MI);
0072 };
0073 } // End namespace llvm.
0074 
0075 #endif