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