1; RUN: llc -verify-machineinstrs < %s -mtriple=arm64-apple-ios7.0 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-LE %s
2; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64_be-none-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=CHECK-BE %s
3
4define i128 @test_simple(i128 %a, i128 %b, i128 %c) {
5; CHECK-LABEL: test_simple:
6
7  %valadd = add i128 %a, %b
8; CHECK-LE: adds [[ADDLO:x[0-9]+]], x0, x2
9; CHECK-LE-NEXT: adcs [[ADDHI:x[0-9]+]], x1, x3
10; CHECK-BE: adds [[ADDLO:x[0-9]+]], x1, x3
11; CHECK-BE-NEXT: adcs [[ADDHI:x[0-9]+]], x0, x2
12
13  %valsub = sub i128 %valadd, %c
14; CHECK-LE: subs x0, [[ADDLO]], x4
15; CHECK-LE: sbcs x1, [[ADDHI]], x5
16; CHECK-BE: subs x1, [[ADDLO]], x5
17; CHECK-BE: sbcs x0, [[ADDHI]], x4
18
19  ret i128 %valsub
20; CHECK: ret
21}
22
23define i128 @test_imm(i128 %a) {
24; CHECK-LABEL: test_imm:
25
26  %val = add i128 %a, 12
27; CHECK-LE: adds x0, x0, #12
28; CHECK-LE: adcs x1, x1, {{x[0-9]|xzr}}
29; CHECK-BE: adds x1, x1, #12
30; CHECK-BE: adcs x0, x0, {{x[0-9]|xzr}}
31
32  ret i128 %val
33; CHECK: ret
34}
35
36define i128 @test_shifted(i128 %a, i128 %b) {
37; CHECK-LABEL: test_shifted:
38
39  %rhs = shl i128 %b, 45
40
41  %val = add i128 %a, %rhs
42; CHECK-LE: adds x0, x0, x2, lsl #45
43; CHECK-LE: adcs x1, x1, {{x[0-9]}}
44; CHECK-BE: adds x1, x1, x3, lsl #45
45; CHECK-BE: adcs x0, x0, {{x[0-9]}}
46
47  ret i128 %val
48; CHECK: ret
49}
50
51define i128 @test_extended(i128 %a, i16 %b) {
52; CHECK-LABEL: test_extended:
53
54  %ext = sext i16 %b to i128
55  %rhs = shl i128 %ext, 3
56
57  %val = add i128 %a, %rhs
58; CHECK-LE: adds x0, x0, w2, sxth #3
59; CHECK-LE: adcs x1, x1, {{x[0-9]}}
60; CHECK-BE: adds x1, x1, w2, sxth #3
61; CHECK-BE: adcs x0, x0, {{x[0-9]}}
62
63  ret i128 %val
64; CHECK: ret
65}
66