10b57cec5SDimitry Andric //== llvm/CodeGen/GlobalISel/Legalizer.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 // 90b57cec5SDimitry Andric /// \file A pass to convert the target-illegal operations created by IR -> MIR 100b57cec5SDimitry Andric /// translation into ones the target expects to be able to select. This may 110b57cec5SDimitry Andric /// occur in multiple phases, for example G_ADD <2 x i8> -> G_ADD <2 x i16> -> 120b57cec5SDimitry Andric /// G_ADD <4 x i16>. 130b57cec5SDimitry Andric /// 140b57cec5SDimitry Andric /// The LegalizeHelper class is where most of the work happens, and is designed 150b57cec5SDimitry Andric /// to be callable from other passes that find themselves with an illegal 160b57cec5SDimitry Andric /// instruction. 170b57cec5SDimitry Andric // 180b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 190b57cec5SDimitry Andric 20fe6060f1SDimitry Andric #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZER_H 21fe6060f1SDimitry Andric #define LLVM_CODEGEN_GLOBALISEL_LEGALIZER_H 220b57cec5SDimitry Andric 2381ad6265SDimitry Andric #include "llvm/ADT/ArrayRef.h" 2481ad6265SDimitry Andric #include "llvm/ADT/StringRef.h" 2506c3fb27SDimitry Andric #include "llvm/CodeGen/GlobalISel/GISelKnownBits.h" 2681ad6265SDimitry Andric #include "llvm/CodeGen/MachineFunction.h" 270b57cec5SDimitry Andric #include "llvm/CodeGen/MachineFunctionPass.h" 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric namespace llvm { 300b57cec5SDimitry Andric 3181ad6265SDimitry Andric class LegalizerInfo; 3281ad6265SDimitry Andric class MachineIRBuilder; 3381ad6265SDimitry Andric class MachineInstr; 3481ad6265SDimitry Andric class GISelChangeObserver; 355ffd83dbSDimitry Andric class LostDebugLocObserver; 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric class Legalizer : public MachineFunctionPass { 380b57cec5SDimitry Andric public: 390b57cec5SDimitry Andric static char ID; 400b57cec5SDimitry Andric 41480093f4SDimitry Andric struct MFResult { 42480093f4SDimitry Andric bool Changed; 43480093f4SDimitry Andric const MachineInstr *FailedOn; 44480093f4SDimitry Andric }; 450b57cec5SDimitry Andric 46480093f4SDimitry Andric private: 470b57cec5SDimitry Andric /// Initialize the field members using \p MF. 480b57cec5SDimitry Andric void init(MachineFunction &MF); 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric public: 510b57cec5SDimitry Andric // Ctor, nothing fancy. 520b57cec5SDimitry Andric Legalizer(); 530b57cec5SDimitry Andric getPassName()540b57cec5SDimitry Andric StringRef getPassName() const override { return "Legalizer"; } 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric void getAnalysisUsage(AnalysisUsage &AU) const override; 570b57cec5SDimitry Andric getRequiredProperties()580b57cec5SDimitry Andric MachineFunctionProperties getRequiredProperties() const override { 590b57cec5SDimitry Andric return MachineFunctionProperties().set( 600b57cec5SDimitry Andric MachineFunctionProperties::Property::IsSSA); 610b57cec5SDimitry Andric } 620b57cec5SDimitry Andric getSetProperties()630b57cec5SDimitry Andric MachineFunctionProperties getSetProperties() const override { 640b57cec5SDimitry Andric return MachineFunctionProperties().set( 650b57cec5SDimitry Andric MachineFunctionProperties::Property::Legalized); 660b57cec5SDimitry Andric } 670b57cec5SDimitry Andric getClearedProperties()680b57cec5SDimitry Andric MachineFunctionProperties getClearedProperties() const override { 695f757f3fSDimitry Andric return MachineFunctionProperties() 705f757f3fSDimitry Andric .set(MachineFunctionProperties::Property::NoPHIs) 715f757f3fSDimitry Andric .set(MachineFunctionProperties::Property::NoVRegs); 720b57cec5SDimitry Andric } 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric bool runOnMachineFunction(MachineFunction &MF) override; 75480093f4SDimitry Andric 76480093f4SDimitry Andric static MFResult 77480093f4SDimitry Andric legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI, 78480093f4SDimitry Andric ArrayRef<GISelChangeObserver *> AuxObservers, 795ffd83dbSDimitry Andric LostDebugLocObserver &LocObserver, 8006c3fb27SDimitry Andric MachineIRBuilder &MIRBuilder, GISelKnownBits *KB); 810b57cec5SDimitry Andric }; 820b57cec5SDimitry Andric } // End namespace llvm. 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric #endif 85