30#define GET_GICOMBINER_DEPS
31#include "SPIRVGenPreLegalizeGICombiner.inc"
32#undef GET_GICOMBINER_DEPS
34#define DEBUG_TYPE "spirv-prelegalizer-combiner"
41#define GET_GICOMBINER_TYPES
42#include "SPIRVGenPreLegalizeGICombiner.inc"
43#undef GET_GICOMBINER_TYPES
45class SPIRVPreLegalizerCombinerImpl :
public Combiner {
48 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig;
52 SPIRVPreLegalizerCombinerImpl(
55 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig,
59 static const char *
getName() {
return "SPIRVPreLegalizerCombiner"; }
66#define GET_GICOMBINER_CLASS_MEMBERS
67#include "SPIRVGenPreLegalizeGICombiner.inc"
68#undef GET_GICOMBINER_CLASS_MEMBERS
71#define GET_GICOMBINER_IMPL
72#include "SPIRVGenPreLegalizeGICombiner.inc"
73#undef GET_GICOMBINER_IMPL
75SPIRVPreLegalizerCombinerImpl::SPIRVPreLegalizerCombinerImpl(
78 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig,
82 Helper(Observer,
B,
true, &VT, MDT, LI, STI),
83 RuleConfig(RuleConfig), STI(STI),
85#include
"SPIRVGenPreLegalizeGICombiner.inc"
90bool SPIRVPreLegalizerCombinerImpl::tryCombineAll(
MachineInstr &
MI)
const {
91 return tryCombineAllImpl(
MI);
97class SPIRVPreLegalizerCombinerLegacy :
public MachineFunctionPass {
101 SPIRVPreLegalizerCombinerLegacy();
103 StringRef getPassName()
const override {
return "SPIRVPreLegalizerCombiner"; }
107 void getAnalysisUsage(AnalysisUsage &AU)
const override;
112void SPIRVPreLegalizerCombinerLegacy::getAnalysisUsage(
113 AnalysisUsage &AU)
const {
116 AU.
addRequired<GISelValueTrackingAnalysisLegacy>();
122SPIRVPreLegalizerCombinerLegacy::SPIRVPreLegalizerCombinerLegacy()
123 : MachineFunctionPass(
ID) {}
132 SPIRVPreLegalizerCombinerImplRuleConfig RuleConfig;
133 if (!RuleConfig.parseCommandLineOption())
137 const auto *LI = ST.getLegalizerInfo();
145 nullptr, EnableOpt,
F.hasOptSize(),
153 SPIRVPreLegalizerCombinerImpl Impl(MF, CInfo, *VT,
nullptr,
154 RuleConfig, ST, MDT, LI);
155 return Impl.combineMachineInstrs();
158char SPIRVPreLegalizerCombinerLegacy::ID = 0;
160 "Combine SPIRV machine instrs before legalization",
false,
164 "Combine SPIRV machine instrs before legalization",
false,
169 return new SPIRVPreLegalizerCombinerLegacy();
173bool SPIRVPreLegalizerCombinerLegacy::runOnMachineFunction(
178 return &getAnalysis<GISelValueTrackingAnalysisLegacy>().get(MF);
181 return &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
190 [&]() { return &MFAM.getResult<GISelValueTrackingAnalysis>(MF); },
191 [&]() { return &MFAM.getResult<MachineDominatorTreeAnalysis>(MF); });
196 .preserve<GISelValueTrackingAnalysis>();
#define GET_GICOMBINER_CONSTRUCTOR_INITS
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Provides analysis for continuously CSEing during GISel passes.
Option class for Targets to specify which operations are combined how and when.
This contains the base class for all Combiners generated by TableGen.
This contains common code to allow clients to notify changes to machine instr.
Provides analysis for querying information about KnownBits during GISel passes.
Contains matchers for matching SSA Machine Instructions.
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static StringRef getName(Value *V)
static bool runPreLegalizerCombiner(MachineFunction &MF, bool ShouldSkip, function_ref< GISelValueTracking *()> GetVT, function_ref< MachineDominatorTree *()> GetMDT)
Target-Independent Code Generator Pass Configuration Options pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
bool hasOptNone() const
Do not optimize this function (-O0).
To use KnownBitsInfo analysis in a pass, KnownBitsInfo &Info = getAnalysis<GISelValueTrackingInfoAnal...
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineFunctionProperties & getProperties() const
Get the function properties.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Representation of each machine instruction.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
An efficient, type-erasing, non-owning reference to a callable.
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
FunctionPass * createSPIRVPreLegalizerCombinerLegacyPass()
LLVM_ABI void getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU)
Modify analysis usage so it preserves passes required for the SelectionDAG fallback.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
unsigned MaxIterations
The maximum number of times the Combiner will iterate over the MachineFunction.
ObserverLevel ObserverLvl
Select how the Combiner acts on MIR changes.
bool EnableFullDCE
Whether dead code elimination is performed before each Combiner iteration.
@ SinglePass
Enables Observer-based DCE and additional heuristics that retry combining defined and used instructio...