forked from OSchip/llvm-project
[mlir][SPIRVToLLVM] Solve ExecutionModeOp redefinition and add OpTypeSampledImage into SPV_Type
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
This commit is contained in:
parent
c5a5517be4
commit
c0a6381e49
|
@ -3154,7 +3154,7 @@ def SPV_Composite :
|
|||
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]>;
|
||||
|
|
|
@ -642,15 +642,17 @@ public:
|
|||
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);
|
||||
|
@ -683,7 +685,6 @@ public:
|
|||
// 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>(
|
||||
|
|
|
@ -94,7 +94,8 @@ spv.module Logical OpenCL {
|
|||
// 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.module Logical OpenCL {
|
|||
spv.Return
|
||||
}
|
||||
spv.EntryPoint "Kernel" @bar
|
||||
spv.ExecutionMode @bar "ContractionOff"
|
||||
spv.ExecutionMode @bar "LocalSizeHint", 32, 1, 1
|
||||
}
|
||||
|
||||
|
|
|
@ -341,11 +341,15 @@ func @aligned_load_incorrect_attributes() -> () {
|
|||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue