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[] = {AMDGPU::FeatureGFX11Insts,
93 AMDGPU::FeatureGFX10Insts,
94 AMDGPU::FeatureGFX9Insts,
95 AMDGPU::FeatureGFX8Insts,
97 AMDGPU::Feature16BitInsts,
98 AMDGPU::FeatureDot1Insts,
99 AMDGPU::FeatureDot2Insts,
100 AMDGPU::FeatureDot3Insts,
101 AMDGPU::FeatureDot4Insts,
102 AMDGPU::FeatureDot5Insts,
103 AMDGPU::FeatureDot6Insts,
104 AMDGPU::FeatureDot7Insts,
105 AMDGPU::FeatureDot8Insts,
106 AMDGPU::FeatureExtendedImageInsts,
107 AMDGPU::FeatureSMemRealTime,
108 AMDGPU::FeatureSMemTimeInst,
114 if (Features.
test(FE.Value) && FE.Implies.any())
115 Result |= expandImpliedFeatures(FE.Implies.getAsBitset());
120void reportFunctionRemoved(
Function &
F,
unsigned Feature) {
128 <<
"removing function '" <<
F.getName() <<
"': +"
129 << getFeatureName(Feature)
130 <<
" is not supported on the current target";
135bool AMDGPURemoveIncompatibleFunctions::checkFunction(
Function &
F) {
136 if (
F.isDeclaration())
167 for (
unsigned Feature : FeaturesToCheck) {
168 if (
ST->hasFeature(Feature) && !GPUFeatureBits.
test(Feature)) {
169 reportFunctionRemoved(
F, Feature);
179 ST->hasFeature(AMDGPU::FeatureWavefrontSize32)) {
180 reportFunctionRemoved(
F, AMDGPU::FeatureWavefrontSize32);
187 "AMDGPU Remove Incompatible Functions",
false,
false)
189char AMDGPURemoveIncompatibleFunctions::
ID = 0;
193 return new AMDGPURemoveIncompatibleFunctions(TM);
AMD GCN specific subclass of TargetSubtarget.
Module.h This file contains the declarations for the Module class.
#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.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
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.