1 1.1 joerg //===-- udivti3_test.c - Test __udivti3 -----------------------------------===// 2 1.1 joerg // 3 1.1 joerg // The LLVM Compiler Infrastructure 4 1.1 joerg // 5 1.1 joerg // This file is dual licensed under the MIT and the University of Illinois Open 6 1.1 joerg // Source Licenses. See LICENSE.TXT for details. 7 1.1 joerg // 8 1.1 joerg //===----------------------------------------------------------------------===// 9 1.1 joerg // 10 1.1 joerg // This file tests __udivti3 for the compiler_rt library. 11 1.1 joerg // 12 1.1 joerg //===----------------------------------------------------------------------===// 13 1.1 joerg 14 1.1 joerg #if __x86_64 15 1.1 joerg 16 1.1 joerg #include "int_lib.h" 17 1.1 joerg #include <stdio.h> 18 1.1 joerg 19 1.1 joerg // Returns: a / b 20 1.1 joerg 21 1.1 joerg tu_int __udivti3(tu_int a, tu_int b); 22 1.1 joerg 23 1.1 joerg int test__udivti3(tu_int a, tu_int b, tu_int expected_q) 24 1.1 joerg { 25 1.1 joerg tu_int q = __udivti3(a, b); 26 1.1 joerg if (q != expected_q) 27 1.1 joerg { 28 1.1 joerg utwords at; 29 1.1 joerg at.all = a; 30 1.1 joerg utwords bt; 31 1.1 joerg bt.all = b; 32 1.1 joerg utwords qt; 33 1.1 joerg qt.all = q; 34 1.1 joerg utwords expected_qt; 35 1.1 joerg expected_qt.all = expected_q; 36 1.1 joerg printf("error in __udivti3: 0x%llX%.16llX / 0x%llX%.16llX = " 37 1.1 joerg "0x%llX%.16llX, expected 0x%llX%.16llX\n", 38 1.1 joerg at.s.high, at.s.low, bt.s.high, bt.s.low, qt.s.high, qt.s.low, 39 1.1 joerg expected_qt.s.high, expected_qt.s.low); 40 1.1 joerg } 41 1.1 joerg return q != expected_q; 42 1.1 joerg } 43 1.1 joerg 44 1.1 joerg #endif 45 1.1 joerg 46 1.1 joerg int main() 47 1.1 joerg { 48 1.1 joerg #if __x86_64 49 1.1 joerg if (test__udivti3(0, 1, 0)) 50 1.1 joerg return 1; 51 1.1 joerg if (test__udivti3(2, 1, 2)) 52 1.1 joerg return 1; 53 1.1 joerg if (test__udivti3(make_tu(0x8000000000000000uLL, 0), 1, 54 1.1 joerg make_tu(0x8000000000000000uLL, 0))) 55 1.1 joerg return 1; 56 1.1 joerg if (test__udivti3(make_tu(0x8000000000000000uLL, 0), 2, 57 1.1 joerg make_tu(0x4000000000000000uLL, 0))) 58 1.1 joerg return 1; 59 1.1 joerg if (test__udivti3(make_tu(0xFFFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL), 2, 60 1.1 joerg make_tu(0x7FFFFFFFFFFFFFFFuLL, 0xFFFFFFFFFFFFFFFFuLL))) 61 1.1 joerg return 1; 62 1.1 joerg 63 1.1 joerg #else 64 1.1 joerg printf("skipped\n"); 65 1.1 joerg #endif 66 1.1 joerg return 0; 67 1.1 joerg } 68