#include "AMDGPU.h"
#include "AMDGPULegalizerInfo.h"
#include "AMDGPURegisterBankInfo.h"
#include "GCNSubtarget.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "SIMachineFunctionInfo.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/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 "AMDGPUGenRegBankGICombiner.inc"
#undef GET_GICOMBINER_TYPES
class AMDGPURegBankCombinerImpl : public Combiner { … };
#define GET_GICOMBINER_IMPL
#define AMDGPUSubtarget …
#include "AMDGPUGenRegBankGICombiner.inc"
#undef AMDGPUSubtarget
#undef GET_GICOMBINER_IMPL
AMDGPURegBankCombinerImpl::AMDGPURegBankCombinerImpl(
MachineFunction &MF, CombinerInfo &CInfo, const TargetPassConfig *TPC,
GISelKnownBits &KB, GISelCSEInfo *CSEInfo,
const AMDGPURegBankCombinerImplRuleConfig &RuleConfig,
const GCNSubtarget &STI, MachineDominatorTree *MDT, const LegalizerInfo *LI)
: … { … }
bool AMDGPURegBankCombinerImpl::isVgprRegBank(Register Reg) const { … }
Register AMDGPURegBankCombinerImpl::getAsVgpr(Register Reg) const { … }
AMDGPURegBankCombinerImpl::MinMaxMedOpc
AMDGPURegBankCombinerImpl::getMinMaxPair(unsigned Opc) const { … }
template <class m_Cst, typename CstTy>
bool AMDGPURegBankCombinerImpl::matchMed(MachineInstr &MI,
MachineRegisterInfo &MRI,
MinMaxMedOpc MMMOpc, Register &Val,
CstTy &K0, CstTy &K1) const { … }
bool AMDGPURegBankCombinerImpl::matchIntMinMaxToMed3(
MachineInstr &MI, Med3MatchInfo &MatchInfo) const { … }
bool AMDGPURegBankCombinerImpl::matchFPMinMaxToMed3(
MachineInstr &MI, Med3MatchInfo &MatchInfo) const { … }
bool AMDGPURegBankCombinerImpl::matchFPMinMaxToClamp(MachineInstr &MI,
Register &Reg) const { … }
bool AMDGPURegBankCombinerImpl::matchFPMed3ToClamp(MachineInstr &MI,
Register &Reg) const { … }
void AMDGPURegBankCombinerImpl::applyClamp(MachineInstr &MI,
Register &Reg) const { … }
void AMDGPURegBankCombinerImpl::applyMed3(MachineInstr &MI,
Med3MatchInfo &MatchInfo) const { … }
SIModeRegisterDefaults AMDGPURegBankCombinerImpl::getMode() const { … }
bool AMDGPURegBankCombinerImpl::getIEEE() const { … }
bool AMDGPURegBankCombinerImpl::getDX10Clamp() const { … }
bool AMDGPURegBankCombinerImpl::isFminnumIeee(const MachineInstr &MI) const { … }
bool AMDGPURegBankCombinerImpl::isFCst(MachineInstr *MI) const { … }
bool AMDGPURegBankCombinerImpl::isClampZeroToOne(MachineInstr *K0,
MachineInstr *K1) const { … }
class AMDGPURegBankCombiner : public MachineFunctionPass { … };
}
void AMDGPURegBankCombiner::getAnalysisUsage(AnalysisUsage &AU) const { … }
AMDGPURegBankCombiner::AMDGPURegBankCombiner(bool IsOptNone)
: … { … }
bool AMDGPURegBankCombiner::runOnMachineFunction(MachineFunction &MF) { … }
char AMDGPURegBankCombiner::ID = …;
INITIALIZE_PASS_BEGIN(AMDGPURegBankCombiner, DEBUG_TYPE,
"Combine AMDGPU machine instrs after regbankselect",
false, false)
INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
INITIALIZE_PASS_DEPENDENCY(GISelKnownBitsAnalysis)
INITIALIZE_PASS_END(AMDGPURegBankCombiner, DEBUG_TYPE,
"Combine AMDGPU machine instrs after regbankselect", false,
false)
namespace llvm {
FunctionPass *createAMDGPURegBankCombiner(bool IsOptNone) { … }
}