Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 1 | //===-- negvsi2_test.c - Test __negvsi2 -----------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | 5b791f6 | 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 | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file tests __negvsi2 for the compiler_rt library. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "int_lib.h" |
| 15 | #include <stdio.h> |
| 16 | |
| 17 | // Returns: -a |
| 18 | |
| 19 | // Effects: aborts if -a overflows |
| 20 | |
Derek Schuff | eb0ebc3 | 2015-04-24 15:45:57 +0000 | [diff] [blame] | 21 | COMPILER_RT_ABI si_int __negvsi2(si_int a); |
Daniel Dunbar | fd08999 | 2009-06-26 16:47:03 +0000 | [diff] [blame] | 22 | |
| 23 | int test__negvsi2(si_int a) |
| 24 | { |
| 25 | si_int x = __negvsi2(a); |
| 26 | si_int expected = -a; |
| 27 | if (x != expected) |
| 28 | printf("error in __negvsi2(0x%X) = %d, expected %d\n", a, x, expected); |
| 29 | return x != expected; |
| 30 | } |
| 31 | |
| 32 | int main() |
| 33 | { |
| 34 | // if (test__negvsi2(0x80000000)) // should abort |
| 35 | // return 1; |
| 36 | if (test__negvsi2(0x00000000)) |
| 37 | return 1; |
| 38 | if (test__negvsi2(0x00000001)) |
| 39 | return 1; |
| 40 | if (test__negvsi2(0x00000002)) |
| 41 | return 1; |
| 42 | if (test__negvsi2(0x7FFFFFFE)) |
| 43 | return 1; |
| 44 | if (test__negvsi2(0x7FFFFFFF)) |
| 45 | return 1; |
| 46 | if (test__negvsi2(0x80000001)) |
| 47 | return 1; |
| 48 | if (test__negvsi2(0x80000002)) |
| 49 | return 1; |
| 50 | if (test__negvsi2(0xFFFFFFFE)) |
| 51 | return 1; |
| 52 | if (test__negvsi2(0xFFFFFFFF)) |
| 53 | return 1; |
| 54 | |
| 55 | return 0; |
| 56 | } |