Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 1 | //===-- lshrti3_test.c - Test __lshrti3 -----------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | 9ad441f | 2010-11-16 22:13:33 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file tests __lshrti3 for the compiler_rt library. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #if __x86_64 |
| 15 | |
| 16 | #include "int_lib.h" |
| 17 | #include <stdio.h> |
| 18 | |
| 19 | // Returns: logical a >> b |
| 20 | |
| 21 | // Precondition: 0 <= b < bits_in_dword |
| 22 | |
| 23 | ti_int __lshrti3(ti_int a, si_int b); |
| 24 | |
| 25 | int test__lshrti3(ti_int a, si_int b, ti_int expected) |
| 26 | { |
| 27 | ti_int x = __lshrti3(a, b); |
| 28 | if (x != expected) |
| 29 | { |
| 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 __lshrti3: 0x%llX%.16llX >> %d = 0x%llX%.16llX," |
| 37 | " expected 0x%llX%.16llX\n", |
Daniel Dunbar | cff5248 | 2009-10-27 17:49:07 +0000 | [diff] [blame] | 38 | at.s.high, at.s.low, b, xt.s.high, xt.s.low, |
| 39 | expectedt.s.high, expectedt.s.low); |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 40 | } |
| 41 | return x != expected; |
| 42 | } |
| 43 | |
| 44 | char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0}; |
| 45 | |
| 46 | #endif |
| 47 | |
| 48 | int main() |
| 49 | { |
| 50 | #if __x86_64 |
| 51 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 0, |
| 52 | make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL))) |
| 53 | return 1; |
| 54 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 1, |
| 55 | make_ti(0x7F6E5D4C3B2A190ALL, 0xFF6E5D4C3B2A190ALL))) |
| 56 | return 1; |
| 57 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 2, |
| 58 | make_ti(0x3FB72EA61D950C85LL, 0x7FB72EA61D950C85LL))) |
| 59 | return 1; |
| 60 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 3, |
| 61 | make_ti(0x1FDB97530ECA8642LL, 0xBFDB97530ECA8642LL))) |
| 62 | return 1; |
| 63 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 4, |
| 64 | make_ti(0x0FEDCBA987654321LL, 0x5FEDCBA987654321LL))) |
| 65 | return 1; |
| 66 | |
| 67 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 28, |
| 68 | make_ti(0x0000000FEDCBA987LL, 0x6543215FEDCBA987LL))) |
| 69 | return 1; |
| 70 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 29, |
| 71 | make_ti(0x00000007F6E5D4C3LL, 0xB2A190AFF6E5D4C3LL))) |
| 72 | return 1; |
| 73 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 30, |
| 74 | make_ti(0x00000003FB72EA61LL, 0xD950C857FB72EA61LL))) |
| 75 | return 1; |
| 76 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 31, |
| 77 | make_ti(0x00000001FDB97530LL, 0xECA8642BFDB97530LL))) |
| 78 | return 1; |
| 79 | |
| 80 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 32, |
| 81 | make_ti(0x00000000FEDCBA98LL, 0x76543215FEDCBA98LL))) |
| 82 | return 1; |
| 83 | |
| 84 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 33, |
| 85 | make_ti(0x000000007F6E5D4CLL, 0x3B2A190AFF6E5D4CLL))) |
| 86 | return 1; |
| 87 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 34, |
| 88 | make_ti(0x000000003FB72EA6LL, 0x1D950C857FB72EA6LL))) |
| 89 | return 1; |
| 90 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 35, |
| 91 | make_ti(0x000000001FDB9753LL, 0x0ECA8642BFDB9753LL))) |
| 92 | return 1; |
| 93 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 36, |
| 94 | make_ti(0x000000000FEDCBA9LL, 0x876543215FEDCBA9LL))) |
| 95 | return 1; |
| 96 | |
| 97 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 60, |
| 98 | make_ti(0x000000000000000FLL, 0xEDCBA9876543215FLL))) |
| 99 | return 1; |
| 100 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 61, |
| 101 | make_ti(0x0000000000000007LL, 0xF6E5D4C3B2A190AFLL))) |
| 102 | return 1; |
| 103 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 62, |
| 104 | make_ti(0x0000000000000003LL, 0xFB72EA61D950C857LL))) |
| 105 | return 1; |
| 106 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 63, |
| 107 | make_ti(0x0000000000000001LL, 0xFDB97530ECA8642BLL))) |
| 108 | return 1; |
| 109 | |
| 110 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 64, |
| 111 | make_ti(0x0000000000000000LL, 0xFEDCBA9876543215LL))) |
| 112 | return 1; |
| 113 | |
| 114 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 65, |
| 115 | make_ti(0x0000000000000000LL, 0x7F6E5D4C3B2A190ALL))) |
| 116 | return 1; |
| 117 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 66, |
| 118 | make_ti(0x0000000000000000LL, 0x3FB72EA61D950C85LL))) |
| 119 | return 1; |
| 120 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 67, |
| 121 | make_ti(0x0000000000000000LL, 0x1FDB97530ECA8642LL))) |
| 122 | return 1; |
| 123 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 68, |
| 124 | make_ti(0x0000000000000000LL, 0x0FEDCBA987654321LL))) |
| 125 | return 1; |
| 126 | |
| 127 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 92, |
| 128 | make_ti(0x0000000000000000LL, 0x0000000FEDCBA987LL))) |
| 129 | return 1; |
| 130 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 93, |
| 131 | make_ti(0x0000000000000000LL, 0x00000007F6E5D4C3LL))) |
| 132 | return 1; |
| 133 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 94, |
| 134 | make_ti(0x0000000000000000LL, 0x00000003FB72EA61LL))) |
| 135 | return 1; |
| 136 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 95, |
| 137 | make_ti(0x0000000000000000LL, 0x00000001FDB97530LL))) |
| 138 | return 1; |
| 139 | |
| 140 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 96, |
| 141 | make_ti(0x0000000000000000LL, 0x00000000FEDCBA98LL))) |
| 142 | return 1; |
| 143 | |
| 144 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 97, |
| 145 | make_ti(0x0000000000000000LL, 0x000000007F6E5D4CLL))) |
| 146 | return 1; |
| 147 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 98, |
| 148 | make_ti(0x0000000000000000LL, 0x000000003FB72EA6LL))) |
| 149 | return 1; |
| 150 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 99, |
| 151 | make_ti(0x0000000000000000LL, 0x000000001FDB9753LL))) |
| 152 | return 1; |
| 153 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 100, |
| 154 | make_ti(0x0000000000000000LL, 0x000000000FEDCBA9LL))) |
| 155 | return 1; |
| 156 | |
| 157 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 124, |
| 158 | make_ti(0x0000000000000000LL, 0x000000000000000FLL))) |
| 159 | return 1; |
| 160 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 125, |
| 161 | make_ti(0x0000000000000000LL, 0x0000000000000007LL))) |
| 162 | return 1; |
| 163 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 126, |
| 164 | make_ti(0x0000000000000000LL, 0x0000000000000003LL))) |
| 165 | return 1; |
| 166 | if (test__lshrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 127, |
| 167 | make_ti(0x0000000000000000LL, 0x0000000000000001LL))) |
| 168 | return 1; |
Joerg Sonnenberger | 7482815 | 2011-05-29 21:43:29 +0000 | [diff] [blame] | 169 | #else |
| 170 | printf("skipped\n"); |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 171 | #endif |
| 172 | return 0; |
| 173 | } |