skint/i.h

598 lines
51 KiB
C
Raw Normal View History

2023-02-28 06:31:08 +01:00
/* i.h -- instructions */
#ifndef glue
#define glue(a, b) a##b
#endif
#ifndef AUTOGL
#define AUTOGL NULL
#endif
#ifndef INLINED
#define INLINED ""
#endif
#if defined(VM_GEN_DEFGLOBAL)
#define declare_instruction(name, enc, etyp, igname, arity, lcode) \
declare_instruction_global(name)
#define declare_instrshadow(name, enc, etyp, igname, arity, lcode)
#define declare_integrable(name, enc, etyp, igname, arity, lcode)
#elif defined(VM_GEN_ENCTABLE)
#define declare_instruction(name, enc, etyp, igname, arity, lcode) \
declare_enctable_entry(name, enc, etyp)
#define declare_instrshadow(name, enc, etyp, igname, arity, lcode) \
declare_enctable_entry(name, enc, etyp)
#define declare_integrable(name, enc, etyp, igname, arity, lcode)
#elif defined(VM_GEN_INTGTABLE)
#define declare_instruction(name, enc, etyp, igname, arity, lcode) \
declare_intgtable_entry(enc, igname, arity, lcode)
#define declare_instrshadow(name, enc, etyp, igname, arity, lcode) \
declare_intgtable_entry(enc, igname, arity, lcode)
#define declare_integrable(name, enc, etyp, igname, arity, lcode) \
declare_intgtable_entry(enc, igname, arity, lcode)
#else /* regular include */
#define declare_instruction(name, enc, etyp, igname, arity, lcode) \
extern obj glue(cx_ins_2D, name);
#define declare_instrshadow(name, enc, etyp, igname, arity, lcode)
#define declare_integrable(name, enc, etyp, igname, arity, lcode)
extern obj vmcases[]; /* vm host */
#endif
/* basic vm machinery: generated by compiler and used in hand-coded functions */
2023-03-26 23:10:51 +02:00
declare_instruction(halt, NULL, 0, NULL, 0, NULL)
declare_instruction(litf, "f", 0, NULL, 0, NULL)
declare_instruction(litt, "t", 0, NULL, 0, NULL)
declare_instruction(litn, "n", 0, NULL, 0, NULL)
declare_instruction(lit, "'", 1, NULL, 0, NULL)
declare_instruction(sref, ".", 1, NULL, 0, NULL)
declare_instruction(dref, ":", 1, NULL, 0, NULL)
declare_instruction(gref, "@", 'g', NULL, 0, NULL)
declare_instruction(iref, "^", 0, NULL, 0, NULL)
declare_instruction(iset, "^!", 0, NULL, 0, NULL)
declare_instruction(dclose, "&", 'd', NULL, 0, NULL)
declare_instruction(sbox, "#", 1, NULL, 0, NULL)
declare_instruction(br, NULL, 'b', NULL, 0, NULL)
declare_instruction(brnot, "?", 'b', NULL, 0, NULL)
declare_instruction(brt, "~?", 'b', NULL, 0, NULL)
declare_instruction(andbo, ";", 'a', NULL, 0, NULL)
declare_instruction(sseti, ".!", 1, NULL, 0, NULL)
declare_instruction(dseti, ":!", 1, NULL, 0, NULL)
declare_instruction(gloc, "`", 'g', NULL, 0, NULL)
declare_instruction(gset, "@!", 'g', NULL, 0, NULL)
declare_instruction(appl, "K3", 0, NULL, 0, NULL)
declare_instruction(cwmv, "K4", 0, NULL, 0, NULL)
declare_instruction(rcmv, "K5", 0, NULL, 0, NULL)
declare_instruction(sdmv, "K6", 0, NULL, 0, NULL)
declare_instruction(lck, "k", 1, NULL, 0, NULL)
declare_instruction(lck0, "k0", 0, NULL, 0, NULL)
declare_instruction(rck, "k!", 0, NULL, 0, NULL)
declare_instruction(wck, "w", 0, NULL, 0, NULL)
declare_instruction(wckr, "w!", 0, NULL, 0, NULL)
2023-03-30 19:17:25 +02:00
declare_instruction(dys, "y", 0, NULL, 0, NULL)
declare_instruction(setdys, "sy", 0, NULL, 0, NULL)
2023-03-26 23:10:51 +02:00
declare_instruction(save, "$", 's', NULL, 0, NULL)
declare_instruction(push, ",", 0, NULL, 0, NULL)
declare_instruction(jdceq, "|", 2, NULL, 0, NULL)
declare_instruction(jdcge, "|!", 2, NULL, 0, NULL)
declare_instruction(jdref, "|!0", 1, NULL, 0, NULL)
declare_instruction(call, "[0", 1, NULL, 0, NULL)
declare_instruction(scall, "[", 2, NULL, 0, NULL)
declare_instruction(return, "]0", 0, NULL, 0, NULL)
declare_instruction(sreturn, "]", 1, NULL, 0, NULL)
declare_instruction(adrop, "_", 1, NULL, 0, NULL)
declare_instruction(pop, "_!", 0, NULL, 0, NULL)
declare_instruction(atest, "%", 1, NULL, 0, NULL)
declare_instruction(shrarg, "%!", 1, NULL, 0, NULL)
declare_instruction(aerr, "%%", 0, NULL, 0, NULL)
/* popular instruction combos */
2023-03-26 23:10:51 +02:00
declare_instruction(shlit, ",'", 1, NULL, 0, NULL)
declare_instruction(shi0, ",'0", 0, NULL, 0, NULL)
declare_instruction(pushlitf, "f,", 0, NULL, 0, NULL)
declare_instruction(pushlitt, "t,", 0, NULL, 0, NULL)
declare_instruction(pushlitn, "n,", 0, NULL, 0, NULL)
declare_instruction(lit0, "'0", 0, NULL, 0, NULL)
declare_instruction(lit1, "'1", 0, NULL, 0, NULL)
declare_instruction(lit2, "'2", 0, NULL, 0, NULL)
declare_instruction(lit3, "'3", 0, NULL, 0, NULL)
declare_instruction(lit4, "'4", 0, NULL, 0, NULL)
declare_instruction(lit5, "'5", 0, NULL, 0, NULL)
declare_instruction(lit6, "'6", 0, NULL, 0, NULL)
declare_instruction(lit7, "'7", 0, NULL, 0, NULL)
declare_instruction(lit8, "'8", 0, NULL, 0, NULL)
declare_instruction(lit9, "'9", 0, NULL, 0, NULL)
declare_instruction(pushlit0, "'0,", 0, NULL, 0, NULL)
declare_instruction(pushlit1, "'1,", 0, NULL, 0, NULL)
declare_instruction(pushlit2, "'2,", 0, NULL, 0, NULL)
declare_instruction(pushlit3, "'3,", 0, NULL, 0, NULL)
declare_instruction(pushlit4, "'4,", 0, NULL, 0, NULL)
declare_instruction(pushlit5, "'5,", 0, NULL, 0, NULL)
declare_instruction(pushlit6, "'6,", 0, NULL, 0, NULL)
declare_instruction(pushlit7, "'7,", 0, NULL, 0, NULL)
declare_instruction(pushlit8, "'8,", 0, NULL, 0, NULL)
declare_instruction(pushlit9, "'9,", 0, NULL, 0, NULL)
declare_instruction(sref0, ".0", 0, NULL, 0, NULL)
declare_instruction(sref1, ".1", 0, NULL, 0, NULL)
declare_instruction(sref2, ".2", 0, NULL, 0, NULL)
declare_instruction(sref3, ".3", 0, NULL, 0, NULL)
declare_instruction(sref4, ".4", 0, NULL, 0, NULL)
declare_instruction(sref5, ".5", 0, NULL, 0, NULL)
declare_instruction(sref6, ".6", 0, NULL, 0, NULL)
declare_instruction(sref7, ".7", 0, NULL, 0, NULL)
declare_instruction(sref8, ".8", 0, NULL, 0, NULL)
declare_instruction(sref9, ".9", 0, NULL, 0, NULL)
declare_instruction(pushsref0, ".0,", 0, NULL, 0, NULL)
declare_instruction(pushsref1, ".1,", 0, NULL, 0, NULL)
declare_instruction(pushsref2, ".2,", 0, NULL, 0, NULL)
declare_instruction(pushsref3, ".3,", 0, NULL, 0, NULL)
declare_instruction(pushsref4, ".4,", 0, NULL, 0, NULL)
declare_instruction(pushsref5, ".5,", 0, NULL, 0, NULL)
declare_instruction(pushsref6, ".6,", 0, NULL, 0, NULL)
declare_instruction(pushsref7, ".7,", 0, NULL, 0, NULL)
declare_instruction(pushsref8, ".8,", 0, NULL, 0, NULL)
declare_instruction(pushsref9, ".9,", 0, NULL, 0, NULL)
declare_instruction(srefi0, ".0^", 0, NULL, 0, NULL)
declare_instruction(srefi1, ".1^", 0, NULL, 0, NULL)
declare_instruction(srefi2, ".2^", 0, NULL, 0, NULL)
declare_instruction(srefi3, ".3^", 0, NULL, 0, NULL)
declare_instruction(srefi4, ".4^", 0, NULL, 0, NULL)
declare_instruction(pushsrefi0, ".0^,", 0, NULL, 0, NULL)
declare_instruction(pushsrefi1, ".1^,", 0, NULL, 0, NULL)
declare_instruction(pushsrefi2, ".2^,", 0, NULL, 0, NULL)
declare_instruction(pushsrefi3, ".3^,", 0, NULL, 0, NULL)
declare_instruction(pushsrefi4, ".4^,", 0, NULL, 0, NULL)
declare_instruction(dref0, ":0", 0, NULL, 0, NULL)
declare_instruction(dref1, ":1", 0, NULL, 0, NULL)
declare_instruction(dref2, ":2", 0, NULL, 0, NULL)
declare_instruction(dref3, ":3", 0, NULL, 0, NULL)
declare_instruction(dref4, ":4", 0, NULL, 0, NULL)
declare_instruction(pushdref0, ":0,", 0, NULL, 0, NULL)
declare_instruction(pushdref1, ":1,", 0, NULL, 0, NULL)
declare_instruction(pushdref2, ":2,", 0, NULL, 0, NULL)
declare_instruction(pushdref3, ":3,", 0, NULL, 0, NULL)
declare_instruction(pushdref4, ":4,", 0, NULL, 0, NULL)
declare_instruction(drefi0, ":0^", 0, NULL, 0, NULL)
declare_instruction(drefi1, ":1^", 0, NULL, 0, NULL)
declare_instruction(drefi2, ":2^", 0, NULL, 0, NULL)
declare_instruction(drefi3, ":3^", 0, NULL, 0, NULL)
declare_instruction(drefi4, ":4^", 0, NULL, 0, NULL)
declare_instruction(pushdrefi0, ":0^,", 0, NULL, 0, NULL)
declare_instruction(pushdrefi1, ":1^,", 0, NULL, 0, NULL)
declare_instruction(pushdrefi2, ":2^,", 0, NULL, 0, NULL)
declare_instruction(pushdrefi3, ":3^,", 0, NULL, 0, NULL)
declare_instruction(pushdrefi4, ":4^,", 0, NULL, 0, NULL)
declare_instruction(call0, "[00", 0, NULL, 0, NULL)
declare_instruction(call1, "[01", 0, NULL, 0, NULL)
declare_instruction(call2, "[02", 0, NULL, 0, NULL)
declare_instruction(call3, "[03", 0, NULL, 0, NULL)
declare_instruction(call4, "[04", 0, NULL, 0, NULL)
declare_instruction(scall1, "[1", 1, NULL, 0, NULL)
declare_instruction(scall10, "[10", 0, NULL, 0, NULL)
declare_instruction(scall11, "[11", 0, NULL, 0, NULL)
declare_instruction(scall12, "[12", 0, NULL, 0, NULL)
declare_instruction(scall13, "[13", 0, NULL, 0, NULL)
declare_instruction(scall14, "[14", 0, NULL, 0, NULL)
declare_instruction(scall2, "[2", 1, NULL, 0, NULL)
declare_instruction(scall20, "[20", 0, NULL, 0, NULL)
declare_instruction(scall21, "[21", 0, NULL, 0, NULL)
declare_instruction(scall22, "[22", 0, NULL, 0, NULL)
declare_instruction(scall23, "[23", 0, NULL, 0, NULL)
declare_instruction(scall24, "[24", 0, NULL, 0, NULL)
declare_instruction(scall3, "[3", 1, NULL, 0, NULL)
declare_instruction(scall30, "[30", 0, NULL, 0, NULL)
declare_instruction(scall31, "[31", 0, NULL, 0, NULL)
declare_instruction(scall32, "[32", 0, NULL, 0, NULL)
declare_instruction(scall33, "[33", 0, NULL, 0, NULL)
declare_instruction(scall34, "[34", 0, NULL, 0, NULL)
declare_instruction(scall4, "[4", 1, NULL, 0, NULL)
declare_instruction(scall40, "[40", 0, NULL, 0, NULL)
declare_instruction(scall41, "[41", 0, NULL, 0, NULL)
declare_instruction(scall42, "[42", 0, NULL, 0, NULL)
declare_instruction(scall43, "[43", 0, NULL, 0, NULL)
declare_instruction(scall44, "[44", 0, NULL, 0, NULL)
declare_instruction(sreturn1, "]1", 0, NULL, 0, NULL)
declare_instruction(sreturn2, "]2", 0, NULL, 0, NULL)
declare_instruction(sreturn3, "]3", 0, NULL, 0, NULL)
declare_instruction(sreturn4, "]4", 0, NULL, 0, NULL)
declare_instruction(atest0, "%0", 0, NULL, 0, NULL)
declare_instruction(atest1, "%1", 0, NULL, 0, NULL)
declare_instruction(atest2, "%2", 0, NULL, 0, NULL)
declare_instruction(atest3, "%3", 0, NULL, 0, NULL)
declare_instruction(atest4, "%4", 0, NULL, 0, NULL)
/* declare_instruction(brnotlt, "<?", 'b', NULL, 0, NULL) */
2023-03-26 23:10:51 +02:00
declare_instruction(pushsub, "-,", 0, NULL, 0, NULL)
2023-02-28 06:31:08 +01:00
/* type checks: integrables but no globals */
2023-03-26 23:10:51 +02:00
declare_instruction(ckp, "%p", 0, "%ckp", '1', INLINED)
declare_instruction(ckl, "%l", 0, "%ckl", '1', INLINED)
declare_instruction(ckv, "%v", 0, "%ckv", '1', INLINED)
declare_instruction(ckc, "%c", 0, "%ckc", '1', INLINED)
declare_instruction(cks, "%s", 0, "%cks", '1', INLINED)
declare_instruction(cki, "%i", 0, "%cki", '1', INLINED)
declare_instruction(ckj, "%j", 0, "%ckj", '1', INLINED)
declare_instruction(ckn, "%n", 0, "%ckn", '1', INLINED)
declare_instruction(ckk, "%k", 0, "%ckk", '1', INLINED)
declare_instruction(cky, "%y", 0, "%cky", '1', INLINED)
declare_instruction(ckr, "%r", 0, "%ckr", '1', INLINED)
declare_instruction(ckw, "%w", 0, "%ckw", '1', INLINED)
declare_instruction(ckx, "%x", 0, "%ckx", '1', INLINED)
declare_instruction(ckz, "%z", 0, "%ckz", '1', INLINED)
/* built-in procedures: integrables with globals */
declare_instruction(isq, "q", 0, "eq?", '2', AUTOGL)
declare_instruction(isv, "v", 0, "eqv?", '2', AUTOGL)
declare_instruction(ise, "e", 0, "equal?", '2', AUTOGL)
declare_instruction(box, "b", 0, "box", '1', AUTOGL)
declare_instruction(unbox, "z", 0, "unbox", '1', AUTOGL)
declare_instruction(setbox, "sz", 0, "set-box!", '2', AUTOGL)
declare_instruction(car, "a", 0, "car", '1', AUTOGL)
declare_instruction(setcar, "sa", 0, "set-car!", '2', AUTOGL)
declare_instruction(cdr, "d", 0, "cdr", '1', AUTOGL)
declare_instruction(setcdr, "sd", 0, "set-cdr!", '2', AUTOGL)
declare_instruction(caar, "aa", 0, "caar", '1', AUTOGL)
declare_instruction(cadr, "da", 0, "cadr", '1', AUTOGL)
declare_instruction(cdar, "ad", 0, "cdar", '1', AUTOGL)
declare_instruction(cddr, "dd", 0, "cddr", '1', AUTOGL)
declare_instruction(nullp, "u", 0, "null?", '1', AUTOGL)
declare_instruction(pairp, "p", 0, "pair?", '1', AUTOGL)
declare_instruction(cons, "c", 0, "cons", '2', AUTOGL)
declare_instruction(not, "~", 0, "not", '1', AUTOGL)
declare_instruction(izerop, "I=0", 0, "fxzero?", '1', AUTOGL)
declare_instruction(iposp, "I>0", 0, "fxpositive?", '1', AUTOGL)
declare_instruction(inegp, "I<0", 0, "fxnegative?", '1', AUTOGL)
declare_instruction(ievnp, "Ie", 0, "fxeven?", '1', AUTOGL)
declare_instruction(ioddp, "Io", 0, "fxodd?", '1', AUTOGL)
declare_instruction(iadd, "I+\0'0", 0, "fx+", 'p', AUTOGL)
declare_instruction(isub, "I-\0I-!", 0, "fx-", 'm', AUTOGL)
declare_instruction(imul, "I*\0'1", 0, "fx*", 'p', AUTOGL)
declare_instruction(idiv, "I/\0,'1I/", 0, "fx/", 'm', AUTOGL)
declare_instruction(iquo, "Iq", 0, "fxquotient", '2', AUTOGL)
declare_instruction(irem, "Ir", 0, "fxremainder", '2', AUTOGL)
declare_instruction(ilt, "I<", 0, "fx<?", 'c', AUTOGL)
declare_instruction(igt, "I>", 0, "fx>?", 'c', AUTOGL)
declare_instruction(ile, "I>!", 0, "fx<=?", 'c', AUTOGL)
declare_instruction(ige, "I<!", 0, "fx>=?", 'c', AUTOGL)
declare_instruction(ieq, "I=", 0, "fx=?", 'c', AUTOGL)
declare_instruction(ine, "I=!", 0, "fx!=?", '2', AUTOGL)
declare_instruction(imin, "In", 0, "fxmin", 'x', AUTOGL)
declare_instruction(imax, "Ix", 0, "fxmax", 'x', AUTOGL)
declare_instruction(ineg, "I-!", 0, "fxneg", '1', AUTOGL)
declare_instruction(iabs, "Ia", 0, "fxabs", '1', AUTOGL)
declare_instruction(itoj, "Ij", 0, "fixnum->flonum", '1', AUTOGL)
declare_instruction(fixp, "I0", 0, "fixnum?", '1', AUTOGL)
declare_instruction(imqu, "Il", 0, "fxmodquo", '2', AUTOGL)
declare_instruction(imlo, "Im", 0, "fxmodulo", '2', AUTOGL)
declare_instruction(ieuq, "I5", 0, "fxeucquo", '2', AUTOGL)
declare_instruction(ieur, "I6", 0, "fxeucrem", '2', AUTOGL)
declare_instruction(igcd, "Ig\0'0", 0, "fxgcd", 'p', AUTOGL)
declare_instruction(ipow, "Ip", 0, "fxexpt", '2', AUTOGL)
declare_instruction(isqrt, "It", 0, "fxsqrt", '1', AUTOGL)
declare_instruction(inot, "D0", 0, "fxnot", '1', AUTOGL)
declare_instruction(iand, "D1\0'(i-1)", 0, "fxand", 'p', AUTOGL)
declare_instruction(iior, "D2\0'0", 0, "fxior", 'p', AUTOGL)
declare_instruction(ixor, "D3\0'0", 0, "fxxor", 'p', AUTOGL)
declare_instruction(iasl, "D4", 0, "fxsll", '2', AUTOGL)
declare_instruction(iasr, "D5", 0, "fxsrl", '2', AUTOGL)
declare_instruction(jzerop, "J=0", 0, "flzero?", '1', AUTOGL)
declare_instruction(jposp, "J>0", 0, "flpositive?", '1', AUTOGL)
declare_instruction(jnegp, "J<0", 0, "flnegative?", '1', AUTOGL)
declare_instruction(jevnp, "Je", 0, "fleven?", '1', AUTOGL)
declare_instruction(joddp, "Jo", 0, "flodd?", '1', AUTOGL)
declare_instruction(jintp, "Jw", 0, "flinteger?", '1', AUTOGL)
declare_instruction(jnanp, "Ju", 0, "flnan?", '1', AUTOGL)
declare_instruction(jfinp, "Jf", 0, "flfinite?", '1', AUTOGL)
declare_instruction(jinfp, "Jh", 0, "flinfinite?", '1', AUTOGL)
declare_instruction(jadd, "J+\0'(j0)", 0, "fl+", 'p', AUTOGL)
declare_instruction(jsub, "J-\0J-!", 0, "fl-", 'm', AUTOGL)
declare_instruction(jmul, "J*\0'(j1)", 0, "fl*", 'p', AUTOGL)
declare_instruction(jdiv, "J/\0,'(j1)J/", 0, "fl/", 'm', AUTOGL)
declare_instruction(jquo, "Jq", 0, "flquotient", '2', AUTOGL)
declare_instruction(jrem, "Jr", 0, "flremainder", '2', AUTOGL)
declare_instruction(jlt, "J<", 0, "fl<?", 'c', AUTOGL)
declare_instruction(jgt, "J>", 0, "fl>?", 'c', AUTOGL)
declare_instruction(jle, "J>!", 0, "fl<=?", 'c', AUTOGL)
declare_instruction(jge, "J<!", 0, "fl>=?", 'c', AUTOGL)
declare_instruction(jeq, "J=", 0, "fl=?", 'c', AUTOGL)
declare_instruction(jne, "J=!", 0, "fl!=?", '2', AUTOGL)
declare_instruction(jmin, "Jn", 0, "flmin", 'x', AUTOGL)
declare_instruction(jmax, "Jx", 0, "flmax", 'x', AUTOGL)
declare_instruction(jneg, "J-!", 0, "flneg", '1', AUTOGL)
declare_instruction(jabs, "Ja", 0, "flabs", '1', AUTOGL)
declare_instruction(jgcd, "Jg\0'(j0)", 0, "flgcd", 'p', AUTOGL)
declare_instruction(jpow, "Jp", 0, "flexpt", '2', AUTOGL)
declare_instruction(jsqrt, "Jt", 0, "flsqrt", '1', AUTOGL)
declare_instruction(jtoi, "Ji", 0, "flonum->fixnum", '1', AUTOGL)
declare_instruction(jmqu, "Jl", 0, "flmodquo", '2', AUTOGL)
declare_instruction(jmlo, "Jm", 0, "flmodulo", '2', AUTOGL)
declare_instruction(jfloor, "Jb", 0, "flfloor", '1', AUTOGL)
declare_instruction(jceil, "Jc", 0, "flceiling", '1', AUTOGL)
declare_instruction(jtrunc, "Jk", 0, "fltruncate", '1', AUTOGL)
declare_instruction(jround, "Jd", 0, "flround", '1', AUTOGL)
declare_instruction(flop, "J0", 0, "flonum?", '1', AUTOGL)
declare_instruction(jexp, "J1", 0, "flexp", '1', AUTOGL)
declare_instruction(jlog, "J2\0f", 0, "fllog", 'b', AUTOGL)
declare_instruction(jsin, "J3", 0, "flsin", '1', AUTOGL)
declare_instruction(jcos, "J4", 0, "flcos", '1', AUTOGL)
declare_instruction(jtan, "J5", 0, "fltan", '1', AUTOGL)
declare_instruction(jasin, "J6", 0, "flasin", '1', AUTOGL)
declare_instruction(jacos, "J7", 0, "flacos", '1', AUTOGL)
declare_instruction(jatan, "J8\0f", 0, "flatan", 'b', AUTOGL)
declare_instruction(zerop, "=0", 0, "zero?", '1', AUTOGL)
declare_instruction(posp, ">0", 0, "positive?", '1', AUTOGL)
declare_instruction(negp, "<0", 0, "negative?", '1', AUTOGL)
declare_instruction(add, "+\0'0", 0, "+", 'p', AUTOGL)
declare_instruction(sub, "-\0-!", 0, "-", 'm', AUTOGL)
declare_instruction(mul, "*\0'1", 0, "*", 'p', AUTOGL)
declare_instruction(div, "/\0,'1/", 0, "/", 'm', AUTOGL)
declare_instruction(lt, "<", 0, "<", 'c', AUTOGL)
declare_instruction(gt, ">", 0, ">", 'c', AUTOGL)
declare_instruction(le, ">!", 0, "<=", 'c', AUTOGL)
declare_instruction(ge, "<!", 0, ">=", 'c', AUTOGL)
declare_instruction(eq, "=", 0, "=", 'c', AUTOGL)
declare_instruction(ne, "=!", 0, "!=", '2', AUTOGL)
declare_instruction(min, "Nn", 0, "min", 'x', AUTOGL)
declare_instruction(max, "Nx", 0, "max", 'x', AUTOGL)
declare_instruction(neg, "-!", 0, "neg", '1', AUTOGL)
declare_instruction(abs, "Na", 0, "abs", '1', AUTOGL)
declare_instruction(gcd, "Ng\0'0", 0, "gcd", 'p', AUTOGL)
declare_instruction(pow, "Np", 0, "expt", '2', AUTOGL)
declare_instruction(sqrt, "Nt", 0, "sqrt", '1', AUTOGL)
declare_instruction(mqu, "Nl", 0, "floor-quotient", '2', AUTOGL)
declare_instruction(mlo, "Nm", 0, "floor-remainder", '2', AUTOGL)
declare_instruction(quo, "Nq", 0, "truncate-quotient", '2', AUTOGL)
declare_instruction(rem, "Nr", 0, "truncate-remainder", '2', AUTOGL)
declare_instruction(nump, "N0", 0, "number?", '1', AUTOGL)
declare_instruction(exp, "N1", 0, "exp", '1', AUTOGL)
declare_instruction(log, "N2\0f", 0, "log", 'b', AUTOGL)
declare_instruction(sin, "N3", 0, "sin", '1', AUTOGL)
declare_instruction(cos, "N4", 0, "cos", '1', AUTOGL)
declare_instruction(tan, "N5", 0, "tan", '1', AUTOGL)
declare_instruction(asin, "N6", 0, "asin", '1', AUTOGL)
declare_instruction(acos, "N7", 0, "acos", '1', AUTOGL)
declare_instruction(atan, "N8\0f", 0, "atan", 'b', AUTOGL)
2023-03-30 23:02:22 +02:00
declare_instruction(ratp, "Nv", 0, "rational?", '1', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(intp, "Nw", 0, "integer?", '1', AUTOGL)
declare_instruction(nanp, "Nu", 0, "nan?", '1', AUTOGL)
declare_instruction(finp, "Nf", 0, "finite?", '1', AUTOGL)
declare_instruction(infp, "Nh", 0, "infinite?", '1', AUTOGL)
declare_instruction(evnp, "Ne", 0, "even?", '1', AUTOGL)
declare_instruction(oddp, "No", 0, "odd?", '1', AUTOGL)
declare_instruction(ntoi, "Ni", 0, "exact", '1', AUTOGL)
declare_instruction(ntoj, "Nj", 0, "inexact", '1', AUTOGL)
declare_instruction(floor, "Nb", 0, "floor", '1', AUTOGL)
declare_instruction(ceil, "Nc", 0, "ceiling", '1', AUTOGL)
declare_instruction(trunc, "Nk", 0, "truncate", '1', AUTOGL)
declare_instruction(round, "Nd", 0, "round", '1', AUTOGL)
declare_instruction(listp, "L0", 0, "list?", '1', AUTOGL)
declare_instruction(list, "l", 1, "list", '#', "%!0_!]0")
declare_instruction(lmk, "L2\0f", 0, "make-list", 'b', AUTOGL)
declare_instruction(llen, "g", 0, "length", '1', AUTOGL)
declare_instruction(lget, "L4", 0, "list-ref", '2', AUTOGL)
declare_instruction(lput, "L5", 0, "list-set!", '3', AUTOGL)
declare_instruction(lcat, "L6", 0, "list-cat", '2', AUTOGL)
declare_instruction(lcpy, "L7", 0, "list-copy", '1', AUTOGL)
declare_instruction(circp, "L9", 0, "circular?", '1', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(memq, "A0", 0, "memq", '2', AUTOGL)
declare_instruction(memv, "A1", 0, "memv", '2', AUTOGL)
declare_instruction(meme, "A2", 0, "meme", '2', AUTOGL)
declare_instruction(assq, "A3", 0, "assq", '2', AUTOGL)
declare_instruction(assv, "A4", 0, "assv", '2', AUTOGL)
declare_instruction(asse, "A5", 0, "asse", '2', AUTOGL)
declare_instruction(ltail, "A6", 0, "list-tail", '2', AUTOGL)
declare_instruction(lpair, "A7", 0, "last-pair", '1', AUTOGL)
declare_instruction(lrev, "A8", 0, "reverse", '1', AUTOGL)
declare_instruction(lrevi, "A9", 0, "reverse!", '1', AUTOGL)
declare_instruction(charp, "C0", 0, "char?", '1', AUTOGL)
declare_instruction(cwsp, "C1", 0, "char-whitespace?", '1', AUTOGL)
declare_instruction(clcp, "C2", 0, "char-lower-case?", '1', AUTOGL)
declare_instruction(cucp, "C3", 0, "char-upper-case?", '1', AUTOGL)
declare_instruction(calp, "C4", 0, "char-alphabetic?", '1', AUTOGL)
declare_instruction(cnup, "C5", 0, "char-numeric?", '1', AUTOGL)
declare_instruction(cupc, "Cu", 0, "char-upcase", '1', AUTOGL)
declare_instruction(cdnc, "Cd", 0, "char-downcase", '1', AUTOGL)
declare_instruction(cflc, "Cf", 0, "char-foldcase", '1', AUTOGL)
declare_instruction(cdgv, "Cv", 0, "digit-value", '1', AUTOGL)
declare_instruction(ccmp, "C-", 0, "char-cmp", '2', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(ceq, "C=", 0, "char=?", 'c', AUTOGL)
declare_instruction(clt, "C<", 0, "char<?", 'c', AUTOGL)
declare_instruction(cgt, "C>", 0, "char>?", 'c', AUTOGL)
declare_instruction(cle, "C>!", 0, "char<=?", 'c', AUTOGL)
declare_instruction(cge, "C<!", 0, "char>=?", 'c', AUTOGL)
declare_instruction(cicmp, "Ci-", 0, "char-ci-cmp", '2', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(cieq, "Ci=", 0, "char-ci=?", 'c', AUTOGL)
declare_instruction(cilt, "Ci<", 0, "char-ci<?", 'c', AUTOGL)
declare_instruction(cigt, "Ci>", 0, "char-ci>?", 'c', AUTOGL)
declare_instruction(cile, "Ci>!", 0, "char-ci<=?", 'c', AUTOGL)
declare_instruction(cige, "Ci<!", 0, "char-ci>=?", 'c', AUTOGL)
declare_instruction(strp, "S0", 0, "string?", '1', AUTOGL)
declare_instruction(str, "S1", 1, "string", '#', "%!0.0X3]1")
declare_instruction(smk, "S2\0'(c )", 0, "make-string", 'b', AUTOGL)
declare_instruction(slen, "S3", 0, "string-length", '1', AUTOGL)
declare_instruction(sget, "S4", 0, "string-ref", '2', AUTOGL)
declare_instruction(sput, "S5", 0, "string-set!", '3', AUTOGL)
declare_instruction(scat, "S6", 0, "string-cat", '2', AUTOGL)
declare_instruction(ssub, "S7", 0, "substring", '3', AUTOGL)
declare_instruction(spos, "S8", 0, "string-position", '2', AUTOGL)
declare_instruction(supc, "Su", 0, "string-upcase", '1', AUTOGL)
declare_instruction(sdnc, "Sd", 0, "string-downcase", '1', AUTOGL)
declare_instruction(sflc, "Sf", 0, "string-foldcase", '1', AUTOGL)
declare_instruction(scmp, "S-", 0, "string-cmp", '2', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(seq, "S=", 0, "string=?", 'c', AUTOGL)
declare_instruction(slt, "S<", 0, "string<?", 'c', AUTOGL)
declare_instruction(sgt, "S>", 0, "string>?", 'c', AUTOGL)
declare_instruction(sle, "S>!", 0, "string<=?", 'c', AUTOGL)
declare_instruction(sge, "S<!", 0, "string>=?", 'c', AUTOGL)
declare_instruction(sicmp, "Si-", 0, "string-ci-cmp", '2', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(sieq, "Si=", 0, "string-ci=?", 'c', AUTOGL)
declare_instruction(silt, "Si<", 0, "string-ci<?", 'c', AUTOGL)
declare_instruction(sigt, "Si>", 0, "string-ci>?", 'c', AUTOGL)
declare_instruction(sile, "Si>!", 0, "string-ci<=?", 'c', AUTOGL)
declare_instruction(sige, "Si<!", 0, "string-ci>=?", 'c', AUTOGL)
declare_instruction(vecp, "V0", 0, "vector?", '1', AUTOGL)
declare_instruction(vec, "V1", 1, "vector", '#', "%!0.0X1]1")
declare_instruction(vmk, "V2\0f", 0, "make-vector", 'b', AUTOGL)
declare_instruction(vlen, "V3", 0, "vector-length", '1', AUTOGL)
declare_instruction(vget, "V4", 0, "vector-ref", '2', AUTOGL)
declare_instruction(vput, "V5", 0, "vector-set!", '3', AUTOGL)
declare_instruction(vcat, "V6", 0, "vector-cat", '2', AUTOGL)
declare_instruction(bvecp, "B0", 0, "bytevector?", '1', AUTOGL)
declare_instruction(bvec, "B1", 1, "bytevector", '#', "%!0.0E1]1")
declare_instruction(bmk, "B2\0'0", 0, "make-bytevector", 'b', AUTOGL)
declare_instruction(blen, "B3", 0, "bytevector-length", '1', AUTOGL)
declare_instruction(bget, "B4", 0, "bytevector-u8-ref", '2', AUTOGL)
declare_instruction(bput, "B5", 0, "bytevector-u8-set!", '3', AUTOGL)
declare_instruction(bsub, "B7", 0, "subbytevector", '3', AUTOGL)
declare_instruction(beq, "B=", 0, "bytevector=?", 'c', AUTOGL)
2023-03-29 00:14:45 +02:00
declare_instruction(recp, "O0\0Y9", 0, "record?", 'b', AUTOGL)
declare_instruction(rmk, "O2\0f", 0, "make-record", 't', AUTOGL)
declare_instruction(rlen, "O3", 0, "record-length", '1', AUTOGL)
declare_instruction(rget, "O4", 0, "record-ref", '2', AUTOGL)
declare_instruction(rput, "O5", 0, "record-set!", '3', AUTOGL)
declare_instruction(rrtd, "O6", 0, "record-type-descriptor", '1', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(vtol, "X0", 0, "%vector->list1", '1', AUTOGL)
declare_instruction(ltov, "X1", 0, "list->vector", '1', AUTOGL)
declare_instruction(stol, "X2", 0, "%string->list1", '1', AUTOGL)
declare_instruction(ltos, "X3", 0, "list->string", '1', AUTOGL)
declare_instruction(ytos, "X4", 0, "symbol->string", '1', AUTOGL)
declare_instruction(stoy, "X5", 0, "string->symbol", '1', AUTOGL)
declare_instruction(itos, "X6\0'(i10)", 0, "fixnum->string", 'b', AUTOGL)
declare_instruction(stoi, "X7\0'(i10)", 0, "string->fixnum", 'b', AUTOGL)
declare_instruction(ctoi, "X8", 0, "char->integer", '1', AUTOGL)
declare_instruction(itoc, "X9", 0, "integer->char", '1', AUTOGL)
declare_instruction(ltob, "E1", 0, "list->bytevector", '1', AUTOGL)
declare_instruction(jtos, "E6", 0, "flonum->string", '1', AUTOGL)
declare_instruction(stoj, "E7", 0, "string->flonum", '1', AUTOGL)
declare_instruction(ntos, "E8\0'(i10)", 0, "number->string", 'b', AUTOGL)
declare_instruction(ston, "E9\0'(i10)", 0, "string->number", 'b', AUTOGL)
declare_instruction(symp, "Y0", 0, "symbol?", '1', AUTOGL)
declare_instruction(boolp, "Y1", 0, "boolean?", '1', AUTOGL)
declare_instruction(boxp, "Y2", 0, "box?", '1', AUTOGL)
2024-07-17 23:47:08 +02:00
declare_instruction(shebangp, "Y5", 0, "shebang?", '1', AUTOGL)
declare_instruction(ytosb, "Y6", 0, "symbol->shebang", '1', AUTOGL)
declare_instruction(sbtoy, "Y7", 0, "shebang->symbol", '1', AUTOGL)
2023-03-29 00:14:45 +02:00
declare_instruction(voidp, "Y8", 0, "void?", '1', AUTOGL)
declare_instruction(void, "Y9", 0, "void", '0', AUTOGL)
declare_instruction(cin, "Pi", 0, "%current-input-port", '0', AUTOGL)
declare_instruction(cout, "Po", 0, "%current-output-port", '0', AUTOGL)
declare_instruction(cerr, "Pe", 0, "%current-error-port", '0', AUTOGL)
2023-03-31 05:01:59 +02:00
declare_instruction(setcin, "Psi", 0, "%set-current-input-port!", '1', AUTOGL)
declare_instruction(setcout, "Pso", 0, "%set-current-output-port!",'1', AUTOGL)
declare_instruction(setcerr, "Pse", 0, "%set-current-error-port!", '1', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(funp, "K0", 0, "procedure?", '1', AUTOGL)
declare_instruction(ipp, "P00", 0, "input-port?", '1', AUTOGL)
declare_instruction(opp, "P01", 0, "output-port?", '1', AUTOGL)
2024-07-12 01:12:03 +02:00
declare_instruction(ttyp, "P09", 0, "tty-port?", '1', AUTOGL)
declare_instruction(sip, "P10", 0, "standard-input-port", '0', AUTOGL)
declare_instruction(sop, "P11", 0, "standard-output-port", '0', AUTOGL)
declare_instruction(sep, "P12", 0, "standard-error-port", '0', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(ipop, "P20", 0, "input-port-open?", '1', AUTOGL)
declare_instruction(opop, "P21", 0, "output-port-open?", '1', AUTOGL)
declare_instruction(oif, "P40", 0, "%open-input-file", '1', AUTOGL)
declare_instruction(oof, "P41", 0, "%open-output-file", '1', AUTOGL)
declare_instruction(obif, "P42", 0, "%open-binary-input-file", '1', AUTOGL)
declare_instruction(obof, "P43", 0, "%open-binary-output-file", '1', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(ois, "P50", 0, "open-input-string", '1', AUTOGL)
declare_instruction(oos, "P51", 0, "open-output-string", '0', AUTOGL)
2023-03-28 00:58:37 +02:00
declare_instruction(oib, "P52", 0, "open-input-bytevector", '1', AUTOGL)
declare_instruction(oob, "P53", 0, "open-output-bytevector", '0', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(cip, "P60", 0, "close-input-port", '1', AUTOGL)
declare_instruction(cop, "P61", 0, "close-output-port", '1', AUTOGL)
declare_instruction(fop, "P71", 0, "flush-output-port", '1', AUTOGL)
declare_instruction(pfc, "P78", 0, "port-fold-case?", '1', AUTOGL)
declare_instruction(spfc, "P79", 0, "set-port-fold-case!", '2', AUTOGL)
2023-03-28 00:58:37 +02:00
declare_instruction(gos, "P90", 0, "get-output-string", '1', AUTOGL)
declare_instruction(gob, "P91", 0, "get-output-bytevector", '1', AUTOGL)
declare_instruction(rdc, "R0\0Pi", 0, "read-char", 'u', AUTOGL)
declare_instruction(rdac, "R1\0Pi", 0, "peek-char", 'u', AUTOGL)
declare_instruction(rdcr, "R2\0Pi", 0, "char-ready?", 'u', AUTOGL)
declare_instruction(rd8, "R3\0Pi", 0, "read-u8", 'u', AUTOGL)
declare_instruction(rda8, "R4\0Pi", 0, "peek-u8", 'u', AUTOGL)
declare_instruction(rd8r, "R5\0Pi", 0, "u8-ready?", 'u', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(eofp, "R8", 0, "eof-object?", '1', AUTOGL)
declare_instruction(eof, "R9", 0, "eof-object", '0', AUTOGL)
declare_instruction(wrc, "W0\0Po", 0, "write-char", 'b', AUTOGL)
2023-03-28 00:58:37 +02:00
declare_instruction(wrs, "W1", 0, "%write-string1", '2', AUTOGL)
declare_instruction(wr8, "W2\0Po", 0, "write-u8", 'b', AUTOGL)
2023-03-28 00:58:37 +02:00
declare_instruction(wrb, "W3", 0, "%write-bytevector1", '2', AUTOGL)
declare_instruction(wrcd, "W4\0Po", 0, "display", 'b', AUTOGL)
declare_instruction(wrcw, "W5\0Po", 0, "write", 'b', AUTOGL)
declare_instruction(wrnl, "W6\0Po", 0, "newline", 'u', AUTOGL)
declare_instruction(wrhw, "W7\0Po", 0, "write-shared", 'b', AUTOGL)
declare_instruction(wriw, "W8\0Po", 0, "write-simple", 'b', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(fexis, "F0", 0, "file-exists?", '1', AUTOGL)
declare_instruction(frem, "F1", 0, "delete-file", '1', AUTOGL)
declare_instruction(fren, "F2", 0, "rename-file", '2', AUTOGL)
declare_instruction(getcwd, "F8", 0, "%cwd", '0', AUTOGL)
declare_instruction(setcwd, "F9", 0, "%set-cwd!", '1', AUTOGL)
2023-03-28 06:32:05 +02:00
declare_instruction(argvref, "Z0", 0, "%argv-ref", '1', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(getenv, "Z1", 0, "get-environment-variable", '1', AUTOGL)
2024-07-17 06:33:46 +02:00
declare_instruction(envvref, "Z2", 0, "%envv-ref", '1', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(clock, "Z3", 0, "current-jiffy", '0', AUTOGL)
declare_instruction(clops, "Z4", 0, "jiffies-per-second", '0', AUTOGL)
declare_instruction(cursec, "Z5", 0, "current-second", '0', AUTOGL)
2024-07-17 05:03:00 +02:00
declare_instruction(system, "Z6", 0, "%system", '1', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(panic, "Z7", 0, "%panic", '2', AUTOGL)
2023-03-30 22:09:25 +02:00
declare_instruction(abort, "Z8\0t", 0, "%abort", 'u', AUTOGL)
declare_instruction(exit, "Z9\0t", 0, "%exit", 'u', AUTOGL)
2024-07-17 05:03:00 +02:00
declare_instruction(gccnt, "Zg", 0, "%gc-count", '0', AUTOGL)
declare_instruction(heapsz, "Zh", 0, "%heap-size", '0', AUTOGL)
declare_instruction(dirsep, "Zs", 0, "directory-separator", '0', AUTOGL)
2023-03-26 23:10:51 +02:00
/* serialization, deserialization, compilation-related instructions */
2023-03-26 23:10:51 +02:00
declare_instruction(igp, "U0", 0, "integrable?", '1', AUTOGL)
declare_instruction(itrs, "U1", 0, "initial-transformers", '0', AUTOGL)
declare_instruction(glos, "U2", 0, "global-store", '0', AUTOGL)
2023-03-26 23:10:51 +02:00
declare_instruction(rdsx, "U3", 0, "deserialize-sexp", '1', AUTOGL)
declare_instruction(rdsc, "U4", 0, "deserialize-code", '1', AUTOGL)
declare_instruction(iglk, "U5", 0, "lookup-integrable", '1', AUTOGL)
declare_instruction(igty, "U6", 0, "integrable-type", '1', AUTOGL)
declare_instruction(iggl, "U7", 0, "integrable-global", '1', AUTOGL)
declare_instruction(igco, "U8", 0, "integrable-code", '2', AUTOGL)
declare_instruction(vmclo, "U9", 1, "closure", '#', INLINED)
declare_instruction(hshim, "H2\0f", 0, "immediate-hash", 'b', AUTOGL)
2023-03-26 23:10:51 +02:00
/* inlined integrables (no custom instructions) */
2023-03-26 23:10:51 +02:00
declare_integrable(NULL, "N0", 0, "complex?", '1', AUTOGL)
declare_integrable(NULL, "N0", 0, "real?", '1', AUTOGL)
declare_integrable(NULL, "I0", 0, "exact-integer?", '1', AUTOGL)
declare_integrable(NULL, "%nI0", 0, "exact?", '1', AUTOGL)
declare_integrable(NULL, "%nJ0", 0, "inexact?", '1', AUTOGL)
declare_integrable(NULL, "Nm", 0, "modulo", '2', AUTOGL)
declare_integrable(NULL, "Nq", 0, "quotient", '2', AUTOGL)
declare_integrable(NULL, "Nr", 0, "remainder", '2', AUTOGL)
declare_integrable(NULL, "Ij", 0, "exact->inexact", '1', AUTOGL)
declare_integrable(NULL, "Ji", 0, "inexact->exact", '1', AUTOGL)
declare_integrable(NULL, "q", 0, "boolean=?", 'c', AUTOGL)
declare_integrable(NULL, "q", 0, "symbol=?", 'c', AUTOGL)
declare_integrable(NULL, "aaa", 0, "caaar", '1', AUTOGL)
declare_integrable(NULL, "daa", 0, "caadr", '1', AUTOGL)
declare_integrable(NULL, "ada", 0, "cadar", '1', AUTOGL)
declare_integrable(NULL, "dda", 0, "caddr", '1', AUTOGL)
declare_integrable(NULL, "aad", 0, "cdaar", '1', AUTOGL)
declare_integrable(NULL, "dad", 0, "cdadr", '1', AUTOGL)
declare_integrable(NULL, "add", 0, "cddar", '1', AUTOGL)
declare_integrable(NULL, "ddd", 0, "cdddr", '1', AUTOGL)
declare_integrable(NULL, "aaaa", 0, "caaaar", '1', AUTOGL)
declare_integrable(NULL, "daaa", 0, "caaadr", '1', AUTOGL)
declare_integrable(NULL, "adaa", 0, "caadar", '1', AUTOGL)
declare_integrable(NULL, "ddaa", 0, "caaddr", '1', AUTOGL)
declare_integrable(NULL, "aada", 0, "cadaar", '1', AUTOGL)
declare_integrable(NULL, "dada", 0, "cadadr", '1', AUTOGL)
declare_integrable(NULL, "adda", 0, "caddar", '1', AUTOGL)
declare_integrable(NULL, "ddda", 0, "cadddr", '1', AUTOGL)
declare_integrable(NULL, "aaad", 0, "cdaaar", '1', AUTOGL)
declare_integrable(NULL, "daad", 0, "cdaadr", '1', AUTOGL)
declare_integrable(NULL, "adad", 0, "cdadar", '1', AUTOGL)
declare_integrable(NULL, "ddad", 0, "cdaddr", '1', AUTOGL)
declare_integrable(NULL, "aadd", 0, "cddaar", '1', AUTOGL)
declare_integrable(NULL, "dadd", 0, "cddadr", '1', AUTOGL)
declare_integrable(NULL, "addd", 0, "cdddar", '1', AUTOGL)
declare_integrable(NULL, "dddd", 0, "cddddr", '1', AUTOGL)
/* non-integrable global definitions */
2023-03-26 23:10:51 +02:00
declare_integrable(NULL, NULL, 0, "apply-to-list", '@', "%2_!K3")
declare_integrable(NULL, NULL, 0, "call-with-values", '@', "%2_!K4")
declare_integrable(NULL, NULL, 0, "values", '@', "K6")
2023-02-28 06:31:08 +01:00
#undef declare_instruction
#undef declare_instrshadow
#undef declare_integrable