make dyarith array-array dispatch its own function

This commit is contained in:
dzaima 2022-09-01 22:22:13 +03:00
parent bd04e38a5e
commit 1b8bd0707e
4 changed files with 83 additions and 107 deletions

View File

@ -255,7 +255,7 @@ static f64 pfmod(f64 a, f64 b) {
case el_f64: { SI_AS_I(NAME,f64,x,asBad) } \
case el_c8: case el_c16: case el_c32: case el_B:; /*fallthrough*/ \
} asBad:;
#define SI_AA(N) return do_dyArith(&N##DyTable, w, x);
#define SI_AA(N) return dyArith_AA(&N##DyTableAA, w, x);
#define IFN_SINGELI(X)
#else
#define SI_AA NO_SI_AA

View File

@ -285,9 +285,8 @@ B internalTemp_c1(B t, B x) {
#endif
return x;
}
#if !SINGELI
B internalTemp_c2(B t, B w, B x) { dec(w); return x; }
#endif
B heapDump_c1(B t, B x) {
cbqn_heapDump();

View File

@ -41,31 +41,25 @@ char* execAA_repr(u8 ex) {
#endif
typedef struct FnInfo {
typedef struct FnInfoAA {
union { CheckedFn cFn; UncheckedFn uFn; };
u8 ex1, ex2; // ExecAA
u8 type; // t_*; unused for u_call_bit
u8 width; // width in bytes; unused for u_call_bit
} FnInfo;
} FnInfoAA;
typedef struct EntAA {
FnInfo a, b;
FnInfoAA a, b;
} EntAA;
typedef struct DyTable {
typedef struct DyTableAA {
EntAA entsAA[8*8]; // one for each instruction
BBB2B mainFn;
char* repr;
} DyTable;
} DyTableAA;
NOINLINE B do_dyArith(DyTable* table, B w, B x) {
B r;
if (1 || isArr(w)) {
u8 we = TI(w, elType);
if (we==el_B) goto rec;
if (1 || isArr(x)) {
u8 xe = TI(x, elType);
if (xe==el_B) goto rec;
NOINLINE B dyArith_AA(DyTableAA* table, B w, B x) {
u8 we = TI(w, elType); if (we==el_B) goto rec;
u8 xe = TI(x, elType); if (xe==el_B) goto rec;
ur wr = RNK(w);
ur xr = RNK(x);
if (wr!=xr || !eqShPart(SH(w), SH(x), wr)) goto rec;
@ -74,11 +68,11 @@ NOINLINE B do_dyArith(DyTable* table, B w, B x) {
EntAA* e = &table->entsAA[we*8 + xe];
newEnt:
FnInfo* fn = &e->a;
FnInfoAA* fn = &e->a;
newFn:
u8 ex = fn->ex1;
newEx:
B t;
B r, t;
#if ARITH_DEBUG
printf("opcode %d / %s\n", ex, execAA_repr(ex));
#endif
@ -142,18 +136,6 @@ NOINLINE B do_dyArith(DyTable* table, B w, B x) {
}
case fail: goto rec;
}
} else {
goto rec;
}
} else {
if (isArr(x)) {
u8 xe = TI(x, elType);
if (xe==el_B) goto rec;
goto rec;
} else { // TODO decide if this is even a case that needs to be handled here
return table->mainFn(w, w, x);
}
}
rec:
return arith_recd(table->mainFn, w, x);
@ -174,8 +156,3 @@ static void stileAAu_f64_f64_f64(u8* r, u8* w, u8* x, u64 len) { for (u64 i = 0;
static void logAAu_f64_f64_f64(u8* r, u8* w, u8* x, u64 len) { for (u64 i = 0; i < len; i++) ((f64*)r)[i] = log(((f64*)x)[i])/log(((f64*)w)[i]); }
#include "../gen/arTables.c"
B internalTemp_c2(B t, B w, B x) {
return do_dyArith(&addDyTable, w, x);
}

View File

@ -107,7 +107,7 @@ Make ← {𝕊ns:
cSrc
"B ", cbqn, "_c2(B,B,B);", nl
"static DyTable ", cbqn,"DyTable = {", nl
"static DyTableAA ", cbqn,"DyTableAA = {", nl
" .entsAA = {", nl
{ instrs, wexe:
{