xref: /llvm-project/mlir/test/Target/LLVMIR/fp-math-function-attributes.mlir (revision e5865ec93cbf77f84c55e55383ce3254186fc065)
1// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
2
3// CHECK-LABEL: define void @unsafe_fp_math_func_true()
4// CHECK-SAME: #[[ATTRS:[0-9]+]]
5llvm.func @unsafe_fp_math_func_true() attributes {unsafe_fp_math = true}  {
6  llvm.return
7}
8// CHECK: attributes #[[ATTRS]] = { "unsafe-fp-math"="true" }
9
10// -----
11
12// CHECK-LABEL: define void @unsafe_fp_math_func_false()
13// CHECK-SAME: #[[ATTRS:[0-9]+]]
14llvm.func @unsafe_fp_math_func_false() attributes {unsafe_fp_math = false}  {
15  llvm.return
16}
17// CHECK: attributes #[[ATTRS]] = { "unsafe-fp-math"="false" }
18
19// -----
20
21// CHECK-LABEL: define void @no_infs_fp_math_func_true()
22// CHECK-SAME: #[[ATTRS:[0-9]+]]
23llvm.func @no_infs_fp_math_func_true() attributes {no_infs_fp_math = true}  {
24  llvm.return
25}
26// CHECK: attributes #[[ATTRS]] = { "no-infs-fp-math"="true" }
27
28// -----
29
30// CHECK-LABEL: define void @no_infs_fp_math_func_false()
31// CHECK-SAME: #[[ATTRS:[0-9]+]]
32llvm.func @no_infs_fp_math_func_false() attributes {no_infs_fp_math = false}  {
33  llvm.return
34}
35// CHECK: attributes #[[ATTRS]] = { "no-infs-fp-math"="false" }
36
37// -----
38
39// CHECK-LABEL: define void @no_nans_fp_math_func_true()
40// CHECK-SAME: #[[ATTRS:[0-9]+]]
41llvm.func @no_nans_fp_math_func_true() attributes {no_nans_fp_math = true}  {
42  llvm.return
43}
44// CHECK: attributes #[[ATTRS]] = { "no-nans-fp-math"="true" }
45
46// -----
47
48// CHECK-LABEL: define void @no_nans_fp_math_func_false()
49// CHECK-SAME: #[[ATTRS:[0-9]+]]
50llvm.func @no_nans_fp_math_func_false() attributes {no_nans_fp_math = false}  {
51  llvm.return
52}
53// CHECK: attributes #[[ATTRS]] = { "no-nans-fp-math"="false" }
54
55// -----
56
57// CHECK-LABEL: define void @approx_func_fp_math_func_true()
58// CHECK-SAME: #[[ATTRS:[0-9]+]]
59llvm.func @approx_func_fp_math_func_true() attributes {approx_func_fp_math = true}  {
60  llvm.return
61}
62// CHECK: attributes #[[ATTRS]] = { "approx-func-fp-math"="true" }
63
64// -----
65//
66// CHECK-LABEL: define void @approx_func_fp_math_func_false()
67// CHECK-SAME: #[[ATTRS:[0-9]+]]
68llvm.func @approx_func_fp_math_func_false() attributes {approx_func_fp_math = false}  {
69  llvm.return
70}
71// CHECK: attributes #[[ATTRS]] = { "approx-func-fp-math"="false" }
72
73// -----
74
75// CHECK-LABEL: define void @no_signed_zeros_fp_math_func_true()
76// CHECK-SAME: #[[ATTRS:[0-9]+]]
77llvm.func @no_signed_zeros_fp_math_func_true() attributes {no_signed_zeros_fp_math = true}  {
78  llvm.return
79}
80// CHECK: attributes #[[ATTRS]] = { "no-signed-zeros-fp-math"="true" }
81
82// -----
83
84// CHECK-LABEL: define void @no_signed_zeros_fp_math_func_false()
85// CHECK-SAME: #[[ATTRS:[0-9]+]]
86llvm.func @no_signed_zeros_fp_math_func_false() attributes {no_signed_zeros_fp_math = false}  {
87  llvm.return
88}
89// CHECK: attributes #[[ATTRS]] = { "no-signed-zeros-fp-math"="false" }
90
91// -----
92
93// CHECK-LABEL: define void @denormal_fp_math_func_ieee()
94// CHECK-SAME: #[[ATTRS:[0-9]+]]
95llvm.func @denormal_fp_math_func_ieee() attributes {denormal_fp_math = "ieee"}  {
96  llvm.return
97}
98// CHECK: attributes #[[ATTRS]] = { "denormal-fp-math"="ieee" }
99
100// -----
101
102// CHECK-LABEL: define void @denormal_fp_math_f32_func_preserve_sign()
103// CHECK-SAME: #[[ATTRS:[0-9]+]]
104llvm.func @denormal_fp_math_f32_func_preserve_sign() attributes {denormal_fp_math_f32 = "preserve-sign"}  {
105  llvm.return
106}
107// CHECK: attributes #[[ATTRS]] = { "denormal-fp-math-f32"="preserve-sign" }
108
109// -----
110
111// CHECK-LABEL: define void @fp_contract_func_fast()
112// CHECK-SAME: #[[ATTRS:[0-9]+]]
113llvm.func @fp_contract_func_fast() attributes {fp_contract = "fast"}  {
114  llvm.return
115}
116// CHECK: attributes #[[ATTRS]] = { "fp-contract"="fast" }
117