Improve builtin op support for f128/comptime_float

* Add support for fabs, floor, ceil, trunc and round
* Add behavior tests
This commit is contained in:
antlilja
2020-06-17 17:35:45 +02:00
parent f595545c10
commit 1157ee1307
5 changed files with 173 additions and 5 deletions

25
src/softfloat_ext.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include "softfloat_ext.hpp"
extern "C" {
#include "softfloat.h"
}
void f128M_abs(const float128_t *aPtr, float128_t *zPtr) {
float128_t zero_float;
ui32_to_f128M(0, &zero_float);
if (f128M_lt(aPtr, &zero_float)) {
f128M_sub(&zero_float, aPtr, zPtr);
} else {
*zPtr = *aPtr;
}
}
void f128M_trunc(const float128_t *aPtr, float128_t *zPtr) {
float128_t zero_float;
ui32_to_f128M(0, &zero_float);
if (f128M_lt(aPtr, &zero_float)) {
f128M_roundToInt(aPtr, softfloat_round_max, false, zPtr);
} else {
f128M_roundToInt(aPtr, softfloat_round_min, false, zPtr);
}
}