History

arm64: Implement TOK_NEG for floats natively

Aleksi Hannula committed 9 months ago

Commit c39eaf11 parent 1cb0a3d4 files · +44 −1Browse files

Unified · Split

4 files
  1. arm64-gen.c +31 −0
  2. lib/lib-arm64.c +11 −0
  3. tccgen.c +1 −1
  4. tcctok.h +1 −0
arm64-gen.c+31−0
@@ -1849,6 +1849,37 @@ ST_FUNC void gen_opf(int op) · 1848 unmodified lines
1849{1849{
1850 uint32_t x, a, b, dbl;1850 uint32_t x, a, b, dbl;
1851 1851
1852 if (op == TOK_NEG) {
1853 switch (vtop[0].type.t & VT_BTYPE) {
1854 case VT_LDOUBLE:
1855 vpush_helper_func(TOK___negtf2);
1856 vrott(2);
1857 gfunc_call(1);
1858 vpushi(0);
1859 vtop->type.t = VT_LDOUBLE;
1860 vtop->r = REG_FRET;
1861 break;
1862
1863 case VT_FLOAT:
1864 case VT_DOUBLE:
1865 gv(RC_FLOAT);
1866 dbl = vtop[0].type.t == VT_DOUBLE;
1867
1868 a = fltr(vtop[0].r);
1869 vtop--;
1870 x = get_reg(RC_FLOAT);
1871 vtop++;
1872 vtop[0].r = x;
1873 x = fltr(x);
1874
1875 o(0x1e214000 | dbl << 22 | x | a << 5);
1876 break;
1877 default:
1878 assert(0);
1879 }
1880 return;
1881 }
1882
1852 if (vtop[0].type.t == VT_LDOUBLE) {1883 if (vtop[0].type.t == VT_LDOUBLE) {
1853 CType type = vtop[0].type;1884 CType type = vtop[0].type;
1854 int func = 0;1885 int func = 0;
lib/lib-arm64.c+11−0
@@ -373,6 +373,17 @@ long double __divtf3(long double fa, long double fb) · 372 unmodified lines
373 return f3_round(x_sgn, x_exp, x);373 return f3_round(x_sgn, x_exp, x);
374}374}
375 375
376long double __negtf2(long double f)
377{
378 u128_t a;
379
380 memcpy(&a, &f, 16);
381 a.x1 ^= 1UL << 63;
382 memcpy(&f, &a, 16);
383
384 return f;
385}
386
376long double __extendsftf2(float f)387long double __extendsftf2(float f)
377{388{
378 long double fx;389 long double fx;
tccgen.c+1−1
@@ -2504,7 +2504,7 @@ static void gen_opic(int op) · 2503 unmodified lines
2504 }2504 }
2505}2505}
2506 2506
2507#if defined TCC_TARGET_X86_64 || defined TCC_TARGET_I3862507#if defined TCC_TARGET_X86_64 || defined TCC_TARGET_I386 || defined TCC_TARGET_ARM64
2508# define gen_negf gen_opf2508# define gen_negf gen_opf
2509#elif defined TCC_TARGET_ARM2509#elif defined TCC_TARGET_ARM
2510void gen_negf(int op)2510void gen_negf(int op)
tcctok.h+1−0
@@ -316,6 +316,7 @@ · 315 unmodified lines
316 DEF(TOK___extenddftf2, "__extenddftf2")316 DEF(TOK___extenddftf2, "__extenddftf2")
317 DEF(TOK___trunctfsf2, "__trunctfsf2")317 DEF(TOK___trunctfsf2, "__trunctfsf2")
318 DEF(TOK___trunctfdf2, "__trunctfdf2")318 DEF(TOK___trunctfdf2, "__trunctfdf2")
319 DEF(TOK___negtf2, "__negtf2")
319 DEF(TOK___fixtfsi, "__fixtfsi")320 DEF(TOK___fixtfsi, "__fixtfsi")
320 DEF(TOK___fixtfdi, "__fixtfdi")321 DEF(TOK___fixtfdi, "__fixtfdi")
321 DEF(TOK___fixunstfsi, "__fixunstfsi")322 DEF(TOK___fixunstfsi, "__fixunstfsi")

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t