brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 712fd17 Raw
138 lines · plain
1// RUN: mlir-translate --no-implicit-module --split-input-file --test-spirv-roundtrip %s | FileCheck %s2 3// RUN: %if spirv-tools %{ rm -rf %t %}4// RUN: %if spirv-tools %{ mkdir %t %}5// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}6// RUN: %if spirv-tools %{ spirv-val %t %}7 8spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {9  // CHECK: location = 0 : i3210  spirv.GlobalVariable @var {location = 0 : i32} : !spirv.ptr<vector<4xf32>, Input>11}12 13// -----14 15spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {16  // CHECK: no_perspective17  spirv.GlobalVariable @var {no_perspective} : !spirv.ptr<vector<4xf32>, Input>18}19 20// -----21 22spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {23  // CHECK: flat24  spirv.GlobalVariable @var {flat} : !spirv.ptr<si32, Input>25}26 27// -----28 29spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], [SPV_KHR_variable_pointers]> {30  // CHECK: aliased31  // CHECK: aliased32  spirv.GlobalVariable @var1 bind(0, 0) {aliased} : !spirv.ptr<!spirv.struct<(!spirv.array<4xf32, stride=4>[0])>, StorageBuffer>33  spirv.GlobalVariable @var2 bind(0, 0) {aliased} : !spirv.ptr<!spirv.struct<(vector<4xf32>[0])>, StorageBuffer>34}35 36// -----37 38spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], [SPV_KHR_variable_pointers]> {39  // CHECK: non_readable40  spirv.GlobalVariable @var bind(0, 0) {non_readable} : !spirv.ptr<!spirv.struct<(!spirv.array<4xf32, stride=4>[0])>, StorageBuffer>41}42 43// -----44 45spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], [SPV_KHR_variable_pointers]> {46  // CHECK: non_writable47  spirv.GlobalVariable @var bind(0, 0) {non_writable} : !spirv.ptr<!spirv.struct<(!spirv.array<4xf32, stride=4>[0])>, StorageBuffer>48}49 50// -----51 52spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], [SPV_KHR_variable_pointers]> {53  // CHECK: restrict54  spirv.GlobalVariable @var bind(0, 0) {restrict} : !spirv.ptr<!spirv.struct<(!spirv.array<4xf32, stride=4>[0])>, StorageBuffer>55}56 57// -----58 59spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {60  // CHECK: relaxed_precision61  spirv.GlobalVariable @var {location = 0 : i32, relaxed_precision} : !spirv.ptr<vector<4xf32>, Output>62}63 64// -----65 66spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Tessellation, Linkage], []> {67  // CHECK: patch68  spirv.GlobalVariable @var {patch} : !spirv.ptr<vector<4xf32>, Input>69}70 71// -----72 73spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {74  // CHECK: invariant75  spirv.GlobalVariable @var {invariant} : !spirv.ptr<vector<2xf32>, Output>76}77 78// -----79 80spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {81  // CHECK: linkage_attributes = #spirv.linkage_attributes<linkage_name = "outSideGlobalVar1", linkage_type = <Import>>82  spirv.GlobalVariable @var1 {83    linkage_attributes=#spirv.linkage_attributes<84      linkage_name="outSideGlobalVar1", 85      linkage_type=<Import>86    >87  } : !spirv.ptr<f32, Private>88}89 90// -----91 92spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel, Linkage], [SPV_KHR_no_integer_wrap_decoration]> {93spirv.func @iadd_decorations(%arg: i32) -> i32 "None" {94  // CHECK: spirv.IAdd %{{.*}}, %{{.*}} {no_signed_wrap, no_unsigned_wrap}95  %0 = spirv.IAdd %arg, %arg {no_signed_wrap, no_unsigned_wrap} : i3296  spirv.ReturnValue %0 : i3297}98}99 100// -----101 102spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel, Linkage], []> {103spirv.func @fadd_decorations(%arg: f32) -> f32 "None" {104  // CHECK: spirv.FAdd %{{.*}}, %{{.*}} {fp_fast_math_mode = #spirv.fastmath_mode<NotNaN|NotInf|NSZ>}105  %0 = spirv.FAdd %arg, %arg {fp_fast_math_mode = #spirv.fastmath_mode<NotNaN|NotInf|NSZ>} : f32106  spirv.ReturnValue %0 : f32107}108}109 110// -----111 112spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {113spirv.func @fmul_decorations(%arg: f32) -> f32 "None" {114  // CHECK: spirv.FMul %{{.*}}, %{{.*}} {no_contraction}115  %0 = spirv.FMul %arg, %arg {no_contraction} : f32116  spirv.ReturnValue %0 : f32117}118}119 120// -----121 122spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel, Linkage, Float16], []> {123spirv.func @fp_rounding_mode(%arg: f32) -> f16 "None" {124  // CHECK: spirv.FConvert %arg0 {fp_rounding_mode = #spirv.fp_rounding_mode<RTN>} : f32 to f16125  %0 = spirv.FConvert %arg {fp_rounding_mode = #spirv.fp_rounding_mode<RTN>} : f32 to f16126  spirv.ReturnValue %0 : f16127}128}129 130// -----131 132spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, Linkage], []> {133  // CHECK: spirv.func @relaxed_precision_arg({{%.*}}: !spirv.ptr<f32, Function> {spirv.decoration = #spirv.decoration<RelaxedPrecision>}) "None" attributes {relaxed_precision} {134  spirv.func @relaxed_precision_arg(%arg0: !spirv.ptr<f32, Function> {spirv.decoration = #spirv.decoration<RelaxedPrecision>}) -> () "None" attributes {relaxed_precision} {135    spirv.Return136  }137}138