xref: /minix3/sys/external/bsd/compiler_rt/dist/test/Unit/ashldi3_test.c (revision 4684ddb6aab0b36791c8099bc705d6140b3d05d0)
1*4684ddb6SLionel Sambuc //===-- ashldi3_test.c - Test __ashldi3 -----------------------------------===//
2*4684ddb6SLionel Sambuc //
3*4684ddb6SLionel Sambuc //                     The LLVM Compiler Infrastructure
4*4684ddb6SLionel Sambuc //
5*4684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6*4684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7*4684ddb6SLionel Sambuc //
8*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
9*4684ddb6SLionel Sambuc //
10*4684ddb6SLionel Sambuc // This file tests __ashldi3 for the compiler_rt library.
11*4684ddb6SLionel Sambuc //
12*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
13*4684ddb6SLionel Sambuc 
14*4684ddb6SLionel Sambuc #include "int_lib.h"
15*4684ddb6SLionel Sambuc #include <stdio.h>
16*4684ddb6SLionel Sambuc 
17*4684ddb6SLionel Sambuc // Returns: a << b
18*4684ddb6SLionel Sambuc 
19*4684ddb6SLionel Sambuc // Precondition:  0 <= b < bits_in_dword
20*4684ddb6SLionel Sambuc 
21*4684ddb6SLionel Sambuc di_int __ashldi3(di_int a, si_int b);
22*4684ddb6SLionel Sambuc 
test__ashldi3(di_int a,si_int b,di_int expected)23*4684ddb6SLionel Sambuc int test__ashldi3(di_int a, si_int b, di_int expected)
24*4684ddb6SLionel Sambuc {
25*4684ddb6SLionel Sambuc     di_int x = __ashldi3(a, b);
26*4684ddb6SLionel Sambuc     if (x != expected)
27*4684ddb6SLionel Sambuc         printf("error in __ashldi3: %llX << %d = %llX, expected %llX\n",
28*4684ddb6SLionel Sambuc                a, b, __ashldi3(a, b), expected);
29*4684ddb6SLionel Sambuc     return x != expected;
30*4684ddb6SLionel Sambuc }
31*4684ddb6SLionel Sambuc 
32*4684ddb6SLionel Sambuc char assumption_1[sizeof(di_int) == 2*sizeof(si_int)] = {0};
33*4684ddb6SLionel Sambuc 
main()34*4684ddb6SLionel Sambuc int main()
35*4684ddb6SLionel Sambuc {
36*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 0, 0x123456789ABCDEFLL))
37*4684ddb6SLionel Sambuc         return 1;
38*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 1, 0x2468ACF13579BDELL))
39*4684ddb6SLionel Sambuc         return 1;
40*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 2, 0x48D159E26AF37BCLL))
41*4684ddb6SLionel Sambuc         return 1;
42*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 3, 0x91A2B3C4D5E6F78LL))
43*4684ddb6SLionel Sambuc         return 1;
44*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 4, 0x123456789ABCDEF0LL))
45*4684ddb6SLionel Sambuc         return 1;
46*4684ddb6SLionel Sambuc 
47*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 28, 0x789ABCDEF0000000LL))
48*4684ddb6SLionel Sambuc         return 1;
49*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 29, 0xF13579BDE0000000LL))
50*4684ddb6SLionel Sambuc         return 1;
51*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 30, 0xE26AF37BC0000000LL))
52*4684ddb6SLionel Sambuc         return 1;
53*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 31, 0xC4D5E6F780000000LL))
54*4684ddb6SLionel Sambuc         return 1;
55*4684ddb6SLionel Sambuc 
56*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 32, 0x89ABCDEF00000000LL))
57*4684ddb6SLionel Sambuc         return 1;
58*4684ddb6SLionel Sambuc 
59*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 33, 0x13579BDE00000000LL))
60*4684ddb6SLionel Sambuc         return 1;
61*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 34, 0x26AF37BC00000000LL))
62*4684ddb6SLionel Sambuc         return 1;
63*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 35, 0x4D5E6F7800000000LL))
64*4684ddb6SLionel Sambuc         return 1;
65*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 36, 0x9ABCDEF000000000LL))
66*4684ddb6SLionel Sambuc         return 1;
67*4684ddb6SLionel Sambuc 
68*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 60, 0xF000000000000000LL))
69*4684ddb6SLionel Sambuc         return 1;
70*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 61, 0xE000000000000000LL))
71*4684ddb6SLionel Sambuc         return 1;
72*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 62, 0xC000000000000000LL))
73*4684ddb6SLionel Sambuc         return 1;
74*4684ddb6SLionel Sambuc     if (test__ashldi3(0x0123456789ABCDEFLL, 63, 0x8000000000000000LL))
75*4684ddb6SLionel Sambuc         return 1;
76*4684ddb6SLionel Sambuc     return 0;
77*4684ddb6SLionel Sambuc }
78