[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / addvti3_test.c
blob3c39613d73bef1dd26183383929b01628cb94b40
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_addvti3
3 // REQUIRES: int128
4 //===-- addvti3_test.c - Test __addvti3 -----------------------------------===//
5 //
6 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7 // See https://llvm.org/LICENSE.txt for license information.
8 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //
10 //===----------------------------------------------------------------------===//
12 // This file tests __addvti3 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
16 #include "int_lib.h"
17 #include <stdio.h>
19 #ifdef CRT_HAS_128BIT
21 // Returns: a + b
23 // Effects: aborts if a + b overflows
25 COMPILER_RT_ABI ti_int __addvti3(ti_int a, ti_int b);
27 int test__addvti3(ti_int a, ti_int b)
29 ti_int x = __addvti3(a, b);
30 ti_int expected = a + b;
31 if (x != expected)
33 twords at;
34 at.all = a;
35 twords bt;
36 bt.all = b;
37 twords xt;
38 xt.all = x;
39 twords expectedt;
40 expectedt.all = expected;
41 printf("error in test__addvti3(0x%llX%.16llX, 0x%llX%.16llX) = "
42 "0x%llX%.16llX, expected 0x%llX%.16llX\n",
43 at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low,
44 expectedt.s.high, expectedt.s.low);
46 return x != expected;
49 #endif
51 int main()
53 #ifdef CRT_HAS_128BIT
54 // should abort
55 // test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
56 // make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL));
57 // should abort
58 // test__addvti3(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
59 // make_ti(0x8000000000000000LL, 0x0000000000000000LL));
60 // should abort
61 // test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000001LL),
62 // make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL));
63 // should abort
64 // test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
65 // make_ti(0x0000000000000000LL, 0x0000000000000001LL));
67 if (test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
68 make_ti(0x0000000000000000LL, 0x0000000000000001LL)))
69 return 1;
70 if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000001LL),
71 make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
72 return 1;
73 if (test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
74 make_ti(0x0000000000000000LL, 0x0000000000000000LL)))
75 return 1;
76 if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000000LL),
77 make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
78 return 1;
79 if (test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
80 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
81 return 1;
82 if (test__addvti3(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
83 make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
84 return 1;
85 if (test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
86 make_ti(0x0000000000000000LL, 0x0000000000000000LL)))
87 return 1;
88 if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000000LL),
89 make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
90 return 1;
92 #else
93 printf("skipped\n");
94 #endif
95 return 0;