SPIR-V spec requires that any calls to external functions are preceded by declarations of those external functions. To simplify the implementation, we sort functions in the serializer using a stronger condition: any functions declarations are moved before any functions definitions - this ensures that external functions are always declared before being used.
97 lines
4.5 KiB
MLIR
97 lines
4.5 KiB
MLIR
// RUN: mlir-translate --no-implicit-module --test-spirv-roundtrip --split-input-file %s | FileCheck %s
|
|
|
|
// RUN: %if spirv-tools %{ rm -rf %t %}
|
|
// RUN: %if spirv-tools %{ mkdir %t %}
|
|
// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
|
|
// RUN: %if spirv-tools %{ spirv-val %t %}
|
|
|
|
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage, Int8, Int16], []> {
|
|
// CHECK: spirv.func @outside.func.with.linkage(i8) "Pure" attributes
|
|
// CHECK: linkage_attributes = #spirv.linkage_attributes<linkage_name = "outside.func", linkage_type = <Import>>
|
|
// CHECK: spirv.func @linkage_attr_test_kernel() "DontInline" {
|
|
// CHECK: spirv.func @inside.func() "Pure" {
|
|
spirv.func @linkage_attr_test_kernel() "DontInline" attributes {} {
|
|
%uchar_0 = spirv.Constant 0 : i8
|
|
%ushort_1 = spirv.Constant 1 : i16
|
|
%uint_0 = spirv.Constant 0 : i32
|
|
spirv.FunctionCall @outside.func.with.linkage(%uchar_0):(i8) -> ()
|
|
spirv.Return
|
|
}
|
|
spirv.func @outside.func.with.linkage(%arg0 : i8) -> () "Pure" attributes {
|
|
linkage_attributes=#spirv.linkage_attributes<
|
|
linkage_name="outside.func",
|
|
linkage_type=<Import>
|
|
>
|
|
}
|
|
spirv.func @inside.func() -> () "Pure" attributes {} {spirv.Return}
|
|
}
|
|
|
|
// -----
|
|
|
|
spirv.module PhysicalStorageBuffer64 GLSL450 requires #spirv.vce<v1.0,
|
|
[Shader, PhysicalStorageBufferAddresses, Linkage], [SPV_KHR_physical_storage_buffer]> {
|
|
// CHECK-LABEL: spirv.func @func_arg_decoration_aliased(%{{.*}}: !spirv.ptr<i32, PhysicalStorageBuffer> {spirv.decoration = #spirv.decoration<Aliased>})
|
|
spirv.func @func_arg_decoration_aliased(
|
|
%arg0 : !spirv.ptr<i32, PhysicalStorageBuffer> { spirv.decoration = #spirv.decoration<Aliased> }
|
|
) "None" {
|
|
spirv.Return
|
|
}
|
|
}
|
|
|
|
// -----
|
|
|
|
spirv.module PhysicalStorageBuffer64 GLSL450 requires #spirv.vce<v1.0,
|
|
[Shader, PhysicalStorageBufferAddresses, Linkage], [SPV_KHR_physical_storage_buffer]> {
|
|
// CHECK-LABEL: spirv.func @func_arg_decoration_restrict(%{{.*}}: !spirv.ptr<i32, PhysicalStorageBuffer> {spirv.decoration = #spirv.decoration<Restrict>})
|
|
spirv.func @func_arg_decoration_restrict(
|
|
%arg0 : !spirv.ptr<i32,PhysicalStorageBuffer> { spirv.decoration = #spirv.decoration<Restrict> }
|
|
) "None" {
|
|
spirv.Return
|
|
}
|
|
}
|
|
|
|
// -----
|
|
|
|
spirv.module PhysicalStorageBuffer64 GLSL450 requires #spirv.vce<v1.0,
|
|
[Shader, PhysicalStorageBufferAddresses, Linkage, GenericPointer], [SPV_KHR_physical_storage_buffer]> {
|
|
// CHECK-LABEL: spirv.func @func_arg_decoration_aliased_pointer(%{{.*}}: !spirv.ptr<!spirv.ptr<i32, PhysicalStorageBuffer>, Generic> {spirv.decoration = #spirv.decoration<AliasedPointer>})
|
|
spirv.func @func_arg_decoration_aliased_pointer(
|
|
%arg0 : !spirv.ptr<!spirv.ptr<i32,PhysicalStorageBuffer>, Generic> { spirv.decoration = #spirv.decoration<AliasedPointer> }
|
|
) "None" {
|
|
spirv.Return
|
|
}
|
|
}
|
|
|
|
// -----
|
|
|
|
spirv.module PhysicalStorageBuffer64 GLSL450 requires #spirv.vce<v1.0,
|
|
[Shader, PhysicalStorageBufferAddresses, Linkage, GenericPointer], [SPV_KHR_physical_storage_buffer]> {
|
|
// CHECK-LABEL: spirv.func @func_arg_decoration_restrict_pointer(%{{.*}}: !spirv.ptr<!spirv.ptr<i32, PhysicalStorageBuffer>, Generic> {spirv.decoration = #spirv.decoration<RestrictPointer>})
|
|
spirv.func @func_arg_decoration_restrict_pointer(
|
|
%arg0 : !spirv.ptr<!spirv.ptr<i32,PhysicalStorageBuffer>, Generic> { spirv.decoration = #spirv.decoration<RestrictPointer> }
|
|
) "None" {
|
|
spirv.Return
|
|
}
|
|
}
|
|
|
|
// -----
|
|
|
|
spirv.module PhysicalStorageBuffer64 GLSL450 requires #spirv.vce<v1.0,
|
|
[Shader, PhysicalStorageBufferAddresses, Linkage], [SPV_KHR_physical_storage_buffer]> {
|
|
// CHECK-LABEL: spirv.func @fn1(%{{.*}}: i32, %{{.*}}: !spirv.ptr<i32, PhysicalStorageBuffer> {spirv.decoration = #spirv.decoration<Aliased>})
|
|
spirv.func @fn1(
|
|
%arg0: i32,
|
|
%arg1: !spirv.ptr<i32, PhysicalStorageBuffer> { spirv.decoration = #spirv.decoration<Aliased> }
|
|
) "None" {
|
|
spirv.Return
|
|
}
|
|
|
|
// CHECK-LABEL: spirv.func @fn2(%{{.*}}: !spirv.ptr<i32, PhysicalStorageBuffer> {spirv.decoration = #spirv.decoration<Aliased>}, %{{.*}}: !spirv.ptr<i32, PhysicalStorageBuffer> {spirv.decoration = #spirv.decoration<Restrict>})
|
|
spirv.func @fn2(
|
|
%arg0: !spirv.ptr<i32, PhysicalStorageBuffer> { spirv.decoration = #spirv.decoration<Aliased> },
|
|
%arg1: !spirv.ptr<i32, PhysicalStorageBuffer> { spirv.decoration = #spirv.decoration<Restrict>}
|
|
) "None" {
|
|
spirv.Return
|
|
}
|
|
}
|