[llvm-branch-commits] [clang] [CIR][OpenCL] Lower kernel argument metadata to LLVM IR (PR #200582)
David Rivera via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jun 12 12:56:30 PDT 2026
================
@@ -75,11 +79,80 @@ class CIRDialectLLVMIRTranslationInterface
// Strip the "cir." prefix to get the LLVM attribute name.
llvm::StringRef llvmAttrName = attrName.substr(strlen("cir."));
- if (auto strAttr = mlir::dyn_cast<mlir::StringAttr>(attribute.getValue()))
+ if (auto clArgMetadata = mlir::dyn_cast<cir::OpenCLKernelArgMetadataAttr>(
+ attribute.getValue())) {
+ emitOpenCLKernelArgMetadata(clArgMetadata, llvmFunc, moduleTranslation);
+ } else if (auto strAttr =
+ mlir::dyn_cast<mlir::StringAttr>(attribute.getValue())) {
llvmFunc->addFnAttr(llvmAttrName, strAttr.getValue());
+ }
return mlir::success();
}
+ void emitOpenCLKernelArgMetadata(
+ cir::OpenCLKernelArgMetadataAttr clArgMetadata, llvm::Function *llvmFunc,
+ mlir::LLVM::ModuleTranslation &moduleTranslation) const {
+ llvm::LLVMContext &llvmContext = moduleTranslation.getLLVMContext();
+
+ SmallVector<llvm::Metadata *, 8> addressQuals;
+
+ auto getOpenCLArgInfoAddressSpace = [](cir::LangAddressSpace addressSpace) {
----------------
RiverDave wrote:
This transformation shoud've been handled earlier in TargetLowering pass. You might need to evaluate if the existing pass can handle generic cir attributes carrying AS.
https://github.com/llvm/llvm-project/pull/200582
More information about the llvm-branch-commits
mailing list