Skip to content

Commit 547c600

Browse files
committed
Address comments
1 parent 836d707 commit 547c600

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ LogicalResult deserializeCacheControlDecoration(
242242
SmallVector<Attribute> attrs;
243243
if (auto attrList =
244244
llvm::dyn_cast_or_null<ArrayAttr>(decorations[words[0]].get(symbol)))
245-
attrs.append(attrList.begin(), attrList.end());
245+
llvm::append_range(attrs, attrList);
246246
attrs.push_back(value);
247247
decorations[words[0]].set(symbol, opBuilder.getArrayAttr(attrs));
248248
return success();

mlir/lib/Target/SPIRV/Serialization/Serializer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,8 @@ LogicalResult processDecorationList(Location loc, Decoration decoration,
247247
}
248248
// This named attribute encodes several decorations. Emit one per
249249
// element in the array.
250-
LogicalResult res = emitter(cacheControlAttr);
251-
if (failed(res))
252-
return res;
250+
if (failed(emitter(cacheControlAttr)))
251+
return failure();
253252
}
254253
return success();
255254
}

mlir/test/Target/SPIRV/decorations.mlir

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: mlir-translate -no-implicit-module -split-input-file -test-spirv-roundtrip %s | FileCheck %s
1+
// RUN: mlir-translate -no-implicit-module -split-input-file -test-spirv-roundtrip -verify-diagnostics %s | FileCheck %s
22

33
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
44
// CHECK: location = 0 : i32
@@ -113,11 +113,41 @@ spirv.func @fp_rounding_mode(%arg: f32) -> f16 "None" {
113113
// CHECK-LABEL: spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [CacheControlsINTEL], [SPV_INTEL_cache_controls]> {
114114

115115
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [CacheControlsINTEL], [SPV_INTEL_cache_controls]> {
116-
spirv.func @foo() "None" {
116+
spirv.func @cache_controls() "None" {
117117
// CHECK: spirv.Variable {cache_control_load_intel = [#spirv.cache_control_load_intel<cache_level = 0, load_cache_control = Uncached>, #spirv.cache_control_load_intel<cache_level = 1, load_cache_control = Cached>, #spirv.cache_control_load_intel<cache_level = 2, load_cache_control = InvalidateAfterR>]} : !spirv.ptr<f32, Function>
118118
%0 = spirv.Variable {cache_control_load_intel = [#spirv.cache_control_load_intel<cache_level = 0, load_cache_control = Uncached>, #spirv.cache_control_load_intel<cache_level = 1, load_cache_control = Cached>, #spirv.cache_control_load_intel<cache_level = 2, load_cache_control = InvalidateAfterR>]} : !spirv.ptr<f32, Function>
119119
// CHECK: spirv.Variable {cache_control_store_intel = [#spirv.cache_control_store_intel<cache_level = 0, store_cache_control = Uncached>, #spirv.cache_control_store_intel<cache_level = 1, store_cache_control = WriteThrough>, #spirv.cache_control_store_intel<cache_level = 2, store_cache_control = WriteBack>]} : !spirv.ptr<f32, Function>
120120
%1 = spirv.Variable {cache_control_store_intel = [#spirv.cache_control_store_intel<cache_level = 0, store_cache_control = Uncached>, #spirv.cache_control_store_intel<cache_level = 1, store_cache_control = WriteThrough>, #spirv.cache_control_store_intel<cache_level = 2, store_cache_control = WriteBack>]} : !spirv.ptr<f32, Function>
121121
spirv.Return
122122
}
123123
}
124+
125+
// -----
126+
127+
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [CacheControlsINTEL], [SPV_INTEL_cache_controls]> {
128+
spirv.func @cache_controls_invalid_type() "None" {
129+
// expected-error@below {{expecting array attribute of CacheControlLoadINTEL for CacheControlLoadINTEL}}
130+
%0 = spirv.Variable {cache_control_load_intel = #spirv.cache_control_load_intel<cache_level = 0, load_cache_control = Uncached>} : !spirv.ptr<f32, Function>
131+
spirv.Return
132+
}
133+
}
134+
135+
// -----
136+
137+
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [CacheControlsINTEL], [SPV_INTEL_cache_controls]> {
138+
spirv.func @cache_controls_invalid_type() "None" {
139+
// expected-error@below {{expecting array attribute of CacheControlStoreINTEL for CacheControlStoreINTEL}}
140+
%0 = spirv.Variable {cache_control_store_intel = [#spirv.cache_control_store_intel<cache_level = 0, store_cache_control = Uncached>, 0 : i32]} : !spirv.ptr<f32, Function>
141+
spirv.Return
142+
}
143+
}
144+
145+
// -----
146+
147+
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [CacheControlsINTEL], [SPV_INTEL_cache_controls]> {
148+
spirv.func @cache_controls_invalid_type() "None" {
149+
// expected-error@below {{expecting non-empty array attribute of CacheControlStoreINTEL for CacheControlStoreINTEL}}
150+
%0 = spirv.Variable {cache_control_store_intel = []} : !spirv.ptr<f32, Function>
151+
spirv.Return
152+
}
153+
}

0 commit comments

Comments
 (0)