10b57cec5SDimitry Andric //== llvm/CodeGen/GlobalISel/InstructionSelect.h -----------------*- C++ -*-==//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric /// \file This file describes the interface of the MachineFunctionPass
90b57cec5SDimitry Andric /// responsible for selecting (possibly generic) machine instructions to
100b57cec5SDimitry Andric /// target-specific instructions.
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #ifndef LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECT_H
140b57cec5SDimitry Andric #define LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECT_H
150b57cec5SDimitry Andric 
1681ad6265SDimitry Andric #include "llvm/ADT/StringRef.h"
1781ad6265SDimitry Andric #include "llvm/CodeGen/MachineFunction.h"
180b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunctionPass.h"
1981ad6265SDimitry Andric #include "llvm/Support/CodeGen.h"
200b57cec5SDimitry Andric 
210b57cec5SDimitry Andric namespace llvm {
22fe6060f1SDimitry Andric 
23fe6060f1SDimitry Andric class BlockFrequencyInfo;
24fe6060f1SDimitry Andric class ProfileSummaryInfo;
25fe6060f1SDimitry Andric 
260b57cec5SDimitry Andric /// This pass is responsible for selecting generic machine instructions to
270b57cec5SDimitry Andric /// target-specific instructions.  It relies on the InstructionSelector provided
280b57cec5SDimitry Andric /// by the target.
290b57cec5SDimitry Andric /// Selection is done by examining blocks in post-order, and instructions in
300b57cec5SDimitry Andric /// reverse order.
310b57cec5SDimitry Andric ///
320b57cec5SDimitry Andric /// \post for all inst in MF: not isPreISelGenericOpcode(inst.opcode)
330b57cec5SDimitry Andric class InstructionSelect : public MachineFunctionPass {
340b57cec5SDimitry Andric public:
350b57cec5SDimitry Andric   static char ID;
getPassName()360b57cec5SDimitry Andric   StringRef getPassName() const override { return "InstructionSelect"; }
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric   void getAnalysisUsage(AnalysisUsage &AU) const override;
390b57cec5SDimitry Andric 
getRequiredProperties()400b57cec5SDimitry Andric   MachineFunctionProperties getRequiredProperties() const override {
410b57cec5SDimitry Andric     return MachineFunctionProperties()
420b57cec5SDimitry Andric         .set(MachineFunctionProperties::Property::IsSSA)
430b57cec5SDimitry Andric         .set(MachineFunctionProperties::Property::Legalized)
440b57cec5SDimitry Andric         .set(MachineFunctionProperties::Property::RegBankSelected);
450b57cec5SDimitry Andric   }
460b57cec5SDimitry Andric 
getSetProperties()470b57cec5SDimitry Andric   MachineFunctionProperties getSetProperties() const override {
480b57cec5SDimitry Andric     return MachineFunctionProperties().set(
490b57cec5SDimitry Andric         MachineFunctionProperties::Property::Selected);
500b57cec5SDimitry Andric   }
510b57cec5SDimitry Andric 
525f757f3fSDimitry Andric   InstructionSelect(CodeGenOptLevel OL);
530b57cec5SDimitry Andric   InstructionSelect();
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric   bool runOnMachineFunction(MachineFunction &MF) override;
56fe6060f1SDimitry Andric 
57fe6060f1SDimitry Andric protected:
58fe6060f1SDimitry Andric   BlockFrequencyInfo *BFI = nullptr;
59fe6060f1SDimitry Andric   ProfileSummaryInfo *PSI = nullptr;
60fe6060f1SDimitry Andric 
615f757f3fSDimitry Andric   CodeGenOptLevel OptLevel = CodeGenOptLevel::None;
620b57cec5SDimitry Andric };
630b57cec5SDimitry Andric } // End namespace llvm.
640b57cec5SDimitry Andric 
650b57cec5SDimitry Andric #endif
66