diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:48 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:06:48 +0000 |
commit | 93c1b73a09a52d4a265f683bf1954b08bb430049 (patch) | |
tree | 5543464d74945196cc890e9d9099e5d0660df7eb /test/builtins/Unit | |
parent | 0d8e7490d6e8a13a8f0977d9b7771803b9f64ea0 (diff) |
Notes
Diffstat (limited to 'test/builtins/Unit')
-rw-r--r-- | test/builtins/Unit/lit.cfg | 8 | ||||
-rw-r--r-- | test/builtins/Unit/riscv/mulsi3_test.c | 119 |
2 files changed, 123 insertions, 4 deletions
diff --git a/test/builtins/Unit/lit.cfg b/test/builtins/Unit/lit.cfg index 0e17e479e6b62..4b63948b5ef6e 100644 --- a/test/builtins/Unit/lit.cfg +++ b/test/builtins/Unit/lit.cfg @@ -26,12 +26,12 @@ config.test_source_root = os.path.dirname(__file__) # Path to the static library is_msvc = get_required_attr(config, "builtins_is_msvc") if is_msvc: - base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.builtins-%s.lib " - % config.target_arch) + base_lib = os.path.join(config.compiler_rt_libdir, "clang_rt.builtins%s.lib " + % config.target_suffix) config.substitutions.append( ("%librt ", base_lib) ) else: - base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.builtins-%s.a" - % config.target_arch) + base_lib = os.path.join(config.compiler_rt_libdir, "libclang_rt.builtins%s.a" + % config.target_suffix) config.substitutions.append( ("%librt ", base_lib + ' -lc -lm ') ) builtins_source_dir = os.path.join( diff --git a/test/builtins/Unit/riscv/mulsi3_test.c b/test/builtins/Unit/riscv/mulsi3_test.c new file mode 100644 index 0000000000000..9033004f11dd8 --- /dev/null +++ b/test/builtins/Unit/riscv/mulsi3_test.c @@ -0,0 +1,119 @@ +// REQUIRES-ANY: riscv32-target-arch +// RUN: %clang_builtins %s %librt -o %t && %run %t +//===-- mulsi3_test.c - Test __mulsi3 -------------------------------------===// +// +// 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 __mulsi3 for the compiler_rt library. +// +//===----------------------------------------------------------------------===// + +#include "int_lib.h" +#include <stdio.h> +#include <limits.h> + +#if !defined(__riscv_mul) && __riscv_xlen == 32 +// Based on mulsi3_test.c + +COMPILER_RT_ABI si_int __mulsi3(si_int a, si_int b); + +int test__mulsi3(si_int a, si_int b, si_int expected) +{ + si_int x = __mulsi3(a, b); + if (x != expected) + printf("error in __mulsi3: %d * %d = %d, expected %d\n", + a, b, __mulsi3(a, b), expected); + return x != expected; +} +#endif + +int main() +{ +#if !defined(__riscv_mul) && __riscv_xlen == 32 + if (test__mulsi3(0, 0, 0)) + return 1; + if (test__mulsi3(0, 1, 0)) + return 1; + if (test__mulsi3(1, 0, 0)) + return 1; + if (test__mulsi3(0, 10, 0)) + return 1; + if (test__mulsi3(10, 0, 0)) + return 1; + if (test__mulsi3(0, INT_MAX, 0)) + return 1; + if (test__mulsi3(INT_MAX, 0, 0)) + return 1; + + if (test__mulsi3(0, -1, 0)) + return 1; + if (test__mulsi3(-1, 0, 0)) + return 1; + if (test__mulsi3(0, -10, 0)) + return 1; + if (test__mulsi3(-10, 0, 0)) + return 1; + if (test__mulsi3(0, INT_MIN, 0)) + return 1; + if (test__mulsi3(INT_MIN, 0, 0)) + return 1; + + if (test__mulsi3(1, 1, 1)) + return 1; + if (test__mulsi3(1, 10, 10)) + return 1; + if (test__mulsi3(10, 1, 10)) + return 1; + if (test__mulsi3(1, INT_MAX, INT_MAX)) + return 1; + if (test__mulsi3(INT_MAX, 1, INT_MAX)) + return 1; + + if (test__mulsi3(1, -1, -1)) + return 1; + if (test__mulsi3(1, -10, -10)) + return 1; + if (test__mulsi3(-10, 1, -10)) + return 1; + if (test__mulsi3(1, INT_MIN, INT_MIN)) + return 1; + if (test__mulsi3(INT_MIN, 1, INT_MIN)) + return 1; + + if (test__mulsi3(46340, 46340, 2147395600)) + return 1; + if (test__mulsi3(-46340, 46340, -2147395600)) + return 1; + if (test__mulsi3(46340, -46340, -2147395600)) + return 1; + if (test__mulsi3(-46340, -46340, 2147395600)) + return 1; + + if (test__mulsi3(4194303, 8192, 34359730176)) + return 1; + if (test__mulsi3(-4194303, 8192, -34359730176)) + return 1; + if (test__mulsi3(4194303, -8192, -34359730176)) + return 1; + if (test__mulsi3(-4194303, -8192, 34359730176)) + return 1; + + if (test__mulsi3(8192, 4194303, 34359730176)) + return 1; + if (test__mulsi3(-8192, 4194303, -34359730176)) + return 1; + if (test__mulsi3(8192, -4194303, -34359730176)) + return 1; + if (test__mulsi3(-8192, -4194303, 34359730176)) + return 1; +#else + printf("skipped\n"); +#endif + + return 0; +} |