Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //== llvm/CodeGen/GlobalISel/Legalizer.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 //
0009 /// \file A pass to convert the target-illegal operations created by IR -> MIR
0010 /// translation into ones the target expects to be able to select. This may
0011 /// occur in multiple phases, for example G_ADD <2 x i8> -> G_ADD <2 x i16> ->
0012 /// G_ADD <4 x i16>.
0013 ///
0014 /// The LegalizeHelper class is where most of the work happens, and is designed
0015 /// to be callable from other passes that find themselves with an illegal
0016 /// instruction.
0017 //
0018 //===----------------------------------------------------------------------===//
0019 
0020 #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZER_H
0021 #define LLVM_CODEGEN_GLOBALISEL_LEGALIZER_H
0022 
0023 #include "llvm/ADT/ArrayRef.h"
0024 #include "llvm/ADT/StringRef.h"
0025 #include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
0026 #include "llvm/CodeGen/MachineFunction.h"
0027 #include "llvm/CodeGen/MachineFunctionPass.h"
0028 
0029 namespace llvm {
0030 
0031 class LegalizerInfo;
0032 class MachineIRBuilder;
0033 class MachineInstr;
0034 class GISelChangeObserver;
0035 class LostDebugLocObserver;
0036 
0037 class Legalizer : public MachineFunctionPass {
0038 public:
0039   static char ID;
0040 
0041   struct MFResult {
0042     bool Changed;
0043     const MachineInstr *FailedOn;
0044   };
0045 
0046 private:
0047   /// Initialize the field members using \p MF.
0048   void init(MachineFunction &MF);
0049 
0050 public:
0051   // Ctor, nothing fancy.
0052   Legalizer();
0053 
0054   StringRef getPassName() const override { return "Legalizer"; }
0055 
0056   void getAnalysisUsage(AnalysisUsage &AU) const override;
0057 
0058   MachineFunctionProperties getRequiredProperties() const override {
0059     return MachineFunctionProperties().set(
0060         MachineFunctionProperties::Property::IsSSA);
0061   }
0062 
0063   MachineFunctionProperties getSetProperties() const override {
0064     return MachineFunctionProperties().set(
0065         MachineFunctionProperties::Property::Legalized);
0066   }
0067 
0068   MachineFunctionProperties getClearedProperties() const override {
0069     return MachineFunctionProperties()
0070         .set(MachineFunctionProperties::Property::NoPHIs)
0071         .set(MachineFunctionProperties::Property::NoVRegs);
0072   }
0073 
0074   bool runOnMachineFunction(MachineFunction &MF) override;
0075 
0076   static MFResult
0077   legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI,
0078                           ArrayRef<GISelChangeObserver *> AuxObservers,
0079                           LostDebugLocObserver &LocObserver,
0080                           MachineIRBuilder &MIRBuilder, GISelKnownBits *KB);
0081 };
0082 } // End namespace llvm.
0083 
0084 #endif