diff options
author | Alexey Samsonov <samsonov@google.com> | 2014-02-14 09:47:31 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2014-02-14 09:47:31 +0000 |
commit | 28d10da69f52af1b01fbc12fd503621713641500 (patch) | |
tree | 76222f9698fdaafdfe23235d18d5ac804ea515d6 /test/builtins/Unit/addvti3_test.c | |
parent | 08c9d0bc3ac37d7d5def0318a1420e67cca53e41 (diff) |
Move tests for BlocksRuntime and builtins to corresponding directories under test/
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/builtins/Unit/addvti3_test.c')
-rw-r--r-- | test/builtins/Unit/addvti3_test.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/test/builtins/Unit/addvti3_test.c b/test/builtins/Unit/addvti3_test.c new file mode 100644 index 000000000..1cf066c48 --- /dev/null +++ b/test/builtins/Unit/addvti3_test.c @@ -0,0 +1,94 @@ +//===-- addvti3_test.c - Test __addvti3 -----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file tests __addvti3 for the compiler_rt library. +// +//===----------------------------------------------------------------------===// + +#if __x86_64 + +#include "int_lib.h" +#include <stdio.h> + +// Returns: a + b + +// Effects: aborts if a + b overflows + +ti_int __addvti3(ti_int a, ti_int b); + +int test__addvti3(ti_int a, ti_int b) +{ + ti_int x = __addvti3(a, b); + ti_int expected = a + b; + if (x != expected) + { + twords at; + at.all = a; + twords bt; + bt.all = b; + twords xt; + xt.all = x; + twords expectedt; + expectedt.all = expected; + printf("error in test__addvti3(0x%llX%.16llX, 0x%llX%.16llX) = " + "0x%llX%.16llX, expected 0x%llX%.16llX\n", + at.s.high, at.s.low, bt.s.high, bt.s.low, xt.s.high, xt.s.low, + expectedt.s.high, expectedt.s.low); + } + return x != expected; +} + +#endif + +int main() +{ +#if __x86_64 +// should abort +// test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL), +// make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)); +// should abort +// test__addvti3(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), +// make_ti(0x8000000000000000LL, 0x0000000000000000LL)); +// should abort +// test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000001LL), +// make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)); +// should abort +// test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), +// make_ti(0x0000000000000000LL, 0x0000000000000001LL)); + + if (test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL), + make_ti(0x0000000000000000LL, 0x0000000000000001LL))) + return 1; + if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000001LL), + make_ti(0x8000000000000000LL, 0x0000000000000000LL))) + return 1; + if (test__addvti3(make_ti(0x8000000000000000LL, 0x0000000000000000LL), + make_ti(0x0000000000000000LL, 0x0000000000000000LL))) + return 1; + if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000000LL), + make_ti(0x8000000000000000LL, 0x0000000000000000LL))) + return 1; + if (test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), + make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) + return 1; + if (test__addvti3(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), + make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) + return 1; + if (test__addvti3(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), + make_ti(0x0000000000000000LL, 0x0000000000000000LL))) + return 1; + if (test__addvti3(make_ti(0x0000000000000000LL, 0x0000000000000000LL), + make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL))) + return 1; + +#else + printf("skipped\n"); +#endif + return 0; +} |