[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / builtins / Unit / ashrti3_test.c
bloba491e900660c2f819971ceb720a0f02a11dc1e42
1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_ashrti3
3 // REQUIRES: int128
4 //===-- ashrti3_test.c - Test __ashrti3 -----------------------------------===//
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 __ashrti3 for the compiler_rt library.
14 //===----------------------------------------------------------------------===//
16 #include "int_lib.h"
17 #include <stdio.h>
19 #ifdef CRT_HAS_128BIT
21 // Returns: arithmetic a >> b
23 // Precondition: 0 <= b < bits_in_tword
25 COMPILER_RT_ABI ti_int __ashrti3(ti_int a, si_int b);
27 int test__ashrti3(ti_int a, si_int b, ti_int expected)
29 ti_int x = __ashrti3(a, b);
30 if (x != expected)
32 twords at;
33 at.all = a;
34 twords xt;
35 xt.all = x;
36 twords expectedt;
37 expectedt.all = expected;
38 printf("error in __ashrti3: 0x%llX%.16llX >> %d = 0x%llX%.16llX,"
39 " expected 0x%llX%.16llX\n",
40 at.s.high, at.s.low, b, xt.s.high, xt.s.low,
41 expectedt.s.high, expectedt.s.low);
43 return x != expected;
46 char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0};
48 #endif
50 int main()
52 #ifdef CRT_HAS_128BIT
53 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 0,
54 make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL)))
55 return 1;
56 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 1,
57 make_ti(0xFF6E5D4C3B2A190ALL, 0xFF6E5D4C3B2A190ALL)))
58 return 1;
59 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 2,
60 make_ti(0xFFB72EA61D950C85LL, 0x7FB72EA61D950C85LL)))
61 return 1;
62 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 3,
63 make_ti(0xFFDB97530ECA8642LL, 0xBFDB97530ECA8642LL)))
64 return 1;
65 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 4,
66 make_ti(0xFFEDCBA987654321LL, 0x5FEDCBA987654321LL)))
67 return 1;
69 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 28,
70 make_ti(0xFFFFFFFFEDCBA987LL, 0x6543215FEDCBA987LL)))
71 return 1;
72 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 29,
73 make_ti(0xFFFFFFFFF6E5D4C3LL, 0xB2A190AFF6E5D4C3LL)))
74 return 1;
75 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 30,
76 make_ti(0xFFFFFFFFFB72EA61LL, 0xD950C857FB72EA61LL)))
77 return 1;
78 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 31,
79 make_ti(0xFFFFFFFFFDB97530LL, 0xECA8642BFDB97530LL)))
80 return 1;
82 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 32,
83 make_ti(0xFFFFFFFFFEDCBA98LL, 0x76543215FEDCBA98LL)))
84 return 1;
86 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 33,
87 make_ti(0xFFFFFFFFFF6E5D4CLL, 0x3B2A190AFF6E5D4CLL)))
88 return 1;
89 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 34,
90 make_ti(0xFFFFFFFFFFB72EA6LL, 0x1D950C857FB72EA6LL)))
91 return 1;
92 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 35,
93 make_ti(0xFFFFFFFFFFDB9753LL, 0x0ECA8642BFDB9753LL)))
94 return 1;
95 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 36,
96 make_ti(0xFFFFFFFFFFEDCBA9LL, 0x876543215FEDCBA9LL)))
97 return 1;
99 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 60,
100 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xEDCBA9876543215FLL)))
101 return 1;
102 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 61,
103 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xF6E5D4C3B2A190AFLL)))
104 return 1;
105 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 62,
106 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFB72EA61D950C857LL)))
107 return 1;
108 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 63,
109 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFDB97530ECA8642BLL)))
110 return 1;
112 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 64,
113 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFEDCBA9876543215LL)))
114 return 1;
116 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 65,
117 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFF6E5D4C3B2A190ALL)))
118 return 1;
119 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 66,
120 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFB72EA61D950C85LL)))
121 return 1;
122 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 67,
123 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFDB97530ECA8642LL)))
124 return 1;
125 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 68,
126 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFEDCBA987654321LL)))
127 return 1;
129 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 92,
130 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFEDCBA987LL)))
131 return 1;
132 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 93,
133 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFF6E5D4C3LL)))
134 return 1;
135 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 94,
136 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFB72EA61LL)))
137 return 1;
138 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 95,
139 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFDB97530LL)))
140 return 1;
142 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 96,
143 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFEDCBA98LL)))
144 return 1;
146 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 97,
147 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFF6E5D4CLL)))
148 return 1;
149 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 98,
150 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFB72EA6LL)))
151 return 1;
152 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 99,
153 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFDB9753LL)))
154 return 1;
155 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 100,
156 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFEDCBA9LL)))
157 return 1;
159 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 124,
160 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
161 return 1;
162 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 125,
163 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
164 return 1;
165 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 126,
166 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
167 return 1;
168 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 127,
169 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
170 return 1;
171 #else
172 printf("skipped\n");
173 #endif
174 return 0;