1. To avoid two ExecutionModeOp using the same name, adding the value of execution mode in name when converting to LLVM dialect.
2. To avoid syntax error in spv.OpLoad, add OpTypeSampledImage into SPV_Type.
Reviewed by:antiagainst
Differential revision:https://reviews.llvm.org/D111193
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]>;
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<ModuleOp>();
+ 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);
// Initialize the struct and set the execution mode value.
rewriter.setInsertionPoint(block, block->begin());
Value structValue = rewriter.create<LLVM::UndefOp>(loc, structType);
- IntegerAttr executionModeAttr = op.execution_modeAttr();
Value executionMode =
rewriter.create<LLVM::ConstantOp>(loc, llvmI32Type, executionModeAttr);
structValue = rewriter.create<LLVM::InsertValueOp>(
// 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: }
spv.Return
}
spv.EntryPoint "Kernel" @bar
+ spv.ExecutionMode @bar "ContractionOff"
spv.ExecutionMode @bar "LocalSizeHint", 32, 1, 1
}
spv.module Logical GLSL450 {
spv.GlobalVariable @var0 : !spv.ptr<f32, Input>
+ spv.GlobalVariable @var1 : !spv.ptr<!spv.sampled_image<!spv.image<f32, Dim2D, IsDepth, Arrayed, SingleSampled, NeedSampler, Unknown>>, UniformConstant>
// CHECK_LABEL: @simple_load
spv.func @simple_load() -> () "None" {
// CHECK: spv.Load "Input" {{%.*}} : f32
%0 = spv.mlir.addressof @var0 : !spv.ptr<f32, Input>
%1 = spv.Load "Input" %0 : f32
+ %2 = spv.mlir.addressof @var1 : !spv.ptr<!spv.sampled_image<!spv.image<f32, Dim2D, IsDepth, Arrayed, SingleSampled, NeedSampler, Unknown>>, UniformConstant>
+ // CHECK: spv.Load "UniformConstant" {{%.*}} : !spv.sampled_image
+ %3 = spv.Load "UniformConstant" %2 : !spv.sampled_image<!spv.image<f32, Dim2D, IsDepth, Arrayed, SingleSampled, NeedSampler, Unknown>>
spv.Return
}
}