mirror of
https://github.com/TinyCC/tinycc.git
synced 2026-03-27 05:29:52 +00:00
arm64: Implement TOK_NEG for floats natively
This commit is contained in:
31
arm64-gen.c
31
arm64-gen.c
@@ -1849,6 +1849,37 @@ ST_FUNC void gen_opf(int op)
|
||||
{
|
||||
uint32_t x, a, b, dbl;
|
||||
|
||||
if (op == TOK_NEG) {
|
||||
switch (vtop[0].type.t & VT_BTYPE) {
|
||||
case VT_LDOUBLE:
|
||||
vpush_helper_func(TOK___negtf2);
|
||||
vrott(2);
|
||||
gfunc_call(1);
|
||||
vpushi(0);
|
||||
vtop->type.t = VT_LDOUBLE;
|
||||
vtop->r = REG_FRET;
|
||||
break;
|
||||
|
||||
case VT_FLOAT:
|
||||
case VT_DOUBLE:
|
||||
gv(RC_FLOAT);
|
||||
dbl = vtop[0].type.t == VT_DOUBLE;
|
||||
|
||||
a = fltr(vtop[0].r);
|
||||
vtop--;
|
||||
x = get_reg(RC_FLOAT);
|
||||
vtop++;
|
||||
vtop[0].r = x;
|
||||
x = fltr(x);
|
||||
|
||||
o(0x1e214000 | dbl << 22 | x | a << 5);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (vtop[0].type.t == VT_LDOUBLE) {
|
||||
CType type = vtop[0].type;
|
||||
int func = 0;
|
||||
|
||||
@@ -373,6 +373,17 @@ long double __divtf3(long double fa, long double fb)
|
||||
return f3_round(x_sgn, x_exp, x);
|
||||
}
|
||||
|
||||
long double __negtf2(long double f)
|
||||
{
|
||||
u128_t a;
|
||||
|
||||
memcpy(&a, &f, 16);
|
||||
a.x1 ^= 1UL << 63;
|
||||
memcpy(&f, &a, 16);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
long double __extendsftf2(float f)
|
||||
{
|
||||
long double fx;
|
||||
|
||||
2
tccgen.c
2
tccgen.c
@@ -2504,7 +2504,7 @@ static void gen_opic(int op)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined TCC_TARGET_X86_64 || defined TCC_TARGET_I386
|
||||
#if defined TCC_TARGET_X86_64 || defined TCC_TARGET_I386 || defined TCC_TARGET_ARM64
|
||||
# define gen_negf gen_opf
|
||||
#elif defined TCC_TARGET_ARM
|
||||
void gen_negf(int op)
|
||||
|
||||
Reference in New Issue
Block a user