[llvm] [SPIRV] Support for SPV_INTEL_cluster_attributes extension (PR #131593)
Dmitry Sidorov via llvm-commits
llvm-commits at lists.llvm.org
Fri May 16 05:28:19 PDT 2025
================
@@ -1976,6 +1980,38 @@ static void handleMIFlagDecoration(MachineInstr &I, const SPIRVSubtarget &ST,
buildOpDecorate(DstReg, I, TII, SPIRV::Decoration::FPFastMathMode, {FMFlags});
}
+static void handleFunctionDecoration(MachineInstr &MI, const SPIRVSubtarget &ST,
+ const SPIRVInstrInfo &TII,
+ SPIRV::ModuleAnalysisInfo &MAI,
+ llvm::Module::const_iterator F) {
+ Register FuncReg = MI.getOperand(0).getReg();
+ llvm::SmallVector<std::pair<unsigned int, llvm::MDNode *>> MetaDataList;
+
+ // Add function-level decorations based on metadata
+ F->getAllMetadata(MetaDataList);
+ for (auto &MetaData : MetaDataList) {
+ if (MetaData.second == F->getMetadata("stall_enable") ||
+ MetaData.second == F->getMetadata("stall_free")) {
----------------
MrSidims wrote:
> Should the !spirv.Decorations metadata be expected to already exist in the LLVM IR (i.e., injected by the frontend or via an earlier pass), or am I expected to modify the frontend to emit this?
As I have previously stated in https://github.com/llvm/llvm-project/pull/134352#discussion_r2075542078 - I don't really understand the end goal. So this question should be readdressed to your internship curator (I'm judging that there is one from your reply: "Actually I was implementing this extension as part of an internship project."). My point is: that it's better not to use internal to intel/llvm metadata. If the goal is just to modify SPIR-V backend that way, that it can emit SPV_INTEL_cluster_attributes - spirv.Decorations metadata is the way to go.
Also, I can't tell for sure as I haven't tested it, but my expectation is that nowadays llvm-spirv translator supports SPV_INTEL_cluster_attributes via spirv.Decorations metadata implicitly.
https://github.com/llvm/llvm-project/pull/131593
More information about the llvm-commits
mailing list