cast-ops.mlir
2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// RUN: mlir-translate -test-spirv-roundtrip -split-input-file %s | FileCheck %s
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
spv.func @bit_cast(%arg0 : f32) "None" {
// CHECK: {{%.*}} = spv.Bitcast {{%.*}} : f32 to i32
%0 = spv.Bitcast %arg0 : f32 to i32
// CHECK: {{%.*}} = spv.Bitcast {{%.*}} : i32 to si32
%1 = spv.Bitcast %0 : i32 to si32
// CHECK: {{%.*}} = spv.Bitcast {{%.*}} : si32 to i32
%2 = spv.Bitcast %1 : si32 to ui32
spv.Return
}
}
// -----
spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
spv.func @convert_f_to_s(%arg0 : f32) -> i32 "None" {
// CHECK: {{%.*}} = spv.ConvertFToS {{%.*}} : f32 to i32
%0 = spv.ConvertFToS %arg0 : f32 to i32
spv.ReturnValue %0 : i32
}
spv.func @convert_f64_to_s32(%arg0 : f64) -> i32 "None" {
// CHECK: {{%.*}} = spv.ConvertFToS {{%.*}} : f64 to i32
%0 = spv.ConvertFToS %arg0 : f64 to i32
spv.ReturnValue %0 : i32
}
spv.func @convert_f_to_u(%arg0 : f32) -> i32 "None" {
// CHECK: {{%.*}} = spv.ConvertFToU {{%.*}} : f32 to i32
%0 = spv.ConvertFToU %arg0 : f32 to i32
spv.ReturnValue %0 : i32
}
spv.func @convert_f64_to_u32(%arg0 : f64) -> i32 "None" {
// CHECK: {{%.*}} = spv.ConvertFToU {{%.*}} : f64 to i32
%0 = spv.ConvertFToU %arg0 : f64 to i32
spv.ReturnValue %0 : i32
}
spv.func @convert_s_to_f(%arg0 : i32) -> f32 "None" {
// CHECK: {{%.*}} = spv.ConvertSToF {{%.*}} : i32 to f32
%0 = spv.ConvertSToF %arg0 : i32 to f32
spv.ReturnValue %0 : f32
}
spv.func @convert_s64_to_f32(%arg0 : i64) -> f32 "None" {
// CHECK: {{%.*}} = spv.ConvertSToF {{%.*}} : i64 to f32
%0 = spv.ConvertSToF %arg0 : i64 to f32
spv.ReturnValue %0 : f32
}
spv.func @convert_u_to_f(%arg0 : i32) -> f32 "None" {
// CHECK: {{%.*}} = spv.ConvertUToF {{%.*}} : i32 to f32
%0 = spv.ConvertUToF %arg0 : i32 to f32
spv.ReturnValue %0 : f32
}
spv.func @convert_u64_to_f32(%arg0 : i64) -> f32 "None" {
// CHECK: {{%.*}} = spv.ConvertUToF {{%.*}} : i64 to f32
%0 = spv.ConvertUToF %arg0 : i64 to f32
spv.ReturnValue %0 : f32
}
spv.func @f_convert(%arg0 : f32) -> f64 "None" {
// CHECK: {{%.*}} = spv.FConvert {{%.*}} : f32 to f64
%0 = spv.FConvert %arg0 : f32 to f64
spv.ReturnValue %0 : f64
}
spv.func @s_convert(%arg0 : i32) -> i64 "None" {
// CHECK: {{%.*}} = spv.SConvert {{%.*}} : i32 to i64
%0 = spv.SConvert %arg0 : i32 to i64
spv.ReturnValue %0 : i64
}
spv.func @u_convert(%arg0 : i32) -> i64 "None" {
// CHECK: {{%.*}} = spv.UConvert {{%.*}} : i32 to i64
%0 = spv.UConvert %arg0 : i32 to i64
spv.ReturnValue %0 : i64
}
}