[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / negvti2_test.c
bloba657284423915055a974feef8d890df2a732d77c
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negvti2
3 // REQUIRES: int128
4 //===-- negvti2_test.c - Test __negvti2 -----------------------------------===//
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 __negvti2 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
16 #include "int_lib.h"
17 #include <stdio.h>
19 #ifdef CRT_HAS_128BIT
21 // Returns: -a
23 // Effects: aborts if -a overflows
25 COMPILER_RT_ABI ti_int __negvti2(ti_int a);
26 COMPILER_RT_ABI ti_int __negti2(ti_int a);
28 int test__negvti2(ti_int a)
30 ti_int x = __negvti2(a);
31 ti_int expected = __negti2(a);
32 if (x != expected)
34 twords at;
35 at.all = a;
36 twords xt;
37 xt.all = x;
38 twords expectedt;
39 expectedt.all = expected;
40 printf("error in __negvti2(0x%.16llX%.16llX) = 0x%.16llX%.16llX, "
41 "expected 0x%.16llX%.16llX\n",
42 at.s.high, at.s.low, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
44 return x != expected;
47 #endif
49 int main()
51 #ifdef CRT_HAS_128BIT
52 if (test__negvti2(0))
53 return 1;
54 if (test__negvti2(1))
55 return 1;
56 if (test__negvti2(-1))
57 return 1;
58 if (test__negvti2(2))
59 return 1;
60 if (test__negvti2(-2))
61 return 1;
62 if (test__negvti2(3))
63 return 1;
64 if (test__negvti2(-3))
65 return 1;
66 if (test__negvti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFELL)))
67 return 1;
68 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000002LL)))
69 return 1;
70 if (test__negvti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFFLL)))
71 return 1;
72 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000001LL)))
73 return 1;
74 if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL)))
75 return 1;
76 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL)))
77 return 1;
78 if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL)))
79 return 1;
80 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL)))
81 return 1;
82 if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000300000000LL)))
83 return 1;
84 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFD00000000LL)))
85 return 1;
86 if (test__negvti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL)))
87 return 1;
88 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL)))
89 return 1;
90 if (test__negvti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL)))
91 return 1;
92 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL)))
93 return 1;
94 if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL)))
95 return 1;
96 if (test__negvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL)))
97 return 1;
98 if (test__negvti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL)))
99 return 1;
100 // if (test__negvti2(make_ti(0x8000000000000000LL, 0x0000000000000000LL))) // abort
101 // return 1;
102 if (test__negvti2(make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
103 return 1;
104 if (test__negvti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
105 return 1;
107 #else
108 printf("skipped\n");
109 #endif
110 return 0;