38#define GET_GICOMBINER_DEPS
39#include "RISCVGenPostLegalizeGICombiner.inc"
40#undef GET_GICOMBINER_DEPS
42#define DEBUG_TYPE "riscv-postlegalizer-combiner"
49#define GET_GICOMBINER_TYPES
50#include "RISCVGenPostLegalizeGICombiner.inc"
51#undef GET_GICOMBINER_TYPES
57 if (
MI.getOpcode() != TargetOpcode::G_STORE)
67 unsigned ValBits =
MRI.getType(SrcReg).getSizeInBits();
68 if ((ValBits == 16 && !STI.hasStdExtZfh()) ||
69 (ValBits == 32 && !STI.hasStdExtF()) ||
70 (ValBits == 64 && (!STI.hasStdExtD() || !STI.
is64Bit())))
81 const unsigned XLen = STI.
getXLen();
84 MI.getOperand(0).setReg(
Zero.getReg(0));
87 if (Def &&
MRI.use_nodbg_empty(MatchInfo))
88 Def->eraseFromParent();
91 unsigned ValBits =
MRI.getType(MatchInfo).getSizeInBits();
93 "(XLEN={1}, ValBits={2}):\n {3}\n",
98class RISCVPostLegalizerCombinerImpl :
public Combiner {
100 const CombinerHelper Helper;
101 const RISCVPostLegalizerCombinerImplRuleConfig &RuleConfig;
102 const RISCVSubtarget &STI;
105 RISCVPostLegalizerCombinerImpl(
107 GISelCSEInfo *CSEInfo,
108 const RISCVPostLegalizerCombinerImplRuleConfig &RuleConfig,
109 const RISCVSubtarget &STI, MachineDominatorTree *MDT,
110 const LegalizerInfo *LI);
112 static const char *
getName() {
return "RISCVPostLegalizerCombiner"; }
114 bool tryCombineAll(MachineInstr &
I)
const override;
117#define GET_GICOMBINER_CLASS_MEMBERS
118#include "RISCVGenPostLegalizeGICombiner.inc"
119#undef GET_GICOMBINER_CLASS_MEMBERS
122#define GET_GICOMBINER_IMPL
123#include "RISCVGenPostLegalizeGICombiner.inc"
124#undef GET_GICOMBINER_IMPL
126RISCVPostLegalizerCombinerImpl::RISCVPostLegalizerCombinerImpl(
129 const RISCVPostLegalizerCombinerImplRuleConfig &RuleConfig,
132 :
Combiner(MF, CInfo, &VT, CSEInfo),
133 Helper(Observer,
B,
false, &VT, MDT, LI),
134 RuleConfig(RuleConfig), STI(STI),
136#include
"RISCVGenPostLegalizeGICombiner.inc"
145 RISCVPostLegalizerCombinerLegacy();
148 return "RISCVPostLegalizerCombiner";
156void RISCVPostLegalizerCombinerLegacy::getAnalysisUsage(
169RISCVPostLegalizerCombinerLegacy::RISCVPostLegalizerCombinerLegacy()
185 RISCVPostLegalizerCombinerImplRuleConfig RuleConfig;
186 if (!RuleConfig.parseCommandLineOption())
190 const auto *LI = ST.getLegalizerInfo();
197 nullptr, EnableOpt,
F.hasOptSize(),
199 RISCVPostLegalizerCombinerImpl Impl(MF, CInfo, *VT, CSEInfo, RuleConfig, ST,
201 return Impl.combineMachineInstrs();
204char RISCVPostLegalizerCombinerLegacy::ID = 0;
206 "Combine RISC-V MachineInstrs after legalization",
false,
211 "Combine RISC-V MachineInstrs after legalization",
false,
215 return new RISCVPostLegalizerCombinerLegacy();
218bool RISCVPostLegalizerCombinerLegacy::runOnMachineFunction(
221 MF, [&]() {
return skipFunction(MF.
getFunction()); },
223 return &getAnalysis<GISelValueTrackingAnalysisLegacy>().get(MF);
226 return &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
231 getAnalysis<GISelCSEAnalysisWrapperPass>().getCSEWrapper();
250 .preserve<GISelValueTrackingAnalysis>()
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define GET_GICOMBINER_CONSTRUCTOR_INITS
amdgpu aa AMDGPU Address space based Alias Analysis Wrapper
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Provides analysis for continuously CSEing during GISel passes.
This contains common combine transformations that may be used in a combine pass,or by the target else...
Option class for Targets to specify which operations are combined how and when.
This contains the base class for all Combiners generated by TableGen.
Provides analysis for querying information about KnownBits during GISel passes.
Contains matchers for matching SSA Machine Instructions.
This file declares the MachineIRBuilder class.
#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)
MachineRegisterInfo & MRI
static bool runCombinerOnMachineFunction(MachineFunction &MF, function_ref< bool()> ShouldSkip, function_ref< GISelValueTracking *()> GetVT, function_ref< MachineDominatorTree *()> GetMDT, function_ref< GISelCSEInfo *()> GetCSEInfo)
Target-Independent Code Generator Pass Configuration Options pass.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a 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).
The actual analysis pass wrapper.
Simple wrapper that does the following.
To use KnownBitsInfo analysis in a pass, KnownBitsInfo &Info = getAnalysis<GISelValueTrackingInfoAnal...
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Analysis pass which computes a MachineDominatorTree.
Analysis pass which computes a MachineDominatorTree.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
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
Helper class to build MachineInstr.
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
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)
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Target-Independent Code Generator Pass Configuration Options.
virtual std::unique_ptr< CSEConfigBase > getCSEConfig() const
Returns the CSEConfig object to use for the current optimization level.
An efficient, type-erasing, non-owning reference to a callable.
Pass manager infrastructure for declaring and invalidating analyses.
auto m_PosZeroFP()
Matches a floating-point positive zero.
bool mi_match(Reg R, const MachineRegisterInfo &MRI, Pattern &&P)
NodeAddr< DefNode * > Def
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.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createRISCVPostLegalizerCombinerLegacyPass()
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.
bool shouldSkipOptimizationForOptBisect(IRUnitRef IR)