xref: /llvm-project/llvm/test/CodeGen/WebAssembly/target-features-attrs.ll (revision c3536b263f253a69fb336fb0617ee33a01a5c5dd)
1; RUN: llc -mcpu=mvp < %s | FileCheck %s
2; RUN: llc -mcpu=mvp -mattr=+simd128 < %s | FileCheck %s --check-prefixes SIMD128
3
4; Test that codegen emits target features from the command line or
5; function attributes correctly and that features are enabled for the
6; entire module if they are enabled for any function in the module.
7
8target triple = "wasm32-unknown-unknown"
9
10define void @fn_atomics(ptr %p1, float %f2) #0 {
11  %a = atomicrmw min ptr undef, i32 42 seq_cst
12  %v = fptoui float %f2 to i32
13  store i32 %v, ptr %p1
14  ret void
15}
16
17define void @fn_nontrapping_fptoint(ptr %p1, float %f2) #1 {
18  %a = atomicrmw min ptr undef, i32 42 seq_cst
19  %v = fptoui float %f2 to i32
20  store i32 %v, ptr %p1
21  ret void
22}
23
24define void @fn_reference_types() #2 {
25  ret void
26}
27
28attributes #0 = { "target-features"="+atomics" }
29attributes #1 = { "target-features"="+nontrapping-fptoint" }
30attributes #2 = { "target-features"="+reference-types" }
31
32; CHECK-LABEL: fn_atomics:
33
34; Expanded atomicrmw min
35; CHECK:       loop
36; CHECK:       i32.atomic.rmw.cmpxchg
37; CHECK:       end_loop
38
39; nontrapping fptoint
40; CHECK:       i32.trunc_sat_f32_u
41; CHECK:       i32.store
42
43; `fn_nontrapping_fptoint` should be the same as `fn_atomics`
44; CHECK-LABEL: fn_nontrapping_fptoint:
45
46; Expanded atomicrmw min
47; CHECK:       loop
48; CHECK:       i32.atomic.rmw.cmpxchg
49; CHECK:       end_loop
50
51; nontrapping fptoint
52; CHECK:       i32.trunc_sat_f32_u
53; CHECK:       i32.store
54
55; Features in function attributes:
56; +atomics, +nontrapping-fptoint, +reference-types
57; CHECK-LABEL: .custom_section.target_features,"",@
58; CHECK-NEXT: .int8  4
59; CHECK-NEXT: .int8  43
60; CHECK-NEXT: .int8  7
61; CHECK-NEXT: .ascii  "atomics"
62; CHECK-NEXT: .int8  43
63; CHECK-NEXT: .int8  22
64; CHECK-NEXT: .ascii  "call-indirect-overlong"
65; CHECK-NEXT: .int8  43
66; CHECK-NEXT: .int8  19
67; CHECK-NEXT: .ascii  "nontrapping-fptoint"
68; CHECK-NEXT: .int8  43
69; CHECK-NEXT: .int8  15
70; CHECK-NEXT: .ascii  "reference-types"
71
72; Features in function attributes + features specified by -mattr= option:
73; +atomics, +nontrapping-fptoint, +reference-types, +simd128
74; SIMD128-LABEL: .custom_section.target_features,"",@
75; SIMD128-NEXT: .int8  5
76; SIMD128-NEXT: .int8  43
77; SIMD128-NEXT: .int8  7
78; SIMD128-NEXT: .ascii  "atomics"
79; SIMD128-NEXT: .int8  43
80; SIMD128-NEXT: .int8  22
81; SIMD128-NEXT: .ascii  "call-indirect-overlong"
82; SIMD128-NEXT: .int8  43
83; SIMD128-NEXT: .int8  19
84; SIMD128-NEXT: .ascii  "nontrapping-fptoint"
85; SIMD128-NEXT: .int8  43
86; SIMD128-NEXT: .int8  15
87; SIMD128-NEXT: .ascii  "reference-types"
88; SIMD128-NEXT: .int8  43
89; SIMD128-NEXT: .int8  7
90; SIMD128-NEXT: .ascii  "simd128"
91