File: target-features-attrs.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (84 lines) | stat: -rw-r--r-- 2,444 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
; RUN: llc -mcpu=mvp < %s | FileCheck %s
; RUN: llc -mcpu=mvp -mattr=+simd128 < %s | FileCheck %s --check-prefixes SIMD128

; Test that codegen emits target features from the command line or
; function attributes correctly and that features are enabled for the
; entire module if they are enabled for any function in the module.

target triple = "wasm32-unknown-unknown"

define void @fn_atomics(ptr %p1, float %f2) #0 {
  %a = atomicrmw min ptr undef, i32 42 seq_cst
  %v = fptoui float %f2 to i32
  store i32 %v, ptr %p1
  ret void
}

define void @fn_nontrapping_fptoint(ptr %p1, float %f2) #1 {
  %a = atomicrmw min ptr undef, i32 42 seq_cst
  %v = fptoui float %f2 to i32
  store i32 %v, ptr %p1
  ret void
}

define void @fn_reference_types() #2 {
  ret void
}

attributes #0 = { "target-features"="+atomics" }
attributes #1 = { "target-features"="+nontrapping-fptoint" }
attributes #2 = { "target-features"="+reference-types" }

; CHECK-LABEL: fn_atomics:

; Expanded atomicrmw min
; CHECK:       loop
; CHECK:       i32.atomic.rmw.cmpxchg
; CHECK:       end_loop

; nontrapping fptoint
; CHECK:       i32.trunc_sat_f32_u
; CHECK:       i32.store

; `fn_nontrapping_fptoint` should be the same as `fn_atomics`
; CHECK-LABEL: fn_nontrapping_fptoint:

; Expanded atomicrmw min
; CHECK:       loop
; CHECK:       i32.atomic.rmw.cmpxchg
; CHECK:       end_loop

; nontrapping fptoint
; CHECK:       i32.trunc_sat_f32_u
; CHECK:       i32.store

; Features in function attributes:
; +atomics, +nontrapping-fptoint, +reference-types
; CHECK-LABEL: .custom_section.target_features,"",@
; CHECK-NEXT: .int8  3
; CHECK-NEXT: .int8  43
; CHECK-NEXT: .int8  7
; CHECK-NEXT: .ascii  "atomics"
; CHECK-NEXT: .int8  43
; CHECK-NEXT: .int8  19
; CHECK-NEXT: .ascii  "nontrapping-fptoint"
; CHECK-NEXT: .int8  43
; CHECK-NEXT: .int8  15
; CHECK-NEXT: .ascii  "reference-types"

; Features in function attributes + features specified by -mattr= option:
; +atomics, +nontrapping-fptoint, +reference-types, +simd128
; SIMD128-LABEL: .custom_section.target_features,"",@
; SIMD128-NEXT: .int8  4
; SIMD128-NEXT: .int8  43
; SIMD128-NEXT: .int8  7
; SIMD128-NEXT: .ascii  "atomics"
; SIMD128-NEXT: .int8  43
; SIMD128-NEXT: .int8  19
; SIMD128-NEXT: .ascii  "nontrapping-fptoint"
; SIMD128-NEXT: .int8  43
; SIMD128-NEXT: .int8  15
; SIMD128-NEXT: .ascii  "reference-types"
; SIMD128-NEXT: .int8  43
; SIMD128-NEXT: .int8  7
; SIMD128-NEXT: .ascii  "simd128"