This patch extends the AccessChainOp index type handling to be able to deal with all Integer type indices (i.e., all bit-widths and signedness symantics). There were two ways of achieving this: 1- Backward compatible: The new way of handling the indices will assume that an index type is i32 by default if not specified in the assembly format, this way all the old tests would pass correctly. 2- Enforce the format: This unifies the spv.AccessChain Op format and all the old tests had to be updated to reflect this change or else they fail. I picked option-2 to unify the Op format and avoid having optional index-type fields that can lead to somewhat confusing tests format and multiple representations for the same Op with undocumented assumption that an index is i32 unless stated. Nonetheless, reverting to option-1 should be straightforward if preferred or needed. Differential Revision: https://reviews.llvm.org/D81763
37 lines
1.7 KiB
MLIR
37 lines
1.7 KiB
MLIR
// RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s
|
|
|
|
// CHECK: spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
|
|
// CHECK-NEXT: spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
|
|
// CHECK-NEXT: spv.globalVariable @var2 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
|
// CHECK-NEXT: spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
|
|
|
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
|
|
spv.globalVariable @var0 bind(1, 0) : !spv.ptr<f32, Input>
|
|
spv.globalVariable @var1 bind(0, 1) : !spv.ptr<f32, Output>
|
|
spv.globalVariable @var2 {built_in = "GlobalInvocationId"} : !spv.ptr<vector<3xi32>, Input>
|
|
spv.globalVariable @var3 built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
|
}
|
|
|
|
// -----
|
|
|
|
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
|
|
// CHECK: spv.globalVariable @var1 : !spv.ptr<f32, Input>
|
|
// CHECK-NEXT: spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
|
|
spv.globalVariable @var1 : !spv.ptr<f32, Input>
|
|
spv.globalVariable @var2 initializer(@var1) bind(1, 0) : !spv.ptr<f32, Input>
|
|
}
|
|
|
|
// -----
|
|
|
|
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
|
|
spv.globalVariable @globalInvocationID built_in("GlobalInvocationId") : !spv.ptr<vector<3xi32>, Input>
|
|
spv.func @foo() "None" {
|
|
// CHECK: %[[ADDR:.*]] = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
|
|
%0 = spv._address_of @globalInvocationID : !spv.ptr<vector<3xi32>, Input>
|
|
%1 = spv.constant 0: i32
|
|
// CHECK: spv.AccessChain %[[ADDR]]
|
|
%2 = spv.AccessChain %0[%1] : !spv.ptr<vector<3xi32>, Input>, i32
|
|
spv.Return
|
|
}
|
|
}
|