28 changes: 14 additions & 14 deletions mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// CHECK: requires #spv.vce<v1.0, [Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.5, [Shader], []>, {}>
#spv.vce<v1.5, [Shader], []>, #spv.resource_limits<>>
} {
spv.func @iadd(%val : i32) -> i32 "None" {
%0 = spv.IAdd %val, %val: i32
Expand All @@ -24,7 +24,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: requires #spv.vce<v1.3, [GroupNonUniformBallot, Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.5, [Shader, GroupNonUniformBallot], []>, {}>
#spv.vce<v1.5, [Shader, GroupNonUniformBallot], []>, #spv.resource_limits<>>
} {
spv.func @group_non_uniform_ballot(%predicate : i1) -> vector<4xi32> "None" {
%0 = spv.GroupNonUniformBallot Workgroup %predicate : vector<4xi32>
Expand All @@ -41,7 +41,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: requires #spv.vce<v1.0, [Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader, Float16, Float64, Int16, Int64, VariablePointers], []>, {}>
#spv.vce<v1.0, [Shader, Float16, Float64, Int16, Int64, VariablePointers], []>, #spv.resource_limits<>>
} {
spv.func @iadd(%val : i32) -> i32 "None" {
%0 = spv.IAdd %val, %val: i32
Expand All @@ -54,7 +54,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: spv.module PhysicalStorageBuffer64 GLSL450 requires #spv.vce<v1.0, [PhysicalStorageBufferAddresses, Shader], [SPV_EXT_physical_storage_buffer]>
spv.module PhysicalStorageBuffer64 GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader, PhysicalStorageBufferAddresses], [SPV_EXT_physical_storage_buffer]>, {}>
#spv.vce<v1.0, [Shader, PhysicalStorageBufferAddresses], [SPV_EXT_physical_storage_buffer]>, #spv.resource_limits<>>
} {
spv.func @physical_ptr(%val : !spv.ptr<f32, PhysicalStorageBuffer>) "None" {
spv.Return
Expand All @@ -67,7 +67,7 @@ spv.module PhysicalStorageBuffer64 GLSL450 attributes {
// CHECK: requires #spv.vce<v1.0, [Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [AtomicStorage], []>, {}>
#spv.vce<v1.0, [AtomicStorage], []>, #spv.resource_limits<>>
} {
spv.func @iadd(%val : i32) -> i32 "None" {
%0 = spv.IAdd %val, %val: i32
Expand All @@ -88,7 +88,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: requires #spv.vce<v1.3, [GroupNonUniformArithmetic, Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.3, [Shader, GroupNonUniformArithmetic], []>, {}>
#spv.vce<v1.3, [Shader, GroupNonUniformArithmetic], []>, #spv.resource_limits<>>
} {
spv.func @group_non_uniform_iadd(%val : i32) -> i32 "None" {
%0 = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %val : i32
Expand All @@ -99,7 +99,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: requires #spv.vce<v1.3, [GroupNonUniformClustered, GroupNonUniformBallot, Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.3, [Shader, GroupNonUniformClustered, GroupNonUniformBallot], []>, {}>
#spv.vce<v1.3, [Shader, GroupNonUniformClustered, GroupNonUniformBallot], []>, #spv.resource_limits<>>
} {
spv.func @group_non_uniform_iadd(%val : i32) -> i32 "None" {
%0 = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %val : i32
Expand All @@ -113,7 +113,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: requires #spv.vce<v1.0, [Int8, Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.3, [Shader, Int8], []>, {}>
#spv.vce<v1.3, [Shader, Int8], []>, #spv.resource_limits<>>
} {
spv.func @iadd_function(%val : i8) -> i8 "None" {
%0 = spv.IAdd %val, %val : i8
Expand All @@ -125,7 +125,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: requires #spv.vce<v1.0, [Float16, Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.3, [Shader, Float16], []>, {}>
#spv.vce<v1.3, [Shader, Float16], []>, #spv.resource_limits<>>
} {
spv.func @fadd_function(%val : f16) -> f16 "None" {
%0 = spv.FAdd %val, %val : f16
Expand All @@ -137,7 +137,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: requires #spv.vce<v1.0, [Vector16, Shader], []>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.3, [Shader, Vector16], []>, {}>
#spv.vce<v1.3, [Shader, Vector16], []>, #spv.resource_limits<>>
} {
spv.func @iadd_v16_function(%val : vector<16xi32>) -> vector<16xi32> "None" {
%0 = spv.IAdd %val, %val : vector<16xi32>
Expand All @@ -156,7 +156,7 @@ spv.module Logical GLSL450 attributes {
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader, SubgroupBallotKHR],
[SPV_KHR_shader_ballot, SPV_KHR_shader_clock, SPV_KHR_variable_pointers]>, {}>
[SPV_KHR_shader_ballot, SPV_KHR_shader_clock, SPV_KHR_variable_pointers]>, #spv.resource_limits<>>
} {
spv.func @subgroup_ballot(%predicate : i1) -> vector<4xi32> "None" {
%0 = spv.SubgroupBallotKHR %predicate: vector<4xi32>
Expand All @@ -171,7 +171,7 @@ spv.module Logical GLSL450 attributes {
// CHECK: requires #spv.vce<v1.0, [VulkanMemoryModel], [SPV_KHR_vulkan_memory_model]>
spv.module Logical Vulkan attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.5, [Shader, VulkanMemoryModel], []>, {}>
#spv.vce<v1.5, [Shader, VulkanMemoryModel], []>, #spv.resource_limits<>>
} {
spv.func @iadd(%val : i32) -> i32 "None" {
%0 = spv.IAdd %val, %val: i32
Expand All @@ -186,7 +186,7 @@ spv.module Logical Vulkan attributes {
// CHECK: requires #spv.vce<v1.0, [StorageBuffer16BitAccess, Shader, Int16], [SPV_KHR_16bit_storage, SPV_KHR_storage_buffer_storage_class]>
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.3, [Shader, StorageBuffer16BitAccess, Int16], []>, {}>
#spv.vce<v1.3, [Shader, StorageBuffer16BitAccess, Int16], []>, #spv.resource_limits<>>
} {
spv.func @iadd_storage_buffer(%ptr : !spv.ptr<i16, StorageBuffer>) -> i16 "None" {
%0 = spv.Load "StorageBuffer" %ptr : i16
Expand All @@ -202,7 +202,7 @@ spv.module Logical GLSL450 attributes {
spv.module Logical GLSL450 attributes {
spv.target_env = #spv.target_env<
#spv.vce<v1.5, [Shader, UniformAndStorageBuffer8BitAccess, StorageBuffer16BitAccess, StorageUniform16, Int16, Int64, ImageBuffer, StorageImageExtendedFormats], []>,
{}>
#spv.resource_limits<>>
} {
spv.GlobalVariable @data : !spv.ptr<!spv.struct<(i8 [0], f16 [2], i64 [4])>, Uniform>
spv.GlobalVariable @img : !spv.ptr<!spv.image<f32, Buffer, NoDepth, NonArrayed, SingleSampled, SamplerUnknown, Rg32f>, UniformConstant>
Expand Down
3 changes: 3 additions & 0 deletions mlir/test/lib/Dialect/SPIRV/TestEntryPointAbi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ struct TestSpirvEntryPointABIPass
"within the "
"module, intended for testing only";
}
void getDependentDialects(DialectRegistry &registry) const override {
registry.insert<spirv::SPIRVDialect>();
}
TestSpirvEntryPointABIPass() = default;
TestSpirvEntryPointABIPass(const TestSpirvEntryPointABIPass &) {}
void runOnOperation() override;
Expand Down
7 changes: 4 additions & 3 deletions mlir/test/mlir-spirv-cpu-runner/double.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ module attributes {
gpu.container_module,
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader], [SPV_KHR_variable_pointers]>,
{max_compute_workgroup_invocations = 128 : i32,
max_compute_workgroup_size = dense<[128, 128, 64]> : vector<3xi32>}>
#spv.resource_limits<
max_compute_workgroup_invocations = 128,
max_compute_workgroup_size = [128, 128, 64]>>
} {
gpu.module @kernels {
gpu.func @double(%arg0 : memref<6xi32>, %arg1 : memref<6xi32>)
kernel attributes { spv.entry_point_abi = {local_size = dense<[1, 1, 1]>: vector<3xi32>}} {
kernel attributes { spv.entry_point_abi = #spv.entry_point_abi<local_size = dense<[1, 1, 1]>: vector<3xi32>>} {
%factor = arith.constant 2 : i32

%i0 = arith.constant 0 : index
Expand Down
7 changes: 4 additions & 3 deletions mlir/test/mlir-spirv-cpu-runner/simple_add.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ module attributes {
gpu.container_module,
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class, SPV_KHR_8bit_storage]>,
{max_compute_workgroup_invocations = 128 : i32,
max_compute_workgroup_size = dense<[128, 128, 64]> : vector<3xi32>}>
#spv.resource_limits<
max_compute_workgroup_invocations = 128,
max_compute_workgroup_size = [128, 128, 64]>>
} {
gpu.module @kernels {
gpu.func @sum(%arg0 : memref<3xf32>, %arg1 : memref<3x3xf32>, %arg2 : memref<3x3x3xf32>)
kernel attributes { spv.entry_point_abi = {local_size = dense<[1, 1, 1]>: vector<3xi32>}} {
kernel attributes { spv.entry_point_abi = #spv.entry_point_abi<local_size = dense<[1, 1, 1]>: vector<3xi32>>} {
%i0 = arith.constant 0 : index
%i1 = arith.constant 1 : index
%i2 = arith.constant 2 : index
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/mlir-vulkan-runner/addf.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
module attributes {
gpu.container_module,
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, {}>
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spv.resource_limits<>>
} {
gpu.module @kernels {
gpu.func @kernel_add(%arg0 : memref<8xf32>, %arg1 : memref<8xf32>, %arg2 : memref<8xf32>)
kernel attributes { spv.entry_point_abi = {local_size = dense<[1, 1, 1]>: vector<3xi32> }} {
kernel attributes { spv.entry_point_abi = #spv.entry_point_abi<local_size = dense<[1, 1, 1]>: vector<3xi32>>} {
%0 = gpu.block_id x
%1 = memref.load %arg0[%0] : memref<8xf32>
%2 = memref.load %arg1[%0] : memref<8xf32>
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/mlir-vulkan-runner/addi.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
module attributes {
gpu.container_module,
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, {}>
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spv.resource_limits<>>
} {
gpu.module @kernels {
gpu.func @kernel_addi(%arg0 : memref<8xi32>, %arg1 : memref<8x8xi32>, %arg2 : memref<8x8x8xi32>)
kernel attributes { spv.entry_point_abi = {local_size = dense<[1, 1, 1]>: vector<3xi32>}} {
kernel attributes { spv.entry_point_abi = #spv.entry_point_abi<local_size = dense<[1, 1, 1]>: vector<3xi32>>} {
%x = gpu.block_id x
%y = gpu.block_id y
%z = gpu.block_id z
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/mlir-vulkan-runner/addi8.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
module attributes {
gpu.container_module,
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class, SPV_KHR_8bit_storage]>, {}>
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class, SPV_KHR_8bit_storage]>, #spv.resource_limits<>>
} {
gpu.module @kernels {
gpu.func @kernel_addi(%arg0 : memref<8xi8>, %arg1 : memref<8x8xi8>, %arg2 : memref<8x8x8xi32>)
kernel attributes { spv.entry_point_abi = {local_size = dense<[1, 1, 1]>: vector<3xi32>}} {
kernel attributes { spv.entry_point_abi = #spv.entry_point_abi<local_size = dense<[1, 1, 1]>: vector<3xi32>>} {
%x = gpu.block_id x
%y = gpu.block_id y
%z = gpu.block_id z
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/mlir-vulkan-runner/mulf.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
module attributes {
gpu.container_module,
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, {}>
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spv.resource_limits<>>
} {
gpu.module @kernels {
gpu.func @kernel_mul(%arg0 : memref<4x4xf32>, %arg1 : memref<4x4xf32>, %arg2 : memref<4x4xf32>)
kernel attributes { spv.entry_point_abi = {local_size = dense<[1, 1, 1]>: vector<3xi32> }} {
kernel attributes { spv.entry_point_abi = #spv.entry_point_abi<local_size = dense<[1, 1, 1]>: vector<3xi32>>} {
%x = gpu.block_id x
%y = gpu.block_id y
%1 = memref.load %arg0[%x, %y] : memref<4x4xf32>
Expand Down
5 changes: 3 additions & 2 deletions mlir/test/mlir-vulkan-runner/subf.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
module attributes {
gpu.container_module,
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, {}>
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>,
#spv.resource_limits<>>
} {
gpu.module @kernels {
gpu.func @kernel_sub(%arg0 : memref<8x4x4xf32>, %arg1 : memref<4x4xf32>, %arg2 : memref<8x4x4xf32>)
kernel attributes { spv.entry_point_abi = {local_size = dense<[1, 1, 1]>: vector<3xi32> }} {
kernel attributes { spv.entry_point_abi = #spv.entry_point_abi<local_size = dense<[1, 1, 1]>: vector<3xi32>>} {
%x = gpu.block_id x
%y = gpu.block_id y
%z = gpu.block_id z
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/mlir-vulkan-runner/time.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
module attributes {
gpu.container_module,
spv.target_env = #spv.target_env<
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, {}>
#spv.vce<v1.0, [Shader], [SPV_KHR_storage_buffer_storage_class]>, #spv.resource_limits>
} {
gpu.module @kernels {
gpu.func @kernel_add(%arg0 : memref<16384xf32>, %arg1 : memref<16384xf32>, %arg2 : memref<16384xf32>)
kernel attributes { spv.entry_point_abi = {local_size = dense<[128, 1, 1]>: vector<3xi32> }} {
kernel attributes { spv.entry_point_abi = #spv.entry_point_abi<local_size = dense<[128, 1, 1]>: vector<3xi32>>} {
%bid = gpu.block_id x
%tid = gpu.thread_id x
%cst = arith.constant 128 : index
Expand Down
4 changes: 4 additions & 0 deletions mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,11 @@ void DefFormat::genParser(MethodBody &os) {
FmtContext ctx;
ctx.addSubst("_parser", "odsParser");
ctx.addSubst("_ctx", "odsParser.getContext()");
ctx.withBuilder("odsBuilder");
if (isa<AttrDef>(def))
ctx.addSubst("_type", "odsType");
os.indent();
os << "::mlir::Builder odsBuilder(odsParser.getContext());\n";

// Declare variables to store all of the parameters. Allocated parameters
// such as `ArrayRef` and `StringRef` must provide a `storageType`. Store
Expand Down Expand Up @@ -668,7 +670,9 @@ void DefFormat::genPrinter(MethodBody &os) {
FmtContext ctx;
ctx.addSubst("_printer", "odsPrinter");
ctx.addSubst("_ctx", "getContext()");
ctx.withBuilder("odsBuilder");
os.indent();
os << "::mlir::Builder odsBuilder(getContext());\n";

// Generate printers.
shouldEmitSpace = true;
Expand Down
37 changes: 19 additions & 18 deletions utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4471,6 +4471,24 @@ gentbl_cc_library(
deps = [":SPIRVOpsTdFiles"],
)

gentbl_cc_library(
name = "SPIRVAttributesIncGen",
strip_include_prefix = "include",
tbl_outs = [
(
["-gen-attrdef-decls"],
"include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.h.inc",
),
(
["-gen-attrdef-defs"],
"include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.cpp.inc",
),
],
tblgen = ":mlir-tblgen",
td_file = "include/mlir/Dialect/SPIRV/IR/SPIRVAttributes.td",
deps = [":SPIRVOpsTdFiles"],
)

gentbl_cc_library(
name = "SPIRVCanonicalizationIncGen",
strip_include_prefix = "lib/Dialect/SPIRV/IR",
Expand Down Expand Up @@ -4507,23 +4525,6 @@ gentbl_cc_library(
deps = [":SPIRVOpsTdFiles"],
)

gentbl_cc_library(
name = "SPIRVTargetAndABIStructGen",
tbl_outs = [
(
["-gen-struct-attr-decls"],
"include/mlir/Dialect/SPIRV/IR/TargetAndABI.h.inc",
),
(
["-gen-struct-attr-defs"],
"include/mlir/Dialect/SPIRV/IR/TargetAndABI.cpp.inc",
),
],
tblgen = ":mlir-tblgen",
td_file = "include/mlir/Dialect/SPIRV/IR/TargetAndABI.td",
deps = [":SPIRVOpsTdFiles"],
)

gentbl_cc_library(
name = "SPIRVAttrUtilsGen",
strip_include_prefix = "include",
Expand Down Expand Up @@ -4569,11 +4570,11 @@ cc_library(
":InferTypeOpInterface",
":Parser",
":SPIRVAttrUtilsGen",
":SPIRVAttributesIncGen",
":SPIRVAvailabilityIncGen",
":SPIRVCanonicalizationIncGen",
":SPIRVOpsIncGen",
":SPIRVSerializationGen",
":SPIRVTargetAndABIStructGen",
":SideEffectInterfaces",
":Support",
":Transforms",
Expand Down