Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@@ -0,0 +1,66 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- absvdi2_test.c - Test __absvdi2 -----------------------------------===//
//
// 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 __absvdi2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#include <stdlib.h>
// Returns: absolute value
// Effects: aborts if abs(x) < 0
COMPILER_RT_ABI di_int __absvdi2(di_int a);
int test__absvdi2(di_int a)
{
di_int x = __absvdi2(a);
di_int expected = a;
if (expected < 0)
expected = -expected;
if (x != expected || expected < 0)
printf("error in __absvdi2(0x%llX) = %lld, expected positive %lld\n",
a, x, expected);
return x != expected;
}
int main()
{
// if (test__absvdi2(0x8000000000000000LL)) // should abort
// return 1;
if (test__absvdi2(0x0000000000000000LL))
return 1;
if (test__absvdi2(0x0000000000000001LL))
return 1;
if (test__absvdi2(0x0000000000000002LL))
return 1;
if (test__absvdi2(0x7FFFFFFFFFFFFFFELL))
return 1;
if (test__absvdi2(0x7FFFFFFFFFFFFFFFLL))
return 1;
if (test__absvdi2(0x8000000000000001LL))
return 1;
if (test__absvdi2(0x8000000000000002LL))
return 1;
if (test__absvdi2(0xFFFFFFFFFFFFFFFELL))
return 1;
if (test__absvdi2(0xFFFFFFFFFFFFFFFFLL))
return 1;
int i;
for (i = 0; i < 10000; ++i)
if (test__absvdi2(((di_int)rand() << 32) | rand()))
return 1;
return 0;
}

View File

@@ -0,0 +1,66 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- absvsi2_test.c - Test __absvsi2 -----------------------------------===//
//
// 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 __absvsi2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#include <stdlib.h>
// Returns: absolute value
// Effects: aborts if abs(x) < 0
COMPILER_RT_ABI si_int __absvsi2(si_int a);
int test__absvsi2(si_int a)
{
si_int x = __absvsi2(a);
si_int expected = a;
if (expected < 0)
expected = -expected;
if (x != expected || expected < 0)
printf("error in __absvsi2(0x%X) = %d, expected positive %d\n",
a, x, expected);
return x != expected;
}
int main()
{
// if (test__absvsi2(0x80000000)) // should abort
// return 1;
if (test__absvsi2(0x00000000))
return 1;
if (test__absvsi2(0x00000001))
return 1;
if (test__absvsi2(0x00000002))
return 1;
if (test__absvsi2(0x7FFFFFFE))
return 1;
if (test__absvsi2(0x7FFFFFFF))
return 1;
if (test__absvsi2(0x80000001))
return 1;
if (test__absvsi2(0x80000002))
return 1;
if (test__absvsi2(0xFFFFFFFE))
return 1;
if (test__absvsi2(0xFFFFFFFF))
return 1;
int i;
for (i = 0; i < 10000; ++i)
if (test__absvsi2(rand()))
return 1;
return 0;
}

View File

