24#define DEBUG_TYPE "amdgpu-remove-incompatible-functions"
37class AMDGPURemoveIncompatibleFunctions :
public ModulePass {
41 AMDGPURemoveIncompatibleFunctions(
const TargetMachine *TM =
nullptr)
43 assert(TM &&
"No TargetMachine!");
47 return "AMDGPU Remove Incompatible Functions";
56 assert(
TM->getTargetTriple().isAMDGCN());
68 return !FnsToDelete.empty();
75StringRef getFeatureName(
unsigned Feature) {
77 if (Feature == KV.Value)
92constexpr unsigned FeaturesToCheck[] = {
93 AMDGPU::FeatureGFX11Insts,
94 AMDGPU::FeatureGFX10Insts,
95 AMDGPU::FeatureGFX9Insts,
96 AMDGPU::FeatureGFX8Insts,
98 AMDGPU::Feature16BitInsts,
99 AMDGPU::FeatureDot1Insts,
100 AMDGPU::FeatureDot2Insts,
101 AMDGPU::FeatureDot3Insts,
102 AMDGPU::FeatureDot4Insts,
103 AMDGPU::FeatureDot5Insts,
104 AMDGPU::FeatureDot6Insts,
105 AMDGPU::FeatureDot7Insts,
106 AMDGPU::FeatureDot8Insts,
107 AMDGPU::FeatureExtendedImageInsts,
108 AMDGPU::FeatureSMemRealTime,
109 AMDGPU::FeatureSMemTimeInst
115 if (Features.
test(FE.Value) && FE.Implies.any())
116 Result |= expandImpliedFeatures(FE.Implies.getAsBitset());
121void reportFunctionRemoved(
Function &
F,
unsigned Feature) {
129 <<
"removing function '" <<
F.getName() <<
"': +"
130 << getFeatureName(Feature)
131 <<
" is not supported on the current target";
136bool AMDGPURemoveIncompatibleFunctions::checkFunction(
Function &
F) {
137 if (
F.isDeclaration())
168 for (
unsigned Feature : FeaturesToCheck) {
169 if (
ST->hasFeature(Feature) && !GPUFeatureBits.
test(Feature)) {
170 reportFunctionRemoved(
F, Feature);
180 ST->hasFeature(AMDGPU::FeatureWavefrontSize32)) {
181 reportFunctionRemoved(
F, AMDGPU::FeatureWavefrontSize32);
188 "AMDGPU Remove Incompatible Functions",
false,
false)
190char AMDGPURemoveIncompatibleFunctions::
ID = 0;
194 return new AMDGPURemoveIncompatibleFunctions(
TM);
AMD GCN specific subclass of TargetSubtarget.
Module.h This file contains the declarations for the Module class.
const char LLVMTargetMachineRef TM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Represent the analysis usage information of a pass.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
const FeatureBitset & getAsBitset() const
Container class for subtarget features.
constexpr bool test(unsigned I) const
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
A Module instance is used to store all the information related to an LLVM module.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Primary interface to the complete machine description for the target machine.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
const SubtargetFeatureKV AMDGPUFeatureKV[AMDGPU::NumSubtargetFeatures - 1]
ModulePass * createAMDGPURemoveIncompatibleFunctionsPass(const TargetMachine *)
Used to provide key value pairs for feature and CPU bit flags.
Used to provide key value pairs for feature and CPU bit flags.
FeatureBitArray Implies
K-V bit mask.