29#include "llvm/IR/IntrinsicsSPIRV.h"
31#define GET_GICOMBINER_DEPS
32#include "SPIRVGenPreLegalizeGICombiner.inc"
33#undef GET_GICOMBINER_DEPS
35#define DEBUG_TYPE "spirv-prelegalizer-combiner"
42#define GET_GICOMBINER_TYPES
43#include "SPIRVGenPreLegalizeGICombiner.inc"
44#undef GET_GICOMBINER_TYPES
46class SPIRVPreLegalizerCombinerImpl :
public Combiner {
49 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig;
53 SPIRVPreLegalizerCombinerImpl(
56 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig,
60 static const char *
getName() {
return "SPIRVPreLegalizerCombiner"; }
67#define GET_GICOMBINER_CLASS_MEMBERS
68#include "SPIRVGenPreLegalizeGICombiner.inc"
69#undef GET_GICOMBINER_CLASS_MEMBERS
72#define GET_GICOMBINER_IMPL
73#include "SPIRVGenPreLegalizeGICombiner.inc"
74#undef GET_GICOMBINER_IMPL
76SPIRVPreLegalizerCombinerImpl::SPIRVPreLegalizerCombinerImpl(
79 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig,
83 Helper(Observer,
B,
true, &VT, MDT, LI, STI),
84 RuleConfig(RuleConfig), STI(STI),
86#include
"SPIRVGenPreLegalizeGICombiner.inc"
91bool SPIRVPreLegalizerCombinerImpl::tryCombineAll(
MachineInstr &
MI)
const {
92 return tryCombineAllImpl(
MI);
98class SPIRVPreLegalizerCombinerLegacy :
public MachineFunctionPass {
102 SPIRVPreLegalizerCombinerLegacy();
104 StringRef getPassName()
const override {
return "SPIRVPreLegalizerCombiner"; }
108 void getAnalysisUsage(AnalysisUsage &AU)
const override;
113void SPIRVPreLegalizerCombinerLegacy::getAnalysisUsage(
114 AnalysisUsage &AU)
const {
117 AU.
addRequired<GISelValueTrackingAnalysisLegacy>();
123SPIRVPreLegalizerCombinerLegacy::SPIRVPreLegalizerCombinerLegacy()
124 : MachineFunctionPass(
ID) {}
133 SPIRVPreLegalizerCombinerImplRuleConfig RuleConfig;
134 if (!RuleConfig.parseCommandLineOption())
138 const auto *LI = ST.getLegalizerInfo();
146 nullptr, EnableOpt,
F.hasOptSize(),
154 SPIRVPreLegalizerCombinerImpl Impl(MF, CInfo, *VT,
nullptr,
155 RuleConfig, ST, MDT, LI);
156 return Impl.combineMachineInstrs();
159char SPIRVPreLegalizerCombinerLegacy::ID = 0;
161 "Combine SPIRV machine instrs before legalization",
false,
165 "Combine SPIRV machine instrs before legalization",
false,
170 return new SPIRVPreLegalizerCombinerLegacy();
174bool SPIRVPreLegalizerCombinerLegacy::runOnMachineFunction(
179 return &getAnalysis<GISelValueTrackingAnalysisLegacy>().get(MF);
182 return &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
193 [&]() { return &MFAM.getResult<GISelValueTrackingAnalysis>(MF); },
194 [&]() { return &MFAM.getResult<MachineDominatorTreeAnalysis>(MF); });
199 .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...
bool shouldSkipOptimizationForOptBisect(IRUnitRef IR)