File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
third_party/intel/lib/Target/LLVMIR/Dialect/TritonGEN Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,24 @@ class TritonGENDialectLLVMIRTranslationInterface
103103 llvm::MDNode::get (ctx, decorations));
104104 return success ();
105105 }
106+
107+ static LogicalResult
108+ handleTritonGenOpenCLKernelsAttr (Operation *op,
109+ LLVM::ModuleTranslation &moduleTranslation) {
110+ auto mlirFunc = dyn_cast<LLVM::LLVMFuncOp>(op);
111+ if (!mlirFunc)
112+ return op->emitOpError (" triton_gen.opencl_kernels attribute attached to "
113+ " non-function operation" );
114+ llvm::Function *func = moduleTranslation.lookupFunction (mlirFunc.getName ());
115+ assert (func && " Function not found" );
116+ constexpr StringLiteral openCLKernelsMDName = " opencl.kernels" ;
117+ llvm::NamedMDNode *openCLKernels =
118+ moduleTranslation.getOrInsertNamedModuleMetadata (openCLKernelsMDName);
119+ llvm::Metadata *kernelRef = llvm::ConstantAsMetadata::get (func);
120+ openCLKernels->addOperand (
121+ llvm::MDNode::get (moduleTranslation.getLLVMContext (), kernelRef));
122+ return success ();
123+ }
106124};
107125} // namespace
108126
You can’t perform that action at this time.
0 commit comments