blob: 7ce7fcf0b7c0d6e1b672813ccfd9bc6cab81e5fc [file] [log] [blame]
Thomas Livelyf6f4f842019-03-20 20:26:45 +00001; RUN: llc < %s | FileCheck %s --check-prefixes CHECK,ATTRS
2; RUN: llc < %s -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
Thomas Livelyf6f4f842019-03-20 20:26:45 +00003; 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
Thomas Lively3f34e1b82019-03-29 00:14:01 +00006; function attributes correctly and that features are enabled for the
7; entire module if they are enabled for any function in the module.
Thomas Livelyf6f4f842019-03-20 20:26:45 +00008
9target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
10target triple = "wasm32-unknown-unknown"
11
Thomas Lively3f34e1b82019-03-29 00:14:01 +000012define 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
Thomas Livelyf6f4f842019-03-20 20:26:45 +000016 ret void
17}
18
Thomas Lively3f34e1b82019-03-29 00:14:01 +000019define 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
Thomas Livelyf6f4f842019-03-20 20:26:45 +000023 ret void
24}
25
Thomas Lively3f34e1b82019-03-29 00:14:01 +000026attributes #0 = { "target-features"="+atomics" }
Thomas Livelyf6f4f842019-03-20 20:26:45 +000027attributes #1 = { "target-features"="+nontrapping-fptoint" }
28
Thomas Lively3f34e1b82019-03-29 00:14:01 +000029
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
Thomas Livelyf6f4f842019-03-20 20:26:45 +000057; CHECK-LABEL: .custom_section.target_features,"",@
58
Thomas Lively3f34e1b82019-03-29 00:14:01 +000059; +atomics, +nontrapping-fptoint
60; ATTRS-NEXT: .int8 2
61; ATTRS-NEXT: .int8 43
Thomas Livelyf6f4f842019-03-20 20:26:45 +000062; 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"
Thomas Livelyf6f4f842019-03-20 20:26:45 +000067
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
Thomas Lively3f34e1b82019-03-29 00:14:01 +000077; +atomics, +nontrapping-fptoint, +sign-ext, +simd128
Thomas Livelyf6f4f842019-03-20 20:26:45 +000078; BLEEDING-EDGE-NEXT: .int8 4
Thomas Lively3f34e1b82019-03-29 00:14:01 +000079; BLEEDING-EDGE-NEXT: .int8 43
Thomas Livelyf6f4f842019-03-20 20:26:45 +000080; BLEEDING-EDGE-NEXT: .int8 7
81; BLEEDING-EDGE-NEXT: .ascii "atomics"
82; BLEEDING-EDGE-NEXT: .int8 43
83; BLEEDING-EDGE-NEXT: .int8 19
84; BLEEDING-EDGE-NEXT: .ascii "nontrapping-fptoint"
85; BLEEDING-EDGE-NEXT: .int8 43
86; BLEEDING-EDGE-NEXT: .int8 8
87; BLEEDING-EDGE-NEXT: .ascii "sign-ext"
88; BLEEDING-EDGE-NEXT: .int8 43
89; BLEEDING-EDGE-NEXT: .int8 7
90; BLEEDING-EDGE-NEXT: .ascii "simd128"
91
92; CHECK-NEXT: .text