Add --strip-unused.

This commit is contained in:
Christoffer Lerno
2023-02-16 22:02:44 +01:00
committed by Christoffer Lerno
parent 0aa776d61b
commit a0a5c940f1
40 changed files with 681 additions and 94 deletions

View File

@@ -1,12 +1,12 @@
module std::math;
fn float __roundevenf(float f) @extern("roundevenf") @weak
fn float __roundevenf(float f) @extern("roundevenf") @weak @nostrip
{
// Slow implementation
return round(f / 2) * 2;
}
fn double __roundeven(double d) @extern("roundeven") @weak
fn double __roundeven(double d) @extern("roundeven") @weak @nostrip
{
// Slow implementation
return round(d / 2) * 2;

View File

@@ -1,6 +1,6 @@
module std::math;
fn int128 __divti3(int128 a, int128 b) @extern("__divti3") @weak
fn int128 __divti3(int128 a, int128 b) @extern("__divti3") @weak @nostrip
{
int128 sign_a = a >> 127; // -1 : 0
int128 sign_b = b >> 127; // -1 : 0
@@ -10,7 +10,7 @@ fn int128 __divti3(int128 a, int128 b) @extern("__divti3") @weak
return __udivti3(unsigned_a, unsigned_b) @inline ^ sign_a + (-sign_a);
}
fn uint128 __umodti3(uint128 n, uint128 d) @extern("__umodti3") @weak
fn uint128 __umodti3(uint128 n, uint128 d) @extern("__umodti3") @weak @nostrip
{
// Ignore d = 0
uint128 sr = (d ? $$clz(d) : 128) - (n ? $$clz(n) : 128);
@@ -34,7 +34,7 @@ fn uint128 __umodti3(uint128 n, uint128 d) @extern("__umodti3") @weak
return r;
}
fn uint128 __udivti3(uint128 n, uint128 d) @extern("__udivti3") @weak
fn uint128 __udivti3(uint128 n, uint128 d) @extern("__udivti3") @weak @nostrip
{
// Ignore d = 0
uint128 sr = (d ? $$clz(d) : 128) - (n ? $$clz(n) : 128);
@@ -60,7 +60,7 @@ fn uint128 __udivti3(uint128 n, uint128 d) @extern("__udivti3") @weak
return n;
}
fn int128 __modti3(int128 a, int128 b) @extern("__modti3") @weak
fn int128 __modti3(int128 a, int128 b) @extern("__modti3") @weak @nostrip
{
int128 sign = b >> 127;
uint128 unsigned_b = (uint128)(b ^ sign) + (-sign);
@@ -83,7 +83,7 @@ union Int128bits @private
uint128 all;
}
fn uint128 __lshrti3(uint128 a, uint b) @extern("__lshrti3") @weak
fn uint128 __lshrti3(uint128 a, uint b) @extern("__lshrti3") @weak @nostrip
{
Int128bits result;
result.all = a;
@@ -101,7 +101,7 @@ fn uint128 __lshrti3(uint128 a, uint b) @extern("__lshrti3") @weak
return result.all;
}
fn int128 __ashrti3(int128 a, uint b) @extern("__ashrti3") @weak
fn int128 __ashrti3(int128 a, uint b) @extern("__ashrti3") @weak @nostrip
{
Int128bits result;
result.all = a;
@@ -119,7 +119,7 @@ fn int128 __ashrti3(int128 a, uint b) @extern("__ashrti3") @weak
return result.all;
}
fn int128 __ashlti3(int128 a, uint b) @extern("__ashlti3") @weak
fn int128 __ashlti3(int128 a, uint b) @extern("__ashlti3") @weak @nostrip
{
Int128bits result;
result.all = a;
@@ -158,7 +158,7 @@ fn int128 __mulddi3(ulong a, ulong b) @private
return r.all;
}
fn int128 __multi3(int128 a, int128 b) @extern("__multi3") @weak
fn int128 __multi3(int128 a, int128 b) @extern("__multi3") @weak @nostrip
{
Int128bits x = { .all = a };
Int128bits y = { .all = b };
@@ -167,14 +167,14 @@ fn int128 __multi3(int128 a, int128 b) @extern("__multi3") @weak
return r.all;
}
fn float __floattisf(int128 a) @extern("__floattisf") @weak => float_from_i128(float, a);
fn double __floattidf(int128 a) @extern("__floattidf") @weak => float_from_i128(double, a);
fn float __floatuntisf(uint128 a) @extern("__floatuntisf") @weak => float_from_u128(float, a);
fn double __floatuntidf(uint128 a) @extern("__floatuntidf") @weak => float_from_u128(double, a);
fn uint128 __fixunsdfti(double a) @weak @extern("__fixunsdfti") => fixuint(a);
fn uint128 __fixunssfti(float a) @weak @extern("__fixunssfti") => fixuint(a);
fn int128 __fixdfti(double a) @weak @extern("__fixdfti") => fixint(a);
fn int128 __fixsfti(float a) @weak @extern("__fixsfti") => fixint(a);
fn float __floattisf(int128 a) @extern("__floattisf") @weak @nostrip => float_from_i128(float, a);
fn double __floattidf(int128 a) @extern("__floattidf") @weak @nostrip => float_from_i128(double, a);
fn float __floatuntisf(uint128 a) @extern("__floatuntisf") @weak @nostrip => float_from_u128(float, a);
fn double __floatuntidf(uint128 a) @extern("__floatuntidf") @weak @nostrip => float_from_u128(double, a);
fn uint128 __fixunsdfti(double a) @weak @extern("__fixunsdfti") @nostrip => fixuint(a);
fn uint128 __fixunssfti(float a) @weak @extern("__fixunssfti") @nostrip => fixuint(a);
fn int128 __fixdfti(double a) @weak @extern("__fixdfti") @nostrip => fixint(a);
fn int128 __fixsfti(float a) @weak @extern("__fixsfti") @nostrip => fixint(a);
macro float_from_i128($Type, a) @private

View File

@@ -14,7 +14,7 @@ $if (!env::COMPILER_LIBC_AVAILABLE):
* ====================================================
*/
fn double __cos(double x, double y) @extern("__cos") @weak
fn double __cos(double x, double y) @extern("__cos") @weak @nostrip
{
const C1 = 4.16666666666666019037e-02; /* 0x3FA55555, 0x5555554C */
const C2 = -1.38888888888741095749e-03; /* 0xBF56C16C, 0x16C15177 */

View File

@@ -24,7 +24,7 @@ const double C1 @private = 0x155553e1053a42.0p-57; /* 0.0416666233237390631894
const double C2 @private = -0x16c087e80f1e27.0p-62; /* -0.00138867637746099294692 */
const double C3 @private = 0x199342e0ee5069.0p-68; /* 0.0000243904487962774090654 */
fn float __cosdf(double x) @extern("__cosdf") @weak
fn float __cosdf(double x) @extern("__cosdf") @weak @nostrip
{
/* Try to optimize for parallel evaluation as in __tandf.c. */
double z = x * x;

View File

@@ -13,7 +13,7 @@ $if (!env::COMPILER_LIBC_AVAILABLE):
* is preserved.
* ====================================================
*/
fn double __sin(double x, double y, int iy) @extern("__sin") @weak
fn double __sin(double x, double y, int iy) @extern("__sin") @weak @nostrip
{
const S1 = -1.66666666666666324348e-01; /* 0xBFC55555, 0x55555549 */

View File

@@ -18,7 +18,7 @@ $if (!env::COMPILER_LIBC_AVAILABLE):
* ====================================================
*/
// |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]).
fn float __sindf(double x) @extern("__sindf") @weak
fn float __sindf(double x) @extern("__sindf") @weak @nostrip
{
const S1F = -0x15555554cbac77.0p-55; /* -0.166666666416265235595 */
const S2F = 0x111110896efbb2.0p-59; /* 0.0083333293858894631756 */

View File

@@ -29,7 +29,7 @@ const double[*] TAN_T = {
2.59073051863633712884e-05, /* 3EFB2A70, 74BF7AD4 */
};
fn double __tan(double x, double y, int odd) @extern("__tan") @weak
fn double __tan(double x, double y, int odd) @extern("__tan") @weak @nostrip
{
const double PIO4 = 7.85398163397448278999e-01; /* 3FE921FB, 54442D18 */
const double PIO4LO = 3.06161699786838301793e-17; /* 3C81A626, 33145C07 */

View File

@@ -27,7 +27,7 @@ const double[*] TANDF = {
0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */
};
fn float __tandf(double x, int odd) @extern("__tandf") @weak
fn float __tandf(double x, int odd) @extern("__tandf") @weak @nostrip
{
double z = x * x;
/*

View File

@@ -30,7 +30,7 @@ const double[*] AT @private = {
1.62858201153657823623e-02, /* 0x3F90AD3A, 0xE322DA11 */
};
fn double _atan(double x) @weak @extern("atan")
fn double _atan(double x) @weak @extern("atan") @nostrip
{
int id @noinit;
uint ix = x.high_word();
@@ -113,7 +113,7 @@ const float[*] ATF @private = {
6.1687607318e-02,
};
fn float _atanf(float x) @weak @extern("atanf")
fn float _atanf(float x) @weak @extern("atanf") @nostrip
{
int id @noinit;
uint ix = x.word();
@@ -186,7 +186,7 @@ macro void extract_words(double d, uint* hi, uint* lo) @private
*lo = (uint)rep;
}
fn double _atan2(double y, double x) @weak @extern("atan2")
fn double _atan2(double y, double x) @weak @extern("atan2") @nostrip
{
if (math::is_nan(x) || math::is_nan(y)) return x + y;
@@ -257,7 +257,7 @@ fn double _atan2(double y, double x) @weak @extern("atan2")
const float PI_F @private = 3.1415927410e+00; /* 0x40490fdb */
const float PI_LO_F @private = -8.7422776573e-08; /* 0xb3bbbd2e */
fn float _atan2f(float y, float x) @weak @extern("atan2f")
fn float _atan2f(float y, float x) @weak @extern("atan2f") @nostrip
{
if (math::is_nan(x) || math::is_nan(y)) return x + y;
uint ix = bitcast(x, uint);

View File

@@ -2,7 +2,7 @@ module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE):
fn double _ceil(double x) @weak @extern("ceil")
fn double _ceil(double x) @weak @extern("ceil") @nostrip
{
ulong ui = bitcast(x, ulong);
int e = (int)((ui >> 52) & 0x7ff);
@@ -19,7 +19,7 @@ fn double _ceil(double x) @weak @extern("ceil")
}
fn float _ceilf(float x) @weak @extern("ceilf")
fn float _ceilf(float x) @weak @extern("ceilf") @nostrip
{
uint u = bitcast(x, uint);
int e = (int)((u >> 23) & 0xff) - 0x7f;

View File

@@ -2,7 +2,7 @@ module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE):
fn float _cosf(float x) @extern("cosf") @weak
fn float _cosf(float x) @extern("cosf") @weak @nostrip
{
uint ix = bitcast(x, uint);
uint sign = ix >> 31;
@@ -54,7 +54,7 @@ fn float _cosf(float x) @extern("cosf") @weak
* ====================================================
*/
fn double _cos(double x) @extern("cos") @weak
fn double _cos(double x) @extern("cos") @weak @nostrip
{
// High word of x.
uint ix = (uint)(bitcast(x, ulong) >> 32);

View File

@@ -5,7 +5,7 @@ $if (!env::COMPILER_LIBC_AVAILABLE):
macro uint _top12f(float x) @private => bitcast(x, uint) >> 20;
fn float _exp2f(float x) @extern("exp2f") @weak
fn float _exp2f(float x) @extern("exp2f") @weak @nostrip
{
double xd = x;
uint abstop = _top12f(x) & 0x7ff;
@@ -82,7 +82,7 @@ macro uint _top12d(double x) @private
return (uint)(bitcast(x, ulong) >> 52);
}
fn double _exp2(double x) @extern("exp2") @weak
fn double _exp2(double x) @extern("exp2") @weak @nostrip
{
uint abstop = _top12d(x) & 0x7ff;
ulong u = bitcast(x, ulong);

View File

@@ -2,7 +2,7 @@ module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE):
fn double _floor(double x) @weak @extern("floor")
fn double _floor(double x) @weak @extern("floor") @nostrip
{
ulong ui = bitcast(x, ulong);
int e = (int)((ui >> 52) & 0x7ff);
@@ -19,7 +19,7 @@ fn double _floor(double x) @weak @extern("floor")
}
fn float _floorf(float x) @weak @extern("floorf")
fn float _floorf(float x) @weak @extern("floorf") @nostrip
{
uint u = bitcast(x, uint);
int e = (int)((u >> 23) & 0xff) - 0x7f;

View File

@@ -2,12 +2,12 @@ module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE):
fn float powf_broken(float x, float f) @extern("powf") @weak
fn float powf_broken(float x, float f) @extern("powf") @weak @nostrip
{
unreachable("'powf' not supported");
}
fn double pow_broken(double x, double y) @extern("pow") @weak
fn double pow_broken(double x, double y) @extern("pow") @weak @nostrip
{
unreachable("'pow' not supported");
}

View File

@@ -2,7 +2,7 @@ module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE):
fn double _round(double x) @extern("round") @weak
fn double _round(double x) @extern("round") @weak @nostrip
{
ulong u = bitcast(x, ulong);
int e = (int)((u >> 52) & 0x7ff);
@@ -28,7 +28,7 @@ fn double _round(double x) @extern("round") @weak
return y;
}
fn float _roundf(float x) @extern("roundf") @weak
fn float _roundf(float x) @extern("roundf") @weak @nostrip
{
uint u = bitcast(x, uint);
int e = (u >> 23) & 0xff;

View File

@@ -2,7 +2,7 @@ module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE):
fn double _scalbn(double x, int n) @weak @extern("scalbn")
fn double _scalbn(double x, int n) @weak @extern("scalbn") @nostrip
{
switch
{

View File

@@ -18,7 +18,7 @@ $if (!env::COMPILER_LIBC_AVAILABLE):
* ====================================================
*/
fn float _sinf(float x) @weak @extern("sinf")
fn float _sinf(float x) @weak @extern("sinf") @nostrip
{
uint ix = bitcast(x, uint);
int sign = ix >> 31;
@@ -87,7 +87,7 @@ fn float _sinf(float x) @weak @extern("sinf")
* ====================================================
*/
fn double sin(double x) @extern("sin") @weak
fn double sin(double x) @extern("sin") @weak @nostrip
{
// High word of x.
uint ix = (uint)(bitcast(x, ulong) >> 32);

View File

@@ -18,7 +18,7 @@ $if (!env::COMPILER_LIBC_AVAILABLE):
* ====================================================
*/
fn void sincosf(float x, float *sin, float *cos) @extern("sincosf") @weak
fn void sincosf(float x, float *sin, float *cos) @extern("sincosf") @weak @nostrip
{
uint ix = bitcast(x, uint);
@@ -107,7 +107,7 @@ fn void sincosf(float x, float *sin, float *cos) @extern("sincosf") @weak
}
fn void sincos(double x, double *sin, double *cos) @extern("sincos") @weak
fn void sincos(double x, double *sin, double *cos) @extern("sincos") @weak @nostrip
{
// High word of x.
uint ix = (uint)(bitcast(x, ulong) >> 32);

View File

@@ -14,7 +14,7 @@ $if (!env::COMPILER_LIBC_AVAILABLE):
* ====================================================
*/
fn double tan(double x) @extern("tan") @weak
fn double tan(double x) @extern("tan") @weak @nostrip
{
uint ix = (uint)(bitcast(x, ulong) >> 32);
ix &= 0x7fffffff;
@@ -59,7 +59,7 @@ fn double tan(double x) @extern("tan") @weak
* ====================================================
*/
fn float tanf(float x) @extern("tanf") @weak
fn float tanf(float x) @extern("tanf") @weak @nostrip
{
uint ix = bitcast(x, uint);
uint sign = ix >> 31;

View File

@@ -2,7 +2,7 @@ module std::math::nolibc::trig;
$if (!env::COMPILER_LIBC_AVAILABLE):
fn double sincos_broken(double x) @extern("sincos") @weak
fn double sincos_broken(double x) @extern("sincos") @weak @nostrip
{
unreachable("'sinccos' not supported");
}

View File

@@ -2,7 +2,7 @@ module std::math::nolibc;
$if (!env::COMPILER_LIBC_AVAILABLE):
fn double _trunc(double x) @weak @extern("trunc")
fn double _trunc(double x) @weak @extern("trunc") @nostrip
{
ulong i = bitcast(x, ulong);
int e = (int)((i >> 52) & 0x7ff) - 0x3ff + 12;
@@ -15,7 +15,7 @@ fn double _trunc(double x) @weak @extern("trunc")
return bitcast(i, double);
}
fn float _truncf(float x) @weak @extern("truncf")
fn float _truncf(float x) @weak @extern("truncf") @nostrip
{
uint i = bitcast(x, uint);
int e = (int)((i >> 23) & 0xff) - 0x7f + 9;