23#define DEBUG_TYPE "amdgpu-remove-incompatible-functions"
36class AMDGPURemoveIncompatibleFunctions :
public ModulePass {
40 AMDGPURemoveIncompatibleFunctions(
const TargetMachine *TM =
nullptr)
42 assert(TM &&
"No TargetMachine!");
46 return "AMDGPU Remove Incompatible Functions";
55 assert(
TM->getTargetTriple().isAMDGCN());
67 return !FnsToDelete.empty();
74StringRef getFeatureName(
unsigned Feature) {
76 if (Feature == KV.Value)
91constexpr unsigned FeaturesToCheck[] = {AMDGPU::FeatureGFX11Insts,
92 AMDGPU::FeatureGFX10Insts,
93 AMDGPU::FeatureGFX9Insts,
94 AMDGPU::FeatureGFX8Insts,
96 AMDGPU::Feature16BitInsts,
97 AMDGPU::FeatureDot1Insts,
98 AMDGPU::FeatureDot2Insts,
99 AMDGPU::FeatureDot3Insts,
100 AMDGPU::FeatureDot4Insts,
101 AMDGPU::FeatureDot5Insts,
102 AMDGPU::FeatureDot6Insts,
103 AMDGPU::FeatureDot7Insts,
104 AMDGPU::FeatureDot8Insts,
105 AMDGPU::FeatureExtendedImageInsts,
106 AMDGPU::FeatureSMemRealTime,
107 AMDGPU::FeatureSMemTimeInst,
113 if (Features.
test(FE.Value) && FE.Implies.any())
114 Result |= expandImpliedFeatures(FE.Implies.getAsBitset());
119void reportFunctionRemoved(
Function &
F,
unsigned Feature) {
127 <<
"removing function '" <<
F.getName() <<
"': +"
128 << getFeatureName(Feature)
129 <<
" is not supported on the current target";
134bool AMDGPURemoveIncompatibleFunctions::checkFunction(
Function &
F) {
135 if (
F.isDeclaration())
166 for (
unsigned Feature : FeaturesToCheck) {
167 if (
ST->hasFeature(Feature) && !GPUFeatureBits.
test(Feature)) {
168 reportFunctionRemoved(
F, Feature);
178 ST->hasFeature(AMDGPU::FeatureWavefrontSize32)) {
179 reportFunctionRemoved(
F, AMDGPU::FeatureWavefrontSize32);
186 "AMDGPU Remove Incompatible Functions",
false,
false)
188char AMDGPURemoveIncompatibleFunctions::
ID = 0;
192 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.