1 1.1 joerg //===-- negti2_test.c - Test __negti2 -------------------------------------===// 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 __negti2 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 20 1.1 joerg 21 1.1 joerg ti_int __negti2(ti_int a); 22 1.1 joerg 23 1.1 joerg int test__negti2(ti_int a, ti_int expected) 24 1.1 joerg { 25 1.1 joerg ti_int x = __negti2(a); 26 1.1 joerg if (x != expected) 27 1.1 joerg { 28 1.1 joerg twords at; 29 1.1 joerg at.all = a; 30 1.1 joerg twords xt; 31 1.1 joerg xt.all = x; 32 1.1 joerg twords expectedt; 33 1.1 joerg expectedt.all = expected; 34 1.1 joerg printf("error in __negti2: -0x%.16llX%.16llX = 0x%.16llX%.16llX, " 35 1.1 joerg "expected 0x%.16llX%.16llX\n", 36 1.1 joerg at.s.high, at.s.low, xt.s.high, xt.s.low, expectedt.s.high, expectedt.s.low); 37 1.1 joerg } 38 1.1 joerg return x != expected; 39 1.1 joerg } 40 1.1 joerg 41 1.1 joerg char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0}; 42 1.1 joerg 43 1.1 joerg #endif 44 1.1 joerg 45 1.1 joerg int main() 46 1.1 joerg { 47 1.1 joerg #if __x86_64 48 1.1 joerg if (test__negti2(0, 0)) 49 1.1 joerg return 1; 50 1.1 joerg if (test__negti2(1, -1)) 51 1.1 joerg return 1; 52 1.1 joerg if (test__negti2(-1, 1)) 53 1.1 joerg return 1; 54 1.1 joerg if (test__negti2(2, -2)) 55 1.1 joerg return 1; 56 1.1 joerg if (test__negti2(-2, 2)) 57 1.1 joerg return 1; 58 1.1 joerg if (test__negti2(3, -3)) 59 1.1 joerg return 1; 60 1.1 joerg if (test__negti2(-3, 3)) 61 1.1 joerg return 1; 62 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFELL), 63 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000002LL))) 64 1.1 joerg return 1; 65 1.1 joerg if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000002LL), 66 1.1 joerg make_ti(0x0000000000000000LL, 0x00000000FFFFFFFELL))) 67 1.1 joerg return 1; 68 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x00000000FFFFFFFFLL), 69 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000001LL))) 70 1.1 joerg return 1; 71 1.1 joerg if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000001LL), 72 1.1 joerg make_ti(0x0000000000000000LL, 0x00000000FFFFFFFFLL))) 73 1.1 joerg return 1; 74 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL), 75 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL))) 76 1.1 joerg return 1; 77 1.1 joerg if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL), 78 1.1 joerg make_ti(0x0000000000000000LL, 0x0000000100000000LL))) 79 1.1 joerg return 1; 80 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL), 81 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL))) 82 1.1 joerg return 1; 83 1.1 joerg if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL), 84 1.1 joerg make_ti(0x0000000000000000LL, 0x0000000200000000LL))) 85 1.1 joerg return 1; 86 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000300000000LL), 87 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFD00000000LL))) 88 1.1 joerg return 1; 89 1.1 joerg if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFD00000000LL), 90 1.1 joerg make_ti(0x0000000000000000LL, 0x0000000300000000LL))) 91 1.1 joerg return 1; 92 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL), 93 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL))) 94 1.1 joerg return 1; 95 1.1 joerg if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL), 96 1.1 joerg make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL))) 97 1.1 joerg return 1; 98 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x7FFFFFFFFFFFFFFFLL), 99 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL))) 100 1.1 joerg return 1; 101 1.1 joerg if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL), 102 1.1 joerg make_ti(0x0000000000000000LL, 0x0000000200000000LL))) 103 1.1 joerg return 1; 104 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000200000000LL), 105 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFE00000000LL))) 106 1.1 joerg return 1; 107 1.1 joerg if (test__negti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL), 108 1.1 joerg make_ti(0x0000000000000000LL, 0x0000000100000000LL))) 109 1.1 joerg return 1; 110 1.1 joerg if (test__negti2(make_ti(0x0000000000000000LL, 0x0000000100000000LL), 111 1.1 joerg make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFF00000000LL))) 112 1.1 joerg return 1; 113 1.1 joerg if (test__negti2(make_ti(0x8000000000000000LL, 0x0000000000000000LL), 114 1.1 joerg make_ti(0x8000000000000000LL, 0x0000000000000000LL))) 115 1.1 joerg return 1; 116 1.1 joerg if (test__negti2(make_ti(0x8000000000000000LL, 0x0000000000000001LL), 117 1.1 joerg make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) 118 1.1 joerg return 1; 119 1.1 joerg if (test__negti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), 120 1.1 joerg make_ti(0x8000000000000000LL, 0x0000000000000001LL))) 121 1.1 joerg return 1; 122 1.1 joerg 123 1.1 joerg #else 124 1.1 joerg printf("skipped\n"); 125 1.1 joerg #endif 126 1.1 joerg return 0; 127 1.1 joerg } 128