Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 1 | //===-- udivti3_test.c - Test __udivti3 -----------------------------------===// |
| 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 __udivti3 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: a / b |
| 20 | |
| 21 | tu_int __udivti3(tu_int a, tu_int b); |
| 22 | |
| 23 | int test__udivti3(tu_int a, tu_int b, tu_int expected_q) |
| 24 | { |
| 25 | tu_int q = __udivti3(a, b); |
| 26 | if (q != expected_q) |
| 27 | { |
| 28 | utwords at; |
| 29 | at.all = a; |
| 30 | utwords bt; |
| 31 | bt.all = b; |
| 32 | utwords qt; |
| 33 | qt.all = q; |
| 34 | utwords expected_qt; |
| 35 | expected_qt.all = expected_q; |
| 36 | printf("error in __udivti3: 0x%llX%.16llX / 0x%llX%.16llX = " |
| 37 | "0x%llX%.16llX, expected 0x%llX%.16llX\n", |
Daniel Dunbar | cff5248 | 2009-10-27 17:49:07 +0000 | [diff] [blame] | 38 | at.s.high, at.s.low, bt.s.high, bt.s.low, qt.s.high, qt.s.low, |
| 39 | expected_qt.s.high, expected_qt.s.low); |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 40 | } |
| 41 | return q != expected_q; |
| 42 | } |
| 43 | |
| 44 | #endif |
| 45 | |
| 46 | int main() |
| 47 | { |
| 48 | #if __x86_64 |
| 49 | if (test__udivti3(0, 1, 0)) |
| 50 | return 1; |
| 51 | if (test__udivti3(2, 1, 2)) |
| 52 | return 1; |
| 53 | if (test__udivti3(make_tu(0x8000000000000000uLL, 0), 1, |
| 54 | make_tu(0x8000000000000000uLL, 0))) |
| 55 | return 1; |
| 56 | if (test__udivti3(make_tu(0x8000000000000000uLL, 0), 2, |
| 57 | make_tu(0x4000000000000000uLL, 0))) |
| 58 | return 1; |
| 59 | if (test__udivti3(make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL), 2, |
| 60 | make_tu(0x7FFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL))) |
| 61 | return 1; |
| 62 | |
Joerg Sonnenberger | 7482815 | 2011-05-29 21:43:29 +0000 | [diff] [blame] | 63 | #else |
| 64 | printf("skipped\n"); |
Daniel Dunbar | b3a6901 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 65 | #endif |
| 66 | return 0; |
| 67 | } |