24#define DEBUG_TYPE "amdgpu-remove-incompatible-functions"
37class AMDGPURemoveIncompatibleFunctions {
39 AMDGPURemoveIncompatibleFunctions(
const TargetMachine *TM =
nullptr)
41 assert(TM &&
"No TargetMachine!");
44 bool checkFunction(Function &
F);
47 assert(TM->getTargetTriple().isAMDGCN());
50 for (Function &
F : M) {
55 for (Function *
F : FnsToDelete) {
59 return !FnsToDelete.empty();
63 const TargetMachine *TM =
nullptr;
66class AMDGPURemoveIncompatibleFunctionsLegacy :
public ModulePass {
70 AMDGPURemoveIncompatibleFunctionsLegacy(
const TargetMachine *TM)
71 : ModulePass(ID), TM(TM) {}
73 bool runOnModule(
Module &M)
override {
74 AMDGPURemoveIncompatibleFunctions
Pass(TM);
78 StringRef getPassName()
const override {
79 return "AMDGPU Remove Incompatible Functions";
82 void getAnalysisUsage(AnalysisUsage &AU)
const override {}
85 const TargetMachine *TM =
nullptr;
88StringRef getFeatureName(
unsigned Feature) {
90 if (Feature == KV.Value)
105constexpr unsigned FeaturesToCheck[] = {AMDGPU::FeatureGFX11Insts,
106 AMDGPU::FeatureGFX10Insts,
107 AMDGPU::FeatureGFX9Insts,
108 AMDGPU::FeatureGFX8Insts,
110 AMDGPU::Feature16BitInsts,
111 AMDGPU::FeatureDot1Insts,
112 AMDGPU::FeatureDot2Insts,
113 AMDGPU::FeatureDot3Insts,
114 AMDGPU::FeatureDot4Insts,
115 AMDGPU::FeatureDot5Insts,
116 AMDGPU::FeatureDot6Insts,
117 AMDGPU::FeatureDot7Insts,
118 AMDGPU::FeatureDot8Insts,
119 AMDGPU::FeatureExtendedImageInsts,
120 AMDGPU::FeatureSMemRealTime,
121 AMDGPU::FeatureSMemTimeInst,
127 if (Features.
test(FE.Value) && FE.Implies.any())
128 Result |= expandImpliedFeatures(FE.Implies.getAsBitset());
133void reportFunctionRemoved(
Function &
F,
unsigned Feature) {
141 <<
"removing function '" <<
F.getName() <<
"': +"
142 << getFeatureName(Feature)
143 <<
" is not supported on the current target";
151 AMDGPURemoveIncompatibleFunctions Impl(TM);
157bool AMDGPURemoveIncompatibleFunctions::checkFunction(
Function &
F) {
158 if (
F.isDeclaration())
182 expandImpliedFeatures(GPUInfo->Implies.getAsBitset());
189 for (
unsigned Feature : FeaturesToCheck) {
190 if (ST->hasFeature(Feature) && !GPUFeatureBits.
test(Feature)) {
191 reportFunctionRemoved(
F, Feature);
200 if (!
ST->supportsWave32() &&
ST->hasFeature(AMDGPU::FeatureWavefrontSize32)) {
201 reportFunctionRemoved(
F, AMDGPU::FeatureWavefrontSize32);
205 if (!
ST->supportsWave64() &&
ST->hasFeature(AMDGPU::FeatureWavefrontSize64)) {
206 reportFunctionRemoved(
F, AMDGPU::FeatureWavefrontSize64);
213 "AMDGPU Remove Incompatible Functions",
false,
false)
215char AMDGPURemoveIncompatibleFunctionsLegacy::
ID = 0;
219 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.
Machine Check Debug Module
ModuleAnalysisManager MAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
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.
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)
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.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
const SubtargetFeatureKV AMDGPUFeatureKV[AMDGPU::NumSubtargetFeatures - 1]
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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.