diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVBase.td @@ -3154,7 +3154,7 @@ def SPV_Type : AnyTypeOf<[ SPV_Void, SPV_Bool, SPV_Integer, SPV_Float, SPV_Vector, SPV_AnyPtr, SPV_AnyArray, SPV_AnyRTArray, SPV_AnyStruct, - SPV_AnyCooperativeMatrix, SPV_AnyMatrix + SPV_AnyCooperativeMatrix, SPV_AnyMatrix, SPV_AnySampledImage ]>; def SPV_SignedInt : SignedIntOfWidths<[8, 16, 32, 64]>; diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp @@ -642,15 +642,17 @@ ConversionPatternRewriter &rewriter) const override { // First, create the global struct's name that would be associated with // this entry point's execution mode. We set it to be: - // __spv__{SPIR-V module name}_{function name}_execution_mode_info + // __spv__{SPIR-V module name}_{function name}_execution_mode_info_{mode} ModuleOp module = op->getParentOfType(); + IntegerAttr executionModeAttr = op.execution_modeAttr(); std::string moduleName; if (module.getName().hasValue()) moduleName = "_" + module.getName().getValue().str(); else moduleName = ""; - std::string executionModeInfoName = llvm::formatv( - "__spv_{0}_{1}_execution_mode_info", moduleName, op.fn().str()); + std::string executionModeInfoName = + llvm::formatv("__spv_{0}_{1}_execution_mode_info_{2}", moduleName, + op.fn().str(), executionModeAttr.getValue()); MLIRContext *context = rewriter.getContext(); OpBuilder::InsertionGuard guard(rewriter); @@ -683,7 +685,6 @@ // Initialize the struct and set the execution mode value. rewriter.setInsertionPoint(block, block->begin()); Value structValue = rewriter.create(loc, structType); - IntegerAttr executionModeAttr = op.execution_modeAttr(); Value executionMode = rewriter.create(loc, llvmI32Type, executionModeAttr); structValue = rewriter.create( diff --git a/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir b/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir --- a/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir +++ b/mlir/test/Conversion/SPIRVToLLVM/misc-ops-to-llvm.mlir @@ -94,7 +94,8 @@ // CHECK-NEXT: %[[RET:.*]] = llvm.insertvalue %[[C2]], %[[T2]][1 : i32, 2 : i32] : !llvm.struct<(i32, array<3 x i32>)> // CHECK-NEXT: llvm.return %[[RET]] : !llvm.struct<(i32, array<3 x i32>)> // CHECK-NEXT: } -// CHECK-NEXT: llvm.func @bar +// CHECK-NEXT: llvm.mlir.global external constant @{{.*}}() : !llvm.struct<(i32)> { +// CHECK: llvm.func @bar // CHECK-NEXT: llvm.return // CHECK-NEXT: } // CHECK-NEXT: } @@ -103,6 +104,7 @@ spv.Return } spv.EntryPoint "Kernel" @bar + spv.ExecutionMode @bar "ContractionOff" spv.ExecutionMode @bar "LocalSizeHint", 32, 1, 1 } diff --git a/mlir/test/Dialect/SPIRV/IR/memory-ops.mlir b/mlir/test/Dialect/SPIRV/IR/memory-ops.mlir --- a/mlir/test/Dialect/SPIRV/IR/memory-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/memory-ops.mlir @@ -341,11 +341,15 @@ spv.module Logical GLSL450 { spv.GlobalVariable @var0 : !spv.ptr + spv.GlobalVariable @var1 : !spv.ptr>, UniformConstant> // CHECK_LABEL: @simple_load spv.func @simple_load() -> () "None" { // CHECK: spv.Load "Input" {{%.*}} : f32 %0 = spv.mlir.addressof @var0 : !spv.ptr %1 = spv.Load "Input" %0 : f32 + %2 = spv.mlir.addressof @var1 : !spv.ptr>, UniformConstant> + // CHECK: spv.Load "UniformConstant" {{%.*}} : !spv.sampled_image + %3 = spv.Load "UniformConstant" %2 : !spv.sampled_image> spv.Return } }