[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / negti2_test.c
blob43bacc4fbd89487b7fd3dcb9195f638a7c46d383
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_negti2
3 // REQUIRES: int128
4 //===-- negti2_test.c - Test __negti2 -------------------------------------===//
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 __negti2 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
16 #include "int_lib.h"
17 #include <stdio.h>
19 #ifdef CRT_HAS_128BIT
21 // Returns: -a
23 COMPILER_RT_ABI ti_int __negti2(ti_int a);
25 int test__negti2(ti_int a, ti_int expected)
27 ti_int x = __negti2(a);
28 if (x != expected)
30 twords at;
31 at.all = a;
32 twords xt;
33 xt.all = x;
34 twords expectedt;
35 expectedt.all = expected;
36 printf("error in __negti2: -0x%.16llX%.16llX = 0x%.16llX%.16llX, "
37 "expected 0x%.16llX%.16llX\n",
38 at.s.high, at.s.low, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low);
40 return x != expected;
43 char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
45 #endif
47 int main()
49 #ifdef CRT_HAS_128BIT
50 if (test__negti2(0, 0))
51 return 1;
52 if (test__negti2(1, -1))
53 return 1;
54 if (test__negti2(-1, 1))
55 return 1;
56 if (test__negti2(2, -2))
57 return 1;
58 if (test__negti2(-2, 2))
59 return 1;
60 if (test__negti2(3, -3))
61 return 1;
62 if (test__negti2(-3, 3))
63 return 1;
64 if (test__negti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFELL),
65 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000002LL)))
66 return 1;
67 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000002LL),
68 make_ti(0x0000000000000000LL, 0x00000000FFFFFFFELL)))
69 return 1;
70 if (test__negti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFFLL),
71 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000001LL)))
72 return 1;
73 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000001LL),
74 make_ti(0x0000000000000000LL, 0x00000000FFFFFFFFLL)))
75 return 1;
76 if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL),
77 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL)))
78 return 1;
79 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL),
80 make_ti(0x0000000000000000LL, 0x0000000100000000LL)))
81 return 1;
82 if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL),
83 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL)))
84 return 1;
85 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL),
86 make_ti(0x0000000000000000LL, 0x0000000200000000LL)))
87 return 1;
88 if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000300000000LL),
89 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFD00000000LL)))
90 return 1;
91 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFD00000000LL),
92 make_ti(0x0000000000000000LL, 0x0000000300000000LL)))
93 return 1;
94 if (test__negti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL),
95 make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL)))
96 return 1;
97 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL),
98 make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL)))
99 return 1;
100 if (test__negti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL),
101 make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL)))
102 return 1;
103 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL),
104 make_ti(0x0000000000000000LL, 0x0000000200000000LL)))
105 return 1;
106 if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL),
107 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL)))
108 return 1;
109 if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL),
110 make_ti(0x0000000000000000LL, 0x0000000100000000LL)))
111 return 1;
112 if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL),
113 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL)))
114 return 1;
115 if (test__negti2(make_ti(0x8000000000000000LL, 0x0000000000000000LL),
116 make_ti(0x8000000000000000LL, 0x0000000000000000LL)))
117 return 1;
118 if (test__negti2(make_ti(0x8000000000000000LL, 0x0000000000000001LL),
119 make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
120 return 1;
121 if (test__negti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL),
122 make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
123 return 1;
125 #else
126 printf("skipped\n");
127 #endif
128 return 0;