@@ -0,0 +1,85 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- absvti2_test.c - Test __absvti2 -----------------------------------===//
//
// 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 __absvti2 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef CRT_HAS_128BIT
// Returns: absolute value
// Effects: aborts if abs(x) < 0
COMPILER_RT_ABI ti_int __absvti2(ti_int a);
int test__absvti2(ti_int a)
{
ti_int x = __absvti2(a);
ti_int expected = a;
if (expected < 0)
expected = -expected;
if (x != expected || expected < 0)
{
twords at;
at.all = a;
twords xt;
xt.all = x;
twords expectedt;
expectedt.all = expected;
printf("error in __absvti2(0x%llX%.16llX) = "
"0x%llX%.16llX, expected positive 0x%llX%.16llX\n",
at.s.high, at.s.low, xt.s.high, xt.s.low,
expectedt.s.high, expectedt.s.low);
}
return x != expected;
}
#endif
int main()
{
#ifdef CRT_HAS_128BIT
// if (test__absvti2(make_ti(0x8000000000000000LL, 0))) // should abort
// return 1;
if (test__absvti2(0x0000000000000000LL))
return 1;
if (test__absvti2(0x0000000000000001LL))
return 1;
if (test__absvti2(0x0000000000000002LL))
return 1;
if (test__absvti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFELL)))
return 1;
if (test__absvti2(make_ti(0x7FFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
return 1;
if (test__absvti2(make_ti(0x8000000000000000LL, 0x0000000000000001LL)))
return 1;
if (test__absvti2(make_ti(0x8000000000000000LL, 0x0000000000000002LL)))
return 1;
if (test__absvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFELL)))
return 1;
if (test__absvti2(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL)))
return 1;
int i;
for (i = 0; i < 10000; ++i)
if (test__absvti2(make_ti(((ti_int)rand() << 32) | rand(),
((ti_int)rand() << 32) | rand())))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,50 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- adddf3vfp_test.c - Test __adddf3vfp -------------------------------===//
//
// 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 __adddf3vfp for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#if __arm__ && __VFP_FP__
extern COMPILER_RT_ABI double __adddf3vfp(double a, double b);
int test__adddf3vfp(double a, double b)
{
double actual = __adddf3vfp(a, b);
double expected = a + b;
if (actual != expected)
printf("error in test__adddf3vfp(%f, %f) = %f, expected %f\n",
a, b, actual, expected);
return actual != expected;
}
#endif
int main()
{
#if __arm__ && __VFP_FP__
if (test__adddf3vfp(1.0, 1.0))
return 1;
if (test__adddf3vfp(HUGE_VAL, HUGE_VAL))
return 1;
if (test__adddf3vfp(0.0, HUGE_VAL))
return 1;
if (test__adddf3vfp(0.0, -0.0))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,50 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- addsf3vfp_test.c - Test __addsf3vfp -------------------------------===//
//
// 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 __addsf3vfp for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
extern COMPILER_RT_ABI float __addsf3vfp(float a, float b);
#if __arm__ && __VFP_FP__
int test__addsf3vfp(float a, float b)
{
float actual = __addsf3vfp(a, b);
float expected = a + b;
if (actual != expected)
printf("error in test__addsf3vfp(%f, %f) = %f, expected %f\n",
a, b, actual, expected);
return actual != expected;
}
#endif
int main()
{
#if __arm__ && __VFP_FP__
if (test__addsf3vfp(1.0, 1.0))
return 1;
if (test__addsf3vfp(HUGE_VALF, HUGE_VALF))
return 1;
if (test__addsf3vfp(0.0, HUGE_VALF))
return 1;
if (test__addsf3vfp(0.0, -0.0))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,83 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===--------------- addtf3_test.c - Test __addtf3 ------------------------===//
//
// 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 __addtf3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#if __LDBL_MANT_DIG__ == 113
#include "fp_test.h"
// Returns: a + b
COMPILER_RT_ABI long double __addtf3(long double a, long double b);
int test__addtf3(long double a, long double b,
uint64_t expectedHi, uint64_t expectedLo)
{
long double x = __addtf3(a, b);
int ret = compareResultLD(x, expectedHi, expectedLo);
if (ret){
printf("error in test__addtf3(%.20Lf, %.20Lf) = %.20Lf, "
"expected %.20Lf\n", a, b, x,
fromRep128(expectedHi, expectedLo));
}
return ret;
}
char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
#endif
int main()
{
#if __LDBL_MANT_DIG__ == 113
// qNaN + any = qNaN
if (test__addtf3(makeQNaN128(),
0x1.23456789abcdefp+5L,
UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
return 1;
// NaN + any = NaN
if (test__addtf3(makeNaN128(UINT64_C(0x800030000000)),
0x1.23456789abcdefp+5L,
UINT64_C(0x7fff800000000000),
UINT64_C(0x0)))
return 1;
// inf + inf = inf
if (test__addtf3(makeInf128(),
makeInf128(),
UINT64_C(0x7fff000000000000),
UINT64_C(0x0)))
return 1;
// inf + any = inf
if (test__addtf3(makeInf128(),
0x1.2335653452436234723489432abcdefp+5L,
UINT64_C(0x7fff000000000000),
UINT64_C(0x0)))
return 1;
// any + any
if (test__addtf3(0x1.23456734245345543849abcdefp+5L,
0x1.edcba52449872455634654321fp-1L,
UINT64_C(0x40042afc95c8b579),
UINT64_C(0x61e58dd6c51eb77c)))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,59 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- addvdi3_test.c - Test __addvdi3 -----------------------------------===//
//
// 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 __addvdi3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
// Returns: a + b
// Effects: aborts if a + b overflows
COMPILER_RT_ABI di_int __addvdi3(di_int a, di_int b);
int test__addvdi3(di_int a, di_int b)
{
di_int x = __addvdi3(a, b);
di_int expected = a + b;
if (x != expected)
printf("error in test__addvdi3(0x%llX, 0x%llX) = %lld, expected %lld\n",
a, b, x, expected);
return x != expected;
}
int main()
{
// test__addvdi3(0x8000000000000000LL, -1); // should abort
// test__addvdi3(-1, 0x8000000000000000LL); // should abort
// test__addvdi3(1, 0x7FFFFFFFFFFFFFFFLL); // should abort
// test__addvdi3(0x7FFFFFFFFFFFFFFFLL, 1); // should abort
if (test__addvdi3(0x8000000000000000LL, 1))
return 1;
if (test__addvdi3(1, 0x8000000000000000LL))
return 1;
if (test__addvdi3(0x8000000000000000LL, 0))
return 1;
if (test__addvdi3(0, 0x8000000000000000LL))
return 1;
if (test__addvdi3(0x7FFFFFFFFFFFFFFLL, -1))
return 1;
if (test__addvdi3(-1, 0x7FFFFFFFFFFFFFFLL))
return 1;
if (test__addvdi3(0x7FFFFFFFFFFFFFFFLL, 0))
return 1;
if (test__addvdi3(0, 0x7FFFFFFFFFFFFFFFLL))
return 1;
return 0;
}

View File

@@ -0,0 +1,59 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- addvsi3_test.c - Test __addvsi3 -----------------------------------===//
//
// 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 __addvsi3 for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
// Returns: a + b
// Effects: aborts if a + b overflows
COMPILER_RT_ABI si_int __addvsi3(si_int a, si_int b);
int test__addvsi3(si_int a, si_int b)
{
si_int x = __addvsi3(a, b);
si_int expected = a + b;
if (x != expected)
printf("error in test__addvsi3(0x%X, 0x%X) = %d, expected %d\n",
a, b, x, expected);
return x != expected;
}
int main()
{
// test__addvsi3(0x80000000, -1); // should abort
// test__addvsi3(-1, 0x80000000); // should abort
// test__addvsi3(1, 0x7FFFFFFF); // should abort
// test__addvsi3(0x7FFFFFFF, 1); // should abort
if (test__addvsi3(0x80000000, 1))
return 1;
if (test__addvsi3(1, 0x80000000))
return 1;
if (test__addvsi3(0x80000000, 0))
return 1;
if (test__addvsi3(0, 0x80000000))
return 1;
if (test__addvsi3(0x7FFFFFFF, -1))
return 1;
if (test__addvsi3(-1, 0x7FFFFFFF))
return 1;
if (test__addvsi3(0x7FFFFFFF, 0))
return 1;
if (test__addvsi3(0, 0x7FFFFFFF))
return 1;
return 0;
}

View File

@@ -0,0 +1,95 @@
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- 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.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#ifdef CRT_HAS_128BIT
// Returns: a + b
// Effects: aborts if a + b overflows
COMPILER_RT_ABI 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()
{
#ifdef CRT_HAS_128BIT
// 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;
}

View File

@@ -0,0 +1,73 @@
// REQUIRES-ANY: arm-target-arch,armv6m-target-arch
// RUN: %arm_call_apsr -o %t.aspr.o
// RUN: %clang_builtins %s %t.aspr.o %librt -o %t && %run %t
//===-- aeabi_cdcmpeq.c - Test __aeabi_cdcmpeq ----------------------------===//
//
// 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 __aeabi_cdcmpeq for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#if __arm__
#include "call_apsr.h"
extern __attribute__((pcs("aapcs"))) void __aeabi_cdcmpeq(double a, double b);
int test__aeabi_cdcmpeq(double a, double b, int expected)
{
uint32_t cpsr_value = call_apsr_d(a, b, __aeabi_cdcmpeq);
union cpsr cpsr = { .value = cpsr_value };
if (expected != cpsr.flags.z) {
printf("error in __aeabi_cdcmpeq(%f, %f) => Z = %d, expected %d\n",
a, b, cpsr.flags.z, expected);
return 1;
}
return 0;
}
#endif
int main()
{
#if __arm__
if (test__aeabi_cdcmpeq(1.0, 1.0, 1))
return 1;
if (test__aeabi_cdcmpeq(1234.567, 765.4321, 0))
return 1;
if (test__aeabi_cdcmpeq(-123.0, -678.0, 0))
return 1;
if (test__aeabi_cdcmpeq(0.0, -0.0, 1))
return 1;
if (test__aeabi_cdcmpeq(1.0, NAN, 0))
return 1;
if (test__aeabi_cdcmpeq(NAN, 1.0, 0))
return 1;
if (test__aeabi_cdcmpeq(NAN, NAN, 0))
return 1;
if (test__aeabi_cdcmpeq(INFINITY, 1.0, 0))
return 1;
if (test__aeabi_cdcmpeq(0.0, INFINITY, 0))
return 1;
if (test__aeabi_cdcmpeq(-INFINITY, 0.0, 0))
return 1;
if (test__aeabi_cdcmpeq(0.0, -INFINITY, 0))
return 1;
if (test__aeabi_cdcmpeq(INFINITY, INFINITY, 1))
return 1;
if (test__aeabi_cdcmpeq(-INFINITY, -INFINITY, 1))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,96 @@
// REQUIRES-ANY: arm-target-arch,armv6m-target-arch
// RUN: %arm_call_apsr -o %t.aspr.o
// RUN: %clang_builtins %s %t.aspr.o %librt -o %t && %run %t
//===-- aeabi_cdcmple.c - Test __aeabi_cdcmple and __aeabi_cdrcmple -------===//
//
// 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 __aeabi_cdcmple and __aeabi_cdrcmple for the compiler_rt
// library.
//
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "call_apsr.h"
#if __arm__
extern __attribute__((pcs("aapcs"))) void __aeabi_cdcmple(double a, double b);
extern __attribute__((pcs("aapcs"))) void __aeabi_cdrcmple(double a, double b);
int test__aeabi_cdcmple(double a, double b, int expected)
{
int32_t cpsr_value = call_apsr_d(a, b, __aeabi_cdcmple);
int32_t r_cpsr_value = call_apsr_d(b, a, __aeabi_cdrcmple);
if (cpsr_value != r_cpsr_value) {
printf("error: __aeabi_cdcmple(%f, %f) != __aeabi_cdrcmple(%f, %f)\n", a, b, b, a);
return 1;
}
int expected_z, expected_c;
if (expected == -1) {
expected_z = 0;
expected_c = 0;
} else if (expected == 0) {
expected_z = 1;
expected_c = 1;
} else {
// a or b is NaN, or a > b
expected_z = 0;
expected_c = 1;
}
union cpsr cpsr = { .value = cpsr_value };
if (expected_z != cpsr.flags.z || expected_c != cpsr.flags.c) {
printf("error in __aeabi_cdcmple(%f, %f) => (Z = %d, C = %d), expected (Z = %d, C = %d)\n",
a, b, cpsr.flags.z, cpsr.flags.c, expected_z, expected_c);
return 1;
}
cpsr.value = r_cpsr_value;
if (expected_z != cpsr.flags.z || expected_c != cpsr.flags.c) {
printf("error in __aeabi_cdrcmple(%f, %f) => (Z = %d, C = %d), expected (Z = %d, C = %d)\n",
a, b, cpsr.flags.z, cpsr.flags.c, expected_z, expected_c);
return 1;
}
return 0;
}
#endif
int main()
{
#if __arm__
if (test__aeabi_cdcmple(1.0, 1.0, 0))
return 1;
if (test__aeabi_cdcmple(1234.567, 765.4321, 1))
return 1;
if (test__aeabi_cdcmple(765.4321, 1234.567, -1))
return 1;
if (test__aeabi_cdcmple(-123.0, -678.0, 1))
return 1;
if (test__aeabi_cdcmple(-678.0, -123.0, -1))
return 1;
if (test__aeabi_cdcmple(0.0, -0.0, 0))
return 1;
if (test__aeabi_cdcmple(1.0, NAN, 1))
return 1;
if (test__aeabi_cdcmple(NAN, 1.0, 1))
return 1;
if (test__aeabi_cdcmple(NAN, NAN, 1))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,73 @@
// REQUIRES-ANY: arm-target-arch,armv6m-target-arch
// RUN: %arm_call_apsr -o %t.aspr.o
// RUN: %clang_builtins %s %t.aspr.o %librt -o %t && %run %t
//===-- aeabi_cfcmpeq.c - Test __aeabi_cfcmpeq ----------------------------===//
//
// 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 __aeabi_cfcmpeq for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#if __arm__
#include "call_apsr.h"
extern __attribute__((pcs("aapcs"))) void __aeabi_cfcmpeq(float a, float b);
int test__aeabi_cfcmpeq(float a, float b, int expected)
{
uint32_t cpsr_value = call_apsr_f(a, b, __aeabi_cfcmpeq);
union cpsr cpsr = { .value = cpsr_value };
if (expected != cpsr.flags.z) {
printf("error in __aeabi_cfcmpeq(%f, %f) => Z = %d, expected %d\n",
a, b, cpsr.flags.z, expected);
return 1;
}
return 0;
}
#endif
int main()
{
#if __arm__
if (test__aeabi_cfcmpeq(1.0, 1.0, 1))
return 1;
if (test__aeabi_cfcmpeq(1234.567, 765.4321, 0))
return 1;
if (test__aeabi_cfcmpeq(-123.0, -678.0, 0))
return 1;
if (test__aeabi_cfcmpeq(0.0, -0.0, 1))
return 1;
if (test__aeabi_cfcmpeq(1.0, NAN, 0))
return 1;
if (test__aeabi_cfcmpeq(NAN, 1.0, 0))
return 1;
if (test__aeabi_cfcmpeq(NAN, NAN, 0))
return 1;
if (test__aeabi_cfcmpeq(INFINITY, 1.0, 0))
return 1;
if (test__aeabi_cfcmpeq(0.0, INFINITY, 0))
return 1;
if (test__aeabi_cfcmpeq(-INFINITY, 0.0, 0))
return 1;
if (test__aeabi_cfcmpeq(0.0, -INFINITY, 0))
return 1;
if (test__aeabi_cfcmpeq(INFINITY, INFINITY, 1))
return 1;
if (test__aeabi_cfcmpeq(-INFINITY, -INFINITY, 1))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,96 @@
// REQUIRES-ANY: arm-target-arch,armv6m-target-arch
// RUN: %arm_call_apsr -o %t.aspr.o
// RUN: %clang_builtins %s %t.aspr.o %librt -o %t && %run %t
//===-- aeabi_cfcmple.c - Test __aeabi_cfcmple and __aeabi_cfrcmple -------===//
//
// 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 __aeabi_cfcmple and __aeabi_cfrcmple for the compiler_rt
// library.
//
//===----------------------------------------------------------------------===//
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "call_apsr.h"
#if __arm__
extern __attribute__((pcs("aapcs"))) void __aeabi_cfcmple(float a, float b);
extern __attribute__((pcs("aapcs"))) void __aeabi_cfrcmple(float a, float b);
int test__aeabi_cfcmple(float a, float b, int expected)
{
int32_t cpsr_value = call_apsr_f(a, b, __aeabi_cfcmple);
int32_t r_cpsr_value = call_apsr_f(b, a, __aeabi_cfrcmple);
if (cpsr_value != r_cpsr_value) {
printf("error: __aeabi_cfcmple(%f, %f) != __aeabi_cfrcmple(%f, %f)\n", a, b, b, a);
return 1;
}
int expected_z, expected_c;
if (expected == -1) {
expected_z = 0;
expected_c = 0;
} else if (expected == 0) {
expected_z = 1;
expected_c = 1;
} else {
// a or b is NaN, or a > b
expected_z = 0;
expected_c = 1;
}
union cpsr cpsr = { .value = cpsr_value };
if (expected_z != cpsr.flags.z || expected_c != cpsr.flags.c) {
printf("error in __aeabi_cfcmple(%f, %f) => (Z = %d, C = %d), expected (Z = %d, C = %d)\n",
a, b, cpsr.flags.z, cpsr.flags.c, expected_z, expected_c);
return 1;
}
cpsr.value = r_cpsr_value;
if (expected_z != cpsr.flags.z || expected_c != cpsr.flags.c) {
printf("error in __aeabi_cfrcmple(%f, %f) => (Z = %d, C = %d), expected (Z = %d, C = %d)\n",
a, b, cpsr.flags.z, cpsr.flags.c, expected_z, expected_c);
return 1;
}
return 0;
}
#endif
int main()
{
#if __arm__
if (test__aeabi_cfcmple(1.0, 1.0, 0))
return 1;
if (test__aeabi_cfcmple(1234.567, 765.4321, 1))
return 1;
if (test__aeabi_cfcmple(765.4321, 1234.567, -1))
return 1;
if (test__aeabi_cfcmple(-123.0, -678.0, 1))
return 1;
if (test__aeabi_cfcmple(-678.0, -123.0, -1))
return 1;
if (test__aeabi_cfcmple(0.0, -0.0, 0))
return 1;
if (test__aeabi_cfcmple(1.0, NAN, 1))
return 1;
if (test__aeabi_cfcmple(NAN, 1.0, 1))
return 1;
if (test__aeabi_cfcmple(NAN, NAN, 1))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,49 @@
// REQUIRES-ANY: arm-target-arch,armv6m-target-arch
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- aeabi_drsub.c - Test __aeabi_drsub --------------------------------===//
//
// 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 __aeabi_drsub for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#if __arm__
extern __attribute__((pcs("aapcs"))) double __aeabi_drsub(double a, double b);
int test__aeabi_drsub(double a, double b, double expected)
{
double actual = __aeabi_drsub(a, b);
if (actual != expected)
printf("error in __aeabi_drsub(%f, %f) = %f, expected %f\n",
a, b, actual, expected);
return actual != expected;
}
#endif
int main()
{
#if __arm__
if (test__aeabi_drsub(1.0, 1.0, 0.0))
return 1;
if (test__aeabi_drsub(1234.567, 765.4321, -469.134900))
return 1;
if (test__aeabi_drsub(-123.0, -678.0, -555.0))
return 1;
if (test__aeabi_drsub(0.0, -0.0, 0.0))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,49 @@
// REQUIRES-ANY: arm-target-arch,armv6m-target-arch
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- aeabi_frsub.c - Test __aeabi_frsub --------------------------------===//
//
// 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 __aeabi_frsub for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#if __arm__
extern __attribute__((pcs("aapcs"))) float __aeabi_frsub(float a, float b);
int test__aeabi_frsub(float a, float b, float expected)
{
float actual = __aeabi_frsub(a, b);
if (actual != expected)
printf("error in __aeabi_frsub(%f, %f) = %f, expected %f\n",
a, b, actual, expected);
return actual != expected;
}
#endif
int main()
{
#if __arm__
if (test__aeabi_frsub(1.0, 1.0, 0.0))
return 1;
if (test__aeabi_frsub(1234.567, 765.4321, -469.134900))
return 1;
if (test__aeabi_frsub(-123.0, -678.0, -555.0))
return 1;
if (test__aeabi_frsub(0.0, -0.0, 0.0))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,82 @@
// REQUIRES-ANY: arm-target-arch,armv6m-target-arch
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- aeabi_idivmod_test.c - Test __aeabi_idivmod -----------------------===//
//
// 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 __aeabi_idivmod for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#if __arm__
// Based on divmodsi4_test.c
extern du_int __aeabi_idivmod(si_int a, si_int b);
int test__aeabi_idivmod(si_int a, si_int b,
si_int expected_result, si_int expected_rem)
{
si_int rem;
du_int ret = __aeabi_idivmod(a, b);
rem = ret >> 32;
si_int result = ret & 0xFFFFFFFF;
if (result != expected_result) {
printf("error in __aeabi_idivmod: %d / %d = %d, expected %d\n",
a, b, result, expected_result);
return 1;
}
if (rem != expected_rem) {
printf("error in __aeabi_idivmod: %d mod %d = %d, expected %d\n",
a, b, rem, expected_rem);
return 1;
}
return 0;
}
#endif
int main()
{
#if __arm__
if (test__aeabi_idivmod(0, 1, 0, 0))
return 1;
if (test__aeabi_idivmod(0, -1, 0, 0))
return 1;
if (test__aeabi_idivmod(2, 1, 2, 0))
return 1;
if (test__aeabi_idivmod(2, -1, -2, 0))
return 1;
if (test__aeabi_idivmod(-2, 1, -2, 0))
return 1;
if (test__aeabi_idivmod(-2, -1, 2, 0))
return 1;
if (test__aeabi_idivmod(7, 5, 1, 2))
return 1;
if (test__aeabi_idivmod(-7, 5, -1, -2))
return 1;
if (test__aeabi_idivmod(19, 5, 3, 4))
return 1;
if (test__aeabi_idivmod(19, -5, -3, 4))
return 1;
if (test__aeabi_idivmod(0x80000000, 8, 0xf0000000, 0))
return 1;
if (test__aeabi_idivmod(0x80000007, 8, 0xf0000001, -1))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1,69 @@
// REQUIRES-ANY: arm-target-arch,armv6m-target-arch
// RUN: %clang_builtins %s %librt -o %t && %run %t
//===-- aeabi_uidivmod_test.c - Test __aeabi_uidivmod ---------------------===//
//
// 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 __aeabi_uidivmod for the compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "int_lib.h"
#include <stdio.h>
#if __arm__
// Based on udivmodsi4_test.c
extern du_int __aeabi_uidivmod(su_int a, su_int b);
int test__aeabi_uidivmod(su_int a, su_int b,
su_int expected_result, su_int expected_rem)
{
du_int ret = __aeabi_uidivmod(a, b);
su_int rem = ret >> 32;
si_int result = ret & 0xFFFFFFFF;
if (result != expected_result) {
printf("error in __aeabi_uidivmod: %u / %u = %u, expected %u\n",
a, b, result, expected_result);
return 1;
}
if (rem != expected_rem) {
printf("error in __aeabi_uidivmod: %u mod %u = %u, expected %u\n",
a, b, rem, expected_rem);
return 1;
}
return 0;
}
#endif
int main()
{
#if __arm__
if (test__aeabi_uidivmod(0, 1, 0, 0))
return 1;
if (test__aeabi_uidivmod(2, 1, 2, 0))
return 1;
if (test__aeabi_uidivmod(19, 5, 3, 4))
return 1;
if (test__aeabi_uidivmod(0x80000000, 8, 0x10000000, 0))
return 1;
if (test__aeabi_uidivmod(0x80000003, 8, 0x10000000, 3))
return 1;
#else
printf("skipped\n");
#endif
return 0;
}

View File

@@ -0,0 +1 @@
a40f006fa69e7872167eefcf1f68a690be0adea9

View File

@@ -0,0 +1,43 @@
//===-- call_apsr.S - Helpers for ARM EABI floating point tests -----------===//
//
// 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 implements helpers for ARM EABI floating point tests for the
// compiler_rt library.
//
//===----------------------------------------------------------------------===//
#include "../../../../lib/builtins/assembly.h"
.syntax unified
// __attribute__((pcs("aapcs")))
// int32_t call_apsr_d(double a, double b, void(*fn)(double, double)) {
// fn(a, b);
// return apsr;
// }
DEFINE_COMPILERRT_PRIVATE_FUNCTION(call_apsr_d)
push {r7, lr}
ldr r7, [sp, #8]
blx r7
mrs r0, apsr
pop {r7, pc}
END_COMPILERRT_FUNCTION(call_apsr_d)
// __attribute__((pcs("aapcs")))
// int32_t call_apsr_f(float a, float b, void(*fn)(float, float)) {
// fn(a, b);
// return apsr;
// }
DEFINE_COMPILERRT_PRIVATE_FUNCTION(call_apsr_f)
push {lr}
blx r2
mrs r0, apsr
pop {pc}
END_COMPILERRT_FUNCTION(call_apsr_f)

View File

@@ -0,0 +1,39 @@
//===-- call_apsr.h - Helpers for ARM EABI floating point tests -----------===//
//
// 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 declares helpers for ARM EABI floating point tests for the
// compiler_rt library.
//
//===----------------------------------------------------------------------===//
#ifndef CALL_APSR_H
#define CALL_APSR_H
#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
#error big endian support not implemented
#endif
union cpsr {
struct {
uint32_t filler: 28;
uint32_t v: 1;
uint32_t c: 1;
uint32_t z: 1;
uint32_t n: 1;
} flags;
uint32_t value;
};
extern __attribute__((pcs("aapcs")))
uint32_t call_apsr_f(float a, float b, __attribute__((pcs("aapcs"))) void (*fn)(float, float));
extern __attribute__((pcs("aapcs")))
uint32_t call_apsr_d(double a, double b, __attribute__((pcs("aapcs"))) void (*fn)(double, double));
#endif // CALL_APSR_H

Some files were not shown because too many files have changed in this diff Show More