LLVM 24.0.0git
Legalizer.h
Go to the documentation of this file.
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.
17//
18//===----------------------------------------------------------------------===//
19
20#ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZER_H
21#define LLVM_CODEGEN_GLOBALISEL_LEGALIZER_H
22
23#include "llvm/ADT/ArrayRef.h"
24#include "llvm/ADT/StringRef.h"
29#include "llvm/IR/Analysis.h"
30#include "llvm/IR/PassManager.h"
32
33namespace llvm {
34
35class LegalizerInfo;
37class MachineInstr;
41
46
48 MachineFunction &MF, const LegalizerInfo &LI,
50 LostDebugLocObserver &LocObserver, MachineIRBuilder &MIRBuilder,
51 const LibcallLoweringInfo *Libcalls, GISelValueTracking *VT);
52
54public:
55 static char ID;
56
57public:
58 // Ctor, nothing fancy.
60
61 StringRef getPassName() const override { return "Legalizer"; }
62
63 void getAnalysisUsage(AnalysisUsage &AU) const override;
64
66 return MachineFunctionProperties().setIsSSA();
67 }
68
70 return MachineFunctionProperties().setLegalized();
71 }
72
74 return MachineFunctionProperties().setNoPHIs().setNoVRegs();
75 }
76
77 bool runOnMachineFunction(MachineFunction &MF) override;
78};
79
80class LegalizerPass : public RequiredPassInfoMixin<LegalizerPass> {
81public:
84
88
90 return MachineFunctionProperties().setLegalized();
91 }
92
94 return MachineFunctionProperties().setNoPHIs().setNoVRegs();
95 }
96};
97
98} // End namespace llvm.
99
100#endif
#define LLVM_ABI
Definition Compiler.h:215
Provides analysis for querying information about KnownBits during GISel passes.
This header defines various interfaces for pass management in LLVM.
Represent the analysis usage information of a pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Abstract class that contains various methods for clients to notify about changes.
MachineFunctionProperties getRequiredProperties() const override
Definition Legalizer.h:65
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
Definition Legalizer.h:61
MachineFunctionProperties getSetProperties() const override
Definition Legalizer.h:69
MachineFunctionProperties getClearedProperties() const override
Definition Legalizer.h:73
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
MachineFunctionProperties getSetProperties() const
Definition Legalizer.h:89
MachineFunctionProperties getRequiredProperties() const
Definition Legalizer.h:85
MachineFunctionProperties getClearedProperties() const
Definition Legalizer.h:93
Tracks which library functions to use for a particular subtarget or function.
Properties which a MachineFunction may have at a given point in time.
Helper class to build MachineInstr.
Representation of each machine instruction.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LegalizerMFResult legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI, ArrayRef< GISelChangeObserver * > AuxObservers, LostDebugLocObserver &LocObserver, MachineIRBuilder &MIRBuilder, const LibcallLoweringInfo *Libcalls, GISelValueTracking *VT)
const MachineInstr * FailedOn
Definition Legalizer.h:44
A CRTP mix-in for passes that should not be skipped.