24#define DEBUG_TYPE "amdgpu-remove-incompatible-functions"
32class AMDGPURemoveIncompatibleFunctions {
34 AMDGPURemoveIncompatibleFunctions(
const TargetMachine *TM =
nullptr)
36 assert(TM &&
"No TargetMachine!");
42 assert(TM->getTargetTriple().isAMDGCN());
54 return !FnsToDelete.
empty();
61class AMDGPURemoveIncompatibleFunctionsLegacy :
public ModulePass {
65 AMDGPURemoveIncompatibleFunctionsLegacy(
const TargetMachine *TM)
68 bool runOnModule(
Module &M)
override {
69 AMDGPURemoveIncompatibleFunctions
Pass(TM);
74 return "AMDGPU Remove Incompatible Functions";
85 if (Feature == KV.Value)
100constexpr unsigned FeaturesToCheck[] = {AMDGPU::FeatureGFX11Insts,
101 AMDGPU::FeatureGFX10Insts,
102 AMDGPU::FeatureGFX9Insts,
103 AMDGPU::FeatureGFX8Insts,
105 AMDGPU::FeatureDPPWavefrontShifts,
106 AMDGPU::FeatureDPPBroadcasts,
107 AMDGPU::Feature16BitInsts,
108 AMDGPU::FeatureDot1Insts,
109 AMDGPU::FeatureDot2Insts,
110 AMDGPU::FeatureDot3Insts,
111 AMDGPU::FeatureDot4Insts,
112 AMDGPU::FeatureDot5Insts,
113 AMDGPU::FeatureDot6Insts,
114 AMDGPU::FeatureDot7Insts,
115 AMDGPU::FeatureDot8Insts,
116 AMDGPU::FeatureExtendedImageInsts,
117 AMDGPU::FeatureSMemRealTime,
118 AMDGPU::FeatureSMemTimeInst,
125 if (Features.
test(FE.Value) && FE.Implies.any())
126 Result |= expandImpliedFeatures(ST, FE.Implies.getAsBitset());
140 <<
"removing function '" <<
F.getName() <<
"': +"
141 << getFeatureName(ST, Feature)
142 <<
" is not supported on the current target";
150 AMDGPURemoveIncompatibleFunctions Impl(TM);
156bool AMDGPURemoveIncompatibleFunctions::checkFunction(
Function &
F) {
157 if (
F.isDeclaration())
188 for (
unsigned Feature : FeaturesToCheck) {
189 if (ST->hasFeature(Feature) && !GPUFeatureBits.
test(Feature)) {
190 reportFunctionRemoved(
F, *ST, Feature);
199 if (!
ST->supportsWave32() &&
ST->hasFeature(AMDGPU::FeatureWavefrontSize32)) {
200 reportFunctionRemoved(
F, *ST, AMDGPU::FeatureWavefrontSize32);
204 if (!
ST->supportsWave64() &&
ST->hasFeature(AMDGPU::FeatureWavefrontSize64)) {
205 reportFunctionRemoved(
F, *ST, AMDGPU::FeatureWavefrontSize64);
212 "AMDGPU Remove Incompatible Functions",
false,
false)
214char AMDGPURemoveIncompatibleFunctionsLegacy::
ID = 0;
218 return new AMDGPURemoveIncompatibleFunctionsLegacy(TM);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMD GCN specific subclass of TargetSubtarget.
Module.h This file contains the declarations for the Module class.
print mir2vec MIR2Vec Vocabulary Printer Pass
ModuleAnalysisManager MAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
Represent the analysis usage information of a pass.
static LLVM_ABI 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...
A Module instance is used to store all the information related to an LLVM module.
Pass interface - Implemented by all 'passes'.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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
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.
ModulePass * createAMDGPURemoveIncompatibleFunctionsPass(const TargetMachine *)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
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.