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 @foo(i32* %p1) #0 {
13  %a = atomicrmw min i32* undef, i32 42 seq_cst
14  %v = fptoui float undef to i32
15  store i32 %v, i32* %p1
16  ret void
17}
18
19define void @bar(i32* %p1) #1 {
20  %a = atomicrmw min i32* undef, i32 42 seq_cst
21  %v = fptoui float undef to i32
22  store i32 %v, i32* %p1
23  ret void
24}
25
26attributes #0 = { "target-features"="+atomics" }
27attributes #1 = { "target-features"="+nontrapping-fptoint" }
28
29
30; CHECK-LABEL: foo:
31
32; Expanded atomicrmw min
33; ATTRS:       loop
34; ATTRS:       i32.atomic.rmw.cmpxchg
35; SIMD128-NOT: i32.atomic.rmw.cmpxchg
36; ATTRS:       end_loop
37
38; nontrapping fptoint
39; ATTRS:       i32.trunc_sat_f32_u
40; SIMD128-NOT: i32.trunc_sat_f32_u
41; ATTRS:       i32.store
42
43; `bar` should be the same as `foo`
44; CHECK-LABEL: bar:
45
46; Expanded atomicrmw min
47; ATTRS:       loop
48; ATTRS:       i32.atomic.rmw.cmpxchg
49; SIMD128-NOT: i32.atomic.rmw.cmpxchg
50; ATTRS:       end_loop
51
52; nontrapping fptoint
53; ATTRS:       i32.trunc_sat_f32_u
54; SIMD128-NOT: i32.trunc_sat_f32_u
55; ATTRS:       i32.store
56
57; CHECK-LABEL: .custom_section.target_features,"",@
58
59; +atomics, +nontrapping-fptoint
60; ATTRS-NEXT: .int8 2
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
68; -atomics, +simd128
69; SIMD128-NEXT: .int8 2
70; SIMD128-NEXT: .int8 45
71; SIMD128-NEXT: .int8 7
72; SIMD128-NEXT: .ascii "atomics"
73; SIMD128-NEXT: .int8 43
74; SIMD128-NEXT: .int8 7
75; SIMD128-NEXT: .ascii "simd128"
76
77; +atomics, +nontrapping-fptoint, +sign-ext, +simd128
78; BLEEDING-EDGE-NEXT: .int8   5
79; BLEEDING-EDGE-NEXT: .int8   43
80; BLEEDING-EDGE-NEXT: .int8   7
81; BLEEDING-EDGE-NEXT: .ascii  "atomics"
82; BLEEDING-EDGE-NEXT: .int8   43
83; BLEEDING-EDGE-NEXT: .int8   15
84; BLEEDING-EDGE-NEXT: .ascii  "mutable-globals"
85; BLEEDING-EDGE-NEXT: .int8   43
86; BLEEDING-EDGE-NEXT: .int8   19
87; BLEEDING-EDGE-NEXT: .ascii  "nontrapping-fptoint"
88; BLEEDING-EDGE-NEXT: .int8   43
89; BLEEDING-EDGE-NEXT: .int8   8
90; BLEEDING-EDGE-NEXT: .ascii  "sign-ext"
91; BLEEDING-EDGE-NEXT: .int8   43
92; BLEEDING-EDGE-NEXT: .int8   7
93; BLEEDING-EDGE-NEXT: .ascii  "simd128"
94
95; CHECK-NEXT: .text
96