1; RUN: llc < %s | FileCheck %s --check-prefixes CHECK,ATTRS
2; RUN: llc < %s -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
3; RUN: llc < %s -mcpu=bleeding-edge | FileCheck %s --check-prefixes CHECK,BLEEDING-EDGE
4
5; Test that codegen emits target features from the command line or
6; function attributes correctly and that features are enabled for the
7; entire module if they are enabled for any function in the module.
8
9target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
10target triple = "wasm32-unknown-unknown"
11
12define void @fn_atomics(i32* %p1, float %f2) #0 {
13  %a = atomicrmw min i32* undef, i32 42 seq_cst
14  %v = fptoui float %f2 to i32
15  store i32 %v, i32* %p1
16  ret void
17}
18
19define void @fn_nontrapping_fptoint(i32* %p1, float %f2) #1 {
20  %a = atomicrmw min i32* undef, i32 42 seq_cst
21  %v = fptoui float %f2 to i32
22  store i32 %v, i32* %p1
23  ret void
24}
25
26define void @fn_reference_types() #2 {
27  ret void
28}
29
30attributes #0 = { "target-features"="+atomics" }
31attributes #1 = { "target-features"="+nontrapping-fptoint" }
32attributes #2 = { "target-features"="+reference-types" }
33
34; CHECK-LABEL: fn_atomics:
35
36; Expanded atomicrmw min
37; ATTRS:       loop
38; CHECK:       i32.atomic.rmw.cmpxchg
39; ATTRS:       end_loop
40
41; nontrapping fptoint
42; CHECK:       i32.trunc_sat_f32_u
43; ATTRS:       i32.store
44
45; `fn_nontrapping_fptoint` should be the same as `fn_atomics`
46; CHECK-LABEL: fn_nontrapping_fptoint:
47
48; Expanded atomicrmw min
49; ATTRS:       loop
50; CHECK:       i32.atomic.rmw.cmpxchg
51; ATTRS:       end_loop
52
53; nontrapping fptoint
54; CHECK:       i32.trunc_sat_f32_u
55; ATTRS:       i32.store
56
57; CHECK-LABEL: .custom_section.target_features,"",@
58
59; +atomics, +nontrapping-fptoint, +reference-types
60; ATTRS-NEXT: .int8 3
61; ATTRS-NEXT: .int8 43
62; ATTRS-NEXT: .int8 7
63; ATTRS-NEXT: .ascii "atomics"
64; ATTRS-NEXT: .int8 43
65; ATTRS-NEXT: .int8 19
66; ATTRS-NEXT: .ascii "nontrapping-fptoint"
67; ATTRS-NEXT: .int8 43
68; ATTRS-NEXT: .int8 15
69; ATTRS-NEXT: .ascii "reference-types"
70
71; +atomics, +nontrapping-fptoint, +reference-types, +simd128
72; SIMD128-NEXT: .int8 4
73; SIMD128-NEXT: .int8 43
74; SIMD128-NEXT: .int8 7
75; SIMD128-NEXT: .ascii "atomics"
76; SIMD128-NEXT: .int8 43
77; SIMD128-NEXT: .int8 19
78; SIMD128-NEXT: .ascii "nontrapping-fptoint"
79; SIMD128-NEXT: .int8 43
80; SIMD128-NEXT: .int8 15
81; SIMD128-NEXT: .ascii "reference-types"
82; SIMD128-NEXT: .int8 43
83; SIMD128-NEXT: .int8 7
84; SIMD128-NEXT: .ascii "simd128"
85
86; +atomics, +bulk-memory, +mutable-globals, +nontrapping-fptoint,
87; +reference-types, +sign-ext, +simd128, +tail-call
88; BLEEDING-EDGE-NEXT: .int8   8
89; BLEEDING-EDGE-NEXT: .int8   43
90; BLEEDING-EDGE-NEXT: .int8   7
91; BLEEDING-EDGE-NEXT: .ascii  "atomics"
92; BLEEDING-EDGE-NEXT: .int8   43
93; BLEEDING-EDGE-NEXT: .int8   11
94; BLEEDING-EDGE-NEXT: .ascii  "bulk-memory"
95; BLEEDING-EDGE-NEXT: .int8   43
96; BLEEDING-EDGE-NEXT: .int8   15
97; BLEEDING-EDGE-NEXT: .ascii  "mutable-globals"
98; BLEEDING-EDGE-NEXT: .int8   43
99; BLEEDING-EDGE-NEXT: .int8   19
100; BLEEDING-EDGE-NEXT: .ascii  "nontrapping-fptoint"
101; BLEEDING-EDGE-NEXT: .int8   43
102; BLEEDING-EDGE-NEXT: .int8   15
103; BLEEDING-EDGE-NEXT: .ascii  "reference-types"
104; BLEEDING-EDGE-NEXT: .int8   43
105; BLEEDING-EDGE-NEXT: .int8   8
106; BLEEDING-EDGE-NEXT: .ascii  "sign-ext"
107; BLEEDING-EDGE-NEXT: .int8   43
108; BLEEDING-EDGE-NEXT: .int8   7
109; BLEEDING-EDGE-NEXT: .ascii  "simd128"
110; BLEEDING-EDGE-NEXT: .int8   43
111; BLEEDING-EDGE-NEXT: .int8   9
112; BLEEDING-EDGE-NEXT: .ascii  "tail-call"
113
114; CHECK-NEXT: .text
115