Recommit [NFC] Better encapsulation of llvm::Optional Storage
[llvm-complete.git] / include / llvm / CodeGen / GlobalISel / Legalizer.h
blob01816509d4d65d3a9d02998e7fc4eddc375af2c0
1 //== llvm/CodeGen/GlobalISel/Legalizer.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 //
9 /// \file A pass to convert the target-illegal operations created by IR -> MIR
10 /// translation into ones the target expects to be able to select. This may
11 /// occur in multiple phases, for example G_ADD <2 x i8> -> G_ADD <2 x i16> ->
12 /// G_ADD <4 x i16>.
13 ///
14 /// The LegalizeHelper class is where most of the work happens, and is designed
15 /// to be callable from other passes that find themselves with an illegal
16 /// instruction.
18 //===----------------------------------------------------------------------===//
20 #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZEMACHINEIRPASS_H
21 #define LLVM_CODEGEN_GLOBALISEL_LEGALIZEMACHINEIRPASS_H
23 #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
24 #include "llvm/CodeGen/MachineFunctionPass.h"
26 namespace llvm {
28 class MachineRegisterInfo;
30 class Legalizer : public MachineFunctionPass {
31 public:
32 static char ID;
34 private:
36 /// Initialize the field members using \p MF.
37 void init(MachineFunction &MF);
39 public:
40 // Ctor, nothing fancy.
41 Legalizer();
43 StringRef getPassName() const override { return "Legalizer"; }
45 void getAnalysisUsage(AnalysisUsage &AU) const override;
47 MachineFunctionProperties getRequiredProperties() const override {
48 return MachineFunctionProperties().set(
49 MachineFunctionProperties::Property::IsSSA);
52 MachineFunctionProperties getSetProperties() const override {
53 return MachineFunctionProperties().set(
54 MachineFunctionProperties::Property::Legalized);
57 bool combineExtracts(MachineInstr &MI, MachineRegisterInfo &MRI,
58 const TargetInstrInfo &TII);
60 bool runOnMachineFunction(MachineFunction &MF) override;
62 } // End namespace llvm.
64 #endif