27#define GET_GICOMBINER_DEPS
28#include "SPIRVGenPreLegalizeGICombiner.inc"
29#undef GET_GICOMBINER_DEPS
31#define DEBUG_TYPE "spirv-prelegalizer-combiner"
38#define GET_GICOMBINER_TYPES
39#include "SPIRVGenPreLegalizeGICombiner.inc"
40#undef GET_GICOMBINER_TYPES
42class SPIRVPreLegalizerCombinerImpl :
public Combiner {
45 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig;
49 SPIRVPreLegalizerCombinerImpl(
52 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig,
56 static const char *
getName() {
return "SPIRVPreLegalizerCombiner"; }
63#define GET_GICOMBINER_CLASS_MEMBERS
64#include "SPIRVGenPreLegalizeGICombiner.inc"
65#undef GET_GICOMBINER_CLASS_MEMBERS
68#define GET_GICOMBINER_IMPL
69#include "SPIRVGenPreLegalizeGICombiner.inc"
70#undef GET_GICOMBINER_IMPL
72SPIRVPreLegalizerCombinerImpl::SPIRVPreLegalizerCombinerImpl(
75 const SPIRVPreLegalizerCombinerImplRuleConfig &RuleConfig,
78 :
Combiner(MF, CInfo, TPC, &VT, CSEInfo),
79 Helper(Observer,
B,
true, &VT, MDT, LI, STI),
80 RuleConfig(RuleConfig), STI(STI),
82#include
"SPIRVGenPreLegalizeGICombiner.inc"
87bool SPIRVPreLegalizerCombinerImpl::tryCombineAll(
MachineInstr &
MI)
const {
88 return tryCombineAllImpl(
MI);
94class SPIRVPreLegalizerCombiner :
public MachineFunctionPass {
98 SPIRVPreLegalizerCombiner();
100 StringRef getPassName()
const override {
return "SPIRVPreLegalizerCombiner"; }
102 bool runOnMachineFunction(MachineFunction &MF)
override;
104 void getAnalysisUsage(AnalysisUsage &AU)
const override;
107 SPIRVPreLegalizerCombinerImplRuleConfig RuleConfig;
112void SPIRVPreLegalizerCombiner::getAnalysisUsage(AnalysisUsage &AU)
const {
116 AU.
addRequired<GISelValueTrackingAnalysisLegacy>();
123SPIRVPreLegalizerCombiner::SPIRVPreLegalizerCombiner()
124 : MachineFunctionPass(
ID) {
125 if (!RuleConfig.parseCommandLineOption())
129bool SPIRVPreLegalizerCombiner::runOnMachineFunction(
MachineFunction &MF) {
132 auto &TPC = getAnalysis<TargetPassConfig>();
135 const auto *LI =
ST.getLegalizerInfo();
141 &getAnalysis<GISelValueTrackingAnalysisLegacy>().get(MF);
143 &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
145 nullptr, EnableOpt,
F.hasOptSize(),
148 CInfo.MaxIterations = 1;
152 CInfo.EnableFullDCE =
false;
153 SPIRVPreLegalizerCombinerImpl Impl(MF, CInfo, &TPC, *VT,
nullptr,
154 RuleConfig, ST, MDT, LI);
155 return Impl.combineMachineInstrs();
158char SPIRVPreLegalizerCombiner::ID = 0;
160 "Combine SPIRV machine instrs before legalization",
false,
165 "Combine SPIRV machine instrs before legalization",
false,
170 return new SPIRVPreLegalizerCombiner();
#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)
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:
FunctionPass class - This class is used to implement most global optimizations.
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.
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Target-Independent Code Generator Pass Configuration Options.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createSPIRVPreLegalizerCombiner()
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
LLVM_ABI void getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU)
Modify analysis usage so it preserves passes required for the SelectionDAG fallback.
@ SinglePass
Enables Observer-based DCE and additional heuristics that retry combining defined and used instructio...