Merge pull request #3452 from juj/llvm_fabs_f32
Add support and test for llvm_fabs_f32.
This commit is contained in:
Коммит
0978a969f1
|
@ -3993,6 +3993,7 @@ LibraryManager.library = {
|
|||
fabs: 'Math_abs',
|
||||
fabsf: 'Math_abs',
|
||||
fabsl: 'Math_abs',
|
||||
llvm_fabs_f32: 'Math_abs',
|
||||
llvm_fabs_f64: 'Math_abs',
|
||||
ceil: 'Math_ceil',
|
||||
ceilf: 'Math_ceil',
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <float.h>
|
||||
#include <emscripten/emscripten.h>
|
||||
|
||||
float __attribute__((noinline)) negative10()
|
||||
{
|
||||
return (emscripten_random() < -1) ? 0.f : -10.5f;
|
||||
}
|
||||
|
||||
float __attribute__((noinline)) positive42()
|
||||
{
|
||||
return (emscripten_random() < -1) ? 0.f : 42.25f;
|
||||
}
|
||||
|
||||
double __attribute__((noinline)) negative_dbl_max()
|
||||
{
|
||||
return (emscripten_random() < -1) ? 0.f : -DBL_MAX;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("%f\n", __builtin_fabsf(negative10()));
|
||||
printf("%f\n", __builtin_fabsf(positive42()));
|
||||
printf("%f\n", __builtin_fabsf(negative_dbl_max()));
|
||||
|
||||
printf("%f\n", __builtin_fabs(negative10()));
|
||||
printf("%f\n", __builtin_fabs(positive42()));
|
||||
printf("%f\n", __builtin_fabs(negative_dbl_max()));
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
10.500000
|
||||
42.250000
|
||||
inf
|
||||
10.500000
|
||||
42.250000
|
||||
1.7976931348623157e+308
|
|
@ -396,6 +396,12 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co
|
|||
|
||||
self.do_run_from_file(src, output, 'waka fleefl asdfasdfasdfasdf'.split(' '))
|
||||
|
||||
def test_llvm_fabs(self):
|
||||
Settings.PRECISE_F32 = 1
|
||||
test_path = path_from_root('tests', 'core', 'test_llvm_fabs')
|
||||
src, output = (test_path + s for s in ('.c', '.out'))
|
||||
self.do_run_from_file(src, output)
|
||||
|
||||
def test_double_varargs(self):
|
||||
test_path = path_from_root('tests', 'core', 'test_double_varargs')
|
||||
src, output = (test_path + s for s in ('.c', '.out'))
|
||||
|
|
Загрузка…
Ссылка в новой задаче