#include "AMDGPU.h"
#include "AMDGPUCombinerHelper.h"
#include "AMDGPULegalizerInfo.h"
#include "GCNSubtarget.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "llvm/CodeGen/GlobalISel/Combiner.h"
#include "llvm/CodeGen/GlobalISel/CombinerHelper.h"
#include "llvm/CodeGen/GlobalISel/CombinerInfo.h"
#include "llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h"
#include "llvm/CodeGen/GlobalISel/GISelKnownBits.h"
#include "llvm/CodeGen/GlobalISel/GenericMachineInstrs.h"
#include "llvm/CodeGen/GlobalISel/MIPatternMatch.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
#include "llvm/Target/TargetMachine.h"
#define GET_GICOMBINER_DEPS
#include "AMDGPUGenPreLegalizeGICombiner.inc"
#undef GET_GICOMBINER_DEPS
#define DEBUG_TYPE …
usingnamespacellvm;
usingnamespaceMIPatternMatch;
namespace {
#define GET_GICOMBINER_TYPES
#include "AMDGPUGenPostLegalizeGICombiner.inc"
#undef GET_GICOMBINER_TYPES
class AMDGPUPostLegalizerCombinerImpl : public Combiner { … };
#define GET_GICOMBINER_IMPL
#define AMDGPUSubtarget …
#include "AMDGPUGenPostLegalizeGICombiner.inc"
#undef AMDGPUSubtarget
#undef GET_GICOMBINER_IMPL
AMDGPUPostLegalizerCombinerImpl::AMDGPUPostLegalizerCombinerImpl(
MachineFunction &MF, CombinerInfo &CInfo, const TargetPassConfig *TPC,
GISelKnownBits &KB, GISelCSEInfo *CSEInfo,
const AMDGPUPostLegalizerCombinerImplRuleConfig &RuleConfig,
const GCNSubtarget &STI, MachineDominatorTree *MDT, const LegalizerInfo *LI)
: … { … }
bool AMDGPUPostLegalizerCombinerImpl::tryCombineAll(MachineInstr &MI) const { … }
bool AMDGPUPostLegalizerCombinerImpl::matchFMinFMaxLegacy(
MachineInstr &MI, MachineInstr &FCmp, FMinFMaxLegacyInfo &Info) const { … }
void AMDGPUPostLegalizerCombinerImpl::applySelectFCmpToFMinFMaxLegacy(
MachineInstr &MI, const FMinFMaxLegacyInfo &Info) const { … }
bool AMDGPUPostLegalizerCombinerImpl::matchUCharToFloat(
MachineInstr &MI) const { … }
void AMDGPUPostLegalizerCombinerImpl::applyUCharToFloat(
MachineInstr &MI) const { … }
bool AMDGPUPostLegalizerCombinerImpl::matchRcpSqrtToRsq(
MachineInstr &MI,
std::function<void(MachineIRBuilder &)> &MatchInfo) const { … }
bool AMDGPUPostLegalizerCombinerImpl::matchFDivSqrtToRsqF16(
MachineInstr &MI) const { … }
void AMDGPUPostLegalizerCombinerImpl::applyFDivSqrtToRsqF16(
MachineInstr &MI, const Register &X) const { … }
bool AMDGPUPostLegalizerCombinerImpl::matchCvtF32UByteN(
MachineInstr &MI, CvtF32UByteMatchInfo &MatchInfo) const { … }
void AMDGPUPostLegalizerCombinerImpl::applyCvtF32UByteN(
MachineInstr &MI, const CvtF32UByteMatchInfo &MatchInfo) const { … }
bool AMDGPUPostLegalizerCombinerImpl::matchRemoveFcanonicalize(
MachineInstr &MI, Register &Reg) const { … }
bool AMDGPUPostLegalizerCombinerImpl::matchCombineSignExtendInReg(
MachineInstr &MI, std::pair<MachineInstr *, unsigned> &MatchData) const { … }
void AMDGPUPostLegalizerCombinerImpl::applyCombineSignExtendInReg(
MachineInstr &MI, std::pair<MachineInstr *, unsigned> &MatchData) const { … }
bool AMDGPUPostLegalizerCombinerImpl::matchCombine_s_mul_u64(
MachineInstr &MI, unsigned &NewOpcode) const { … }
class AMDGPUPostLegalizerCombiner : public MachineFunctionPass { … };
}
void AMDGPUPostLegalizerCombiner::getAnalysisUsage(AnalysisUsage &AU) const { … }
AMDGPUPostLegalizerCombiner::AMDGPUPostLegalizerCombiner(bool IsOptNone)
: … { … }
bool AMDGPUPostLegalizerCombiner::runOnMachineFunction(MachineFunction &MF) { … }
char AMDGPUPostLegalizerCombiner::ID = …;
INITIALIZE_PASS_BEGIN(AMDGPUPostLegalizerCombiner, DEBUG_TYPE,
"Combine AMDGPU machine instrs after legalization", false,
false)
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
INITIALIZE_PASS_DEPENDENCY(GISelKnownBitsAnalysis)
INITIALIZE_PASS_END(AMDGPUPostLegalizerCombiner, DEBUG_TYPE,
"Combine AMDGPU machine instrs after legalization", false,
false)
namespace llvm {
FunctionPass *createAMDGPUPostLegalizeCombiner(bool IsOptNone) { … }
}