Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 1 | //== llvm/CodeGen/GlobalISel/Legalizer.h ---------------- -*- C++ -*-==// |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 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. |
| 17 | // |
| 18 | //===----------------------------------------------------------------------===// |
| 19 | |
| 20 | #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZEMACHINEIRPASS_H |
| 21 | #define LLVM_CODEGEN_GLOBALISEL_LEGALIZEMACHINEIRPASS_H |
| 22 | |
| 23 | #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" |
| 24 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 25 | |
| 26 | namespace llvm { |
| 27 | |
| 28 | class MachineRegisterInfo; |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 29 | class LostDebugLocObserver; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 30 | |
| 31 | class Legalizer : public MachineFunctionPass { |
| 32 | public: |
| 33 | static char ID; |
| 34 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 35 | struct MFResult { |
| 36 | bool Changed; |
| 37 | const MachineInstr *FailedOn; |
| 38 | }; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 39 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 40 | private: |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 41 | /// Initialize the field members using \p MF. |
| 42 | void init(MachineFunction &MF); |
| 43 | |
| 44 | public: |
| 45 | // Ctor, nothing fancy. |
| 46 | Legalizer(); |
| 47 | |
| 48 | StringRef getPassName() const override { return "Legalizer"; } |
| 49 | |
| 50 | void getAnalysisUsage(AnalysisUsage &AU) const override; |
| 51 | |
| 52 | MachineFunctionProperties getRequiredProperties() const override { |
| 53 | return MachineFunctionProperties().set( |
| 54 | MachineFunctionProperties::Property::IsSSA); |
| 55 | } |
| 56 | |
| 57 | MachineFunctionProperties getSetProperties() const override { |
| 58 | return MachineFunctionProperties().set( |
| 59 | MachineFunctionProperties::Property::Legalized); |
| 60 | } |
| 61 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 62 | MachineFunctionProperties getClearedProperties() const override { |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 63 | return MachineFunctionProperties().set( |
| 64 | MachineFunctionProperties::Property::NoPHIs); |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 65 | } |
| 66 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 67 | bool runOnMachineFunction(MachineFunction &MF) override; |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 68 | |
| 69 | static MFResult |
| 70 | legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI, |
| 71 | ArrayRef<GISelChangeObserver *> AuxObservers, |
| 72 | LostDebugLocObserver &LocObserver, |
| 73 | MachineIRBuilder &MIRBuilder); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 74 | }; |
| 75 | } // End namespace llvm. |
| 76 | |
| 77 | #endif |