1 //===-- ashrti3_test.c - Test __ashrti3 -----------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file tests __ashrti3 for the compiler_rt library. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "int_lib.h" 15 #include <stdio.h> 16 17 #ifdef CRT_HAS_128BIT 18 19 // Returns: arithmetic a >> b 20 21 // Precondition: 0 <= b < bits_in_tword 22 23 COMPILER_RT_ABI ti_int __ashrti3(ti_int a, si_int b); 24 25 int test__ashrti3(ti_int a, si_int b, ti_int expected) 26 { 27 ti_int x = __ashrti3(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 __ashrti3: 0x%llX%.16llX >> %d = 0x%llX%.16llX," 37 " expected 0x%llX%.16llX\n", 38 at.s.high, at.s.low, b, xt.s.high, xt.s.low, 39 expectedt.s.high, expectedt.s.low); 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 #ifdef CRT_HAS_128BIT 51 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 0, 52 make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL))) 53 return 1; 54 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 1, 55 make_ti(0xFF6E5D4C3B2A190ALL, 0xFF6E5D4C3B2A190ALL))) 56 return 1; 57 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 2, 58 make_ti(0xFFB72EA61D950C85LL, 0x7FB72EA61D950C85LL))) 59 return 1; 60 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 3, 61 make_ti(0xFFDB97530ECA8642LL, 0xBFDB97530ECA8642LL))) 62 return 1; 63 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 4, 64 make_ti(0xFFEDCBA987654321LL, 0x5FEDCBA987654321LL))) 65 return 1; 66 67 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 28, 68 make_ti(0xFFFFFFFFEDCBA987LL, 0x6543215FEDCBA987LL))) 69 return 1; 70 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 29, 71 make_ti(0xFFFFFFFFF6E5D4C3LL, 0xB2A190AFF6E5D4C3LL))) 72 return 1; 73 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 30, 74 make_ti(0xFFFFFFFFFB72EA61LL, 0xD950C857FB72EA61LL))) 75 return 1; 76 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 31, 77 make_ti(0xFFFFFFFFFDB97530LL, 0xECA8642BFDB97530LL))) 78 return 1; 79 80 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 32, 81 make_ti(0xFFFFFFFFFEDCBA98LL, 0x76543215FEDCBA98LL))) 82 return 1; 83 84 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 33, 85 make_ti(0xFFFFFFFFFF6E5D4CLL, 0x3B2A190AFF6E5D4CLL))) 86 return 1; 87 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 34, 88 make_ti(0xFFFFFFFFFFB72EA6LL, 0x1D950C857FB72EA6LL))) 89 return 1; 90 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 35, 91 make_ti(0xFFFFFFFFFFDB9753LL, 0x0ECA8642BFDB9753LL))) 92 return 1; 93 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 36, 94 make_ti(0xFFFFFFFFFFEDCBA9LL, 0x876543215FEDCBA9LL))) 95 return 1; 96 97 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 60, 98 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xEDCBA9876543215FLL))) 99 return 1; 100 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 61, 101 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xF6E5D4C3B2A190AFLL))) 102 return 1; 103 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 62, 104 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFB72EA61D950C857LL))) 105 return 1; 106 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 63, 107 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFDB97530ECA8642BLL))) 108 return 1; 109 110 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 64, 111 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFEDCBA9876543215LL))) 112 return 1; 113 114 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 65, 115 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFF6E5D4C3B2A190ALL))) 116 return 1; 117 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 66, 118 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFB72EA61D950C85LL))) 119 return 1; 120 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 67, 121 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFDB97530ECA8642LL))) 122 return 1; 123 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 68, 124 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFEDCBA987654321LL))) 125 return 1; 126 127 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 92, 128 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFEDCBA987LL))) 129 return 1; 130 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 93, 131 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFF6E5D4C3LL))) 132 return 1; 133 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 94, 134 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFB72EA61LL))) 135 return 1; 136 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 95, 137 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFDB97530LL))) 138 return 1; 139 140 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 96, 141 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFEDCBA98LL))) 142 return 1; 143 144 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 97, 145 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFF6E5D4CLL))) 146 return 1; 147 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 98, 148 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFB72EA6LL))) 149 return 1; 150 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 99, 151 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFDB9753LL))) 152 return 1; 153 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 100, 154 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFEDCBA9LL))) 155 return 1; 156 157 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 124, 158 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) 159 return 1; 160 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 125, 161 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) 162 return 1; 163 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 126, 164 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) 165 return 1; 166 if (test__ashrti3(make_ti(0xFEDCBA9876543215LL, 0xFEDCBA9876543215LL), 127, 167 make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) 168 return 1; 169 #else 170 printf("skipped\n"); 171 #endif 172 return 0; 173 } 174