[llvm-branch-commits] [llvm] [AMDGPU][Attributor] Add `AAAMDGPUClusterDims` (PR #158076)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Sep 11 07:48:12 PDT 2025
================
@@ -1296,6 +1303,157 @@ struct AAAMDGPUNoAGPR
const char AAAMDGPUNoAGPR::ID = 0;
+/// An abstract attribute to propagate the function attribute
+/// "amdgpu-cluster-dims" from kernel entry functions to device functions.
+struct AAAMDGPUClusterDims
+ : public StateWrapper<BooleanState, AbstractAttribute> {
+ using Base = StateWrapper<BooleanState, AbstractAttribute>;
+ AAAMDGPUClusterDims(const IRPosition &IRP, Attributor &A) : Base(IRP) {}
+
+ /// Create an abstract attribute view for the position \p IRP.
+ static AAAMDGPUClusterDims &createForPosition(const IRPosition &IRP,
+ Attributor &A);
+
+ /// See AbstractAttribute::getName().
+ StringRef getName() const override { return "AAAMDGPUClusterDims"; }
+
+ /// See AbstractAttribute::getIdAddr().
+ const char *getIdAddr() const override { return &ID; }
+
+ /// This function should return true if the type of the \p AA is
+ /// AAAMDGPUClusterDims.
+ static bool classof(const AbstractAttribute *AA) {
+ return (AA->getIdAddr() == &ID);
+ }
+
+ virtual const AMDGPU::ClusterDimsAttr &getClusterDims() const = 0;
+
+ /// Unique ID (due to the unique address)
+ static const char ID;
+};
+
+const char AAAMDGPUClusterDims::ID = 0;
+
+struct AAAMDGPUClusterDimsFunction : public AAAMDGPUClusterDims {
+ AAAMDGPUClusterDimsFunction(const IRPosition &IRP, Attributor &A)
+ : AAAMDGPUClusterDims(IRP, A) {}
+
+ void initialize(Attributor &A) override {
+ Function *F = getAssociatedFunction();
+ assert(F && "empty associated function");
+
+ Attr = AMDGPU::ClusterDimsAttr::get(*F);
+
+ // No matter what a kernel function has, it is final.
+ if (AMDGPU::isEntryFunctionCC(F->getCallingConv())) {
+ if (Attr.isUnknown())
+ indicatePessimisticFixpoint();
+ else
+ indicateOptimisticFixpoint();
+ }
+ }
+
+ const std::string getAsStr(Attributor *A) const override {
+ if (!getAssumed() || Attr.isUnknown())
+ return "unknown";
+ if (Attr.isNoCluster())
+ return "no";
+ if (Attr.isVariableedDims())
----------------
arsenm wrote:
Find and replace typo? "isVariableedDims"
https://github.com/llvm/llvm-project/pull/158076
More information about the llvm-branch-commits
mailing list