[Mlir-commits] [mlir] [MLIR][XeVM] Rewrite llvm.alloca if addr_space is not 0 (PR #183417)

Sang Ik Lee llvmlistbot at llvm.org
Thu Feb 26 10:01:48 PST 2026


================
@@ -836,6 +838,46 @@ class SubgroupOpWorkitemOpToOCLPattern : public OpConversionPattern<OpType> {
   }
 };
 
+static unsigned getNextGlobalIdx() {
+  static unsigned globalIdx = 0;
+  return globalIdx++;
+}
+
+class AllocaToGlobalPattern : public OpConversionPattern<LLVM::AllocaOp> {
+  using OpConversionPattern::OpConversionPattern;
+  LogicalResult
+  matchAndRewrite(LLVM::AllocaOp op, LLVM::AllocaOp::Adaptor adaptor,
+                  ConversionPatternRewriter &rewriter) const override {
+    auto moduleOp = op->getParentOfType<ModuleOp>();
+    if (!moduleOp)
+      return failure();
+    auto ptrType = cast<LLVM::LLVMPointerType>(op.getType());
+    auto addrSpace = ptrType.getAddressSpace();
+    if (addrSpace != 3)
----------------
silee2 wrote:

xevm enum values are virutal and not tied to a backend. The numeric value here is specific to OpenCL.
SPIR-V dialect also only defines virtual enum for address space since actual numeric value differs for Vulkan and OpenCL.

https://github.com/llvm/llvm-project/pull/183417


More information about the Mlir-commits mailing list