Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s | FileCheck %s --check-prefixes CHECK,ATTRS |
| 2 | ; RUN: llc < %s -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128 |
Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 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 |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 6 | ; function attributes correctly and that features are enabled for the |
| 7 | ; entire module if they are enabled for any function in the module. |
Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 8 | |
| 9 | target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" |
| 10 | target triple = "wasm32-unknown-unknown" |
| 11 | |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 12 | define 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 Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 16 | ret void |
| 17 | } |
| 18 | |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 19 | define 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 Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 23 | ret void |
| 24 | } |
| 25 | |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 26 | attributes #0 = { "target-features"="+atomics" } |
Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 27 | attributes #1 = { "target-features"="+nontrapping-fptoint" } |
| 28 | |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 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 | |
Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 57 | ; CHECK-LABEL: .custom_section.target_features,"",@ |
| 58 | |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 59 | ; +atomics, +nontrapping-fptoint |
| 60 | ; ATTRS-NEXT: .int8 2 |
| 61 | ; ATTRS-NEXT: .int8 43 |
Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 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" |
Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 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 | |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 77 | ; +atomics, +nontrapping-fptoint, +sign-ext, +simd128 |
Thomas Lively | 9e27514 | 2019-04-12 20:39:53 +0000 | [diff] [blame] | 78 | ; BLEEDING-EDGE-NEXT: .int8 5 |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 79 | ; BLEEDING-EDGE-NEXT: .int8 43 |
Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 80 | ; BLEEDING-EDGE-NEXT: .int8 7 |
| 81 | ; BLEEDING-EDGE-NEXT: .ascii "atomics" |
| 82 | ; BLEEDING-EDGE-NEXT: .int8 43 |
Thomas Lively | 9e27514 | 2019-04-12 20:39:53 +0000 | [diff] [blame] | 83 | ; BLEEDING-EDGE-NEXT: .int8 15 |
| 84 | ; BLEEDING-EDGE-NEXT: .ascii "mutable-globals" |
| 85 | ; BLEEDING-EDGE-NEXT: .int8 43 |
Thomas Lively | f6f4f84 | 2019-03-20 20:26:45 +0000 | [diff] [blame] | 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 |