/* 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 */ 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(indirect, "^", 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(sseti, ".!", 1, NULL, 0, NULL) declare_instruction(dseti, ":!", 1, NULL, 0, NULL) declare_instruction(gset, "@!", 'g', NULL, 0, NULL) declare_instruction(conti, "K1", 0, NULL, 0, NULL) declare_instruction(nuate, "K2", 0, NULL, 0, NULL) declare_instruction(appl, "K3", 0, NULL, 0, NULL) declare_instruction(save, "$", 's', NULL, 0, NULL) declare_instruction(push, ",", 0, 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) /* popular instruction combos */ 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, "0", 0, "%iposp", 1, INLINED) declare_instruction(inegp, "I<0", 0, "%inegp", 1, INLINED) declare_instruction(ievnp, "Ie", 0, "%ievnp", 1, INLINED) declare_instruction(ioddp, "Io", 0, "%ioddp", 1, INLINED) declare_instruction(iadd, "I+", 0, "%iadd", 2, INLINED) declare_instruction(isub, "I-", 0, "%isub", 2, INLINED) declare_instruction(imul, "I*", 0, "%imul", 2, INLINED) declare_instruction(idiv, "I/", 0, "%idiv", 2, INLINED) declare_instruction(iquo, "Iq", 0, "%iquo", 2, INLINED) declare_instruction(irem, "Ir", 0, "%irem", 2, INLINED) declare_instruction(ilt, "I<", 0, "%ilt", 2, INLINED) declare_instruction(igt, "I>", 0, "%igt", 2, INLINED) declare_instruction(ile, "I>!", 0, "%ile", 2, INLINED) declare_instruction(ige, "I0", 0, "%jposp", 1, INLINED) declare_instruction(jnegp, "J<0", 0, "%jnegp", 1, INLINED) declare_instruction(jevnp, "Je", 0, "%jevnp", 1, INLINED) declare_instruction(joddp, "Jo", 0, "%joddp", 1, INLINED) declare_instruction(jintp, "Jw", 0, "%jintp", 1, INLINED) declare_instruction(jnanp, "Ju", 0, "%jnanp", 1, INLINED) declare_instruction(jfinp, "Jf", 0, "%jfinp", 1, INLINED) declare_instruction(jinfp, "Jh", 0, "%jinfp", 1, INLINED) declare_instruction(jadd, "J+", 0, "%jadd", 2, INLINED) declare_instruction(jsub, "J-", 0, "%jsub", 2, INLINED) declare_instruction(jmul, "J*", 0, "%jmul", 2, INLINED) declare_instruction(jdiv, "J/", 0, "%jdiv", 2, INLINED) declare_instruction(jquo, "Jq", 0, "%jquo", 2, INLINED) declare_instruction(jrem, "Jr", 0, "%jrem", 2, INLINED) declare_instruction(jlt, "J<", 0, "%jlt", 2, INLINED) declare_instruction(jgt, "J>", 0, "%jgt", 2, INLINED) declare_instruction(jle, "J>!", 0, "%jle", 2, INLINED) declare_instruction(jge, "J0", 0, "%posp", 1, INLINED) declare_instruction(negp, "<0", 0, "%negp", 1, INLINED) declare_instruction(add, "+", 0, "%add", 2, INLINED) declare_instruction(sub, "-", 0, "%sub", 2, INLINED) declare_instruction(mul, "*", 0, "%mul", 2, INLINED) declare_instruction(div, "/", 0, "%div", 2, INLINED) declare_instruction(lt, "<", 0, "%lt", 2, INLINED) declare_instruction(gt, ">", 0, "%gt", 2, INLINED) declare_instruction(le, ">!", 0, "%le", 2, INLINED) declare_instruction(ge, "", 0, "%cgt", 2, INLINED) declare_instruction(cle, "C>!", 0, "%cle", 2, INLINED) declare_instruction(cge, "C", 0, "%cigt", 2, INLINED) declare_instruction(cile, "Ci>!", 0, "%cile", 2, INLINED) declare_instruction(cige, "Ci", 0, "%sgt", 2, INLINED) declare_instruction(sle, "S>!", 0, "%sle", 2, INLINED) declare_instruction(sge, "S", 0, "%sigt", 2, INLINED) declare_instruction(sile, "Si>!", 0, "%sile", 2, INLINED) declare_instruction(sige, "Si