1; RUN: llc < %s -mtriple=thumbv7-apple-ios7.0 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-OLD
2; RUN: llc < %s -mtriple=thumbv7s-apple-ios7.0 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-F16
3; RUN: llc < %s -mtriple=thumbv8-apple-ios7.0 | FileCheck %s --check-prefix=CHECK  --check-prefix=CHECK-V8
4; RUN: llc < %s -mtriple=armv8r-none-none-eabi | FileCheck %s --check-prefix=CHECK  --check-prefix=CHECK-V8
5; RUN: llc < %s -mtriple=armv8r-none-none-eabi -mattr=+fp-only-sp | FileCheck %s --check-prefix=CHECK  --check-prefix=CHECK-V8-SP
6
7define void @test_load_store(half* %in, half* %out) {
8; CHECK-LABEL: test_load_store:
9; CHECK: ldrh [[TMP:r[0-9]+]], [r0]
10; CHECK: strh [[TMP]], [r1]
11  %val = load half, half* %in
12  store half %val, half* %out
13  ret void
14}
15
16define i16 @test_bitcast_from_half(half* %addr) {
17; CHECK-LABEL: test_bitcast_from_half:
18; CHECK: ldrh r0, [r0]
19  %val = load half, half* %addr
20  %val_int = bitcast half %val to i16
21  ret i16 %val_int
22}
23
24define void @test_bitcast_to_half(half* %addr, i16 %in) {
25; CHECK-LABEL: test_bitcast_to_half:
26; CHECK: strh r1, [r0]
27  %val_fp = bitcast i16 %in to half
28  store half %val_fp, half* %addr
29  ret void
30}
31
32define float @test_extend32(half* %addr) {
33; CHECK-LABEL: test_extend32:
34
35; CHECK-OLD: b.w ___extendhfsf2
36; CHECK-F16: vcvtb.f32.f16
37; CHECK-V8: vcvtb.f32.f16
38; CHECK-V8-SP: vcvtb.f32.f16
39  %val16 = load half, half* %addr
40  %val32 = fpext half %val16 to float
41  ret float %val32
42}
43
44define double @test_extend64(half* %addr) {
45; CHECK-LABEL: test_extend64:
46
47; CHECK-OLD: bl ___extendhfsf2
48; CHECK-OLD: vcvt.f64.f32
49; CHECK-F16: vcvtb.f32.f16
50; CHECK-F16: vcvt.f64.f32
51; CHECK-V8: vcvtb.f64.f16
52; CHECK-V8-SP: vcvtb.f32.f16
53; CHECK-V8-SP: bl __aeabi_f2d
54  %val16 = load half, half* %addr
55  %val32 = fpext half %val16 to double
56  ret double %val32
57}
58
59define void @test_trunc32(float %in, half* %addr) {
60; CHECK-LABEL: test_trunc32:
61
62; CHECK-OLD: bl ___truncsfhf2
63; CHECK-F16: vcvtb.f16.f32
64; CHECK-V8: vcvtb.f16.f32
65; CHECK-V8-SP: vcvtb.f16.f32
66  %val16 = fptrunc float %in to half
67  store half %val16, half* %addr
68  ret void
69}
70
71define void @test_trunc64(double %in, half* %addr) {
72; CHECK-LABEL: test_trunc64:
73
74; CHECK-OLD: bl ___truncdfhf2
75; CHECK-F16: bl ___truncdfhf2
76; CHECK-V8: vcvtb.f16.f64
77; CHECK-V8-SP: bl __aeabi_d2h
78  %val16 = fptrunc double %in to half
79  store half %val16, half* %addr
80  ret void
81}
82