Lines Matching defs:fsm
1035 /* fsm */
1824 node_overflow(struct x86_decode_fsm *fsm, struct x86_instr *instr)
1826 fsm->fn = NULL;
1831 fsm_read(struct x86_decode_fsm *fsm, uint8_t *bytes, size_t n)
1833 if (fsm->buf + n > fsm->end) {
1836 memcpy(bytes, fsm->buf, n);
1841 fsm_advance(struct x86_decode_fsm *fsm, size_t n,
1844 fsm->buf += n;
1845 if (fsm->buf > fsm->end) {
1846 fsm->fn = node_overflow;
1848 fsm->fn = fn;
1868 node_movs(struct x86_decode_fsm *fsm, struct x86_instr *instr)
1885 fsm_advance(fsm, 0, NULL);
1897 node_cmps(struct x86_decode_fsm *fsm, struct x86_instr *instr)
1914 fsm_advance(fsm, 0, NULL);
1924 node_stlo(struct x86_decode_fsm *fsm, struct x86_instr *instr)
1955 fsm_advance(fsm, 0, NULL);
1961 node_dmo(struct x86_decode_fsm *fsm, struct x86_instr *instr)
1982 if (fsm_read(fsm, (uint8_t *)&stdmo->u.dmo, adrsize) == -1) {
1985 fsm_advance(fsm, adrsize, NULL);
2007 node_immediate(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2027 if (fsm_read(fsm, (uint8_t *)&store->u.imm.data, immsize) == -1) {
2030 fsm_advance(fsm, immsize, NULL);
2040 node_disp(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2056 if (fsm_read(fsm, (uint8_t *)&data, n) == -1) {
2060 if (__predict_true(fsm->is64bit)) {
2067 fsm_advance(fsm, n, node_immediate);
2069 fsm_advance(fsm, n, NULL);
2080 node_dual(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2105 fsm_advance(fsm, 1, node_immediate);
2107 fsm_advance(fsm, 1, NULL);
2110 fsm_advance(fsm, 1, node_disp);
2150 node_sib(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2157 if (fsm_read(fsm, &byte, sizeof(byte)) == -1) {
2192 fsm_advance(fsm, 1, node_disp);
2194 fsm_advance(fsm, 1, node_immediate);
2196 fsm_advance(fsm, 1, NULL);
2250 is_rip_relative(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2252 return (fsm->is64bit && /* RIP-relative only in 64bit mode */
2258 is_disp32_only(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2260 return (!fsm->is64bit && /* no disp32-only in 64bit mode */
2267 is_disp16_only(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2275 is_dual(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2303 node_regmodrm(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2310 if (fsm_read(fsm, &byte, sizeof(byte)) == -1) {
2366 fsm_advance(fsm, 1, node_sib);
2370 if (is_rip_relative(fsm, instr)) {
2375 fsm_advance(fsm, 1, node_disp);
2379 if (is_disp32_only(fsm, instr)) {
2384 fsm_advance(fsm, 1, node_disp);
2388 if (__predict_false(is_disp16_only(fsm, instr))) {
2393 fsm_advance(fsm, 1, node_disp);
2397 if (__predict_false(is_dual(fsm, instr))) {
2399 fsm_advance(fsm, 0, node_dual);
2413 fsm_advance(fsm, 1, node_immediate);
2415 fsm_advance(fsm, 1, NULL);
2420 fsm_advance(fsm, 1, node_immediate);
2422 fsm_advance(fsm, 1, NULL);
2425 fsm_advance(fsm, 1, node_disp);
2432 get_operand_size(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2443 if (!fsm->is16bit) {
2462 get_address_size(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2464 if (fsm->is64bit) {
2471 if (fsm->is32bit) {
2486 node_primary_opcode(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2491 if (fsm_read(fsm, &byte, sizeof(byte)) == -1) {
2502 instr->operand_size = get_operand_size(fsm, instr);
2503 instr->address_size = get_address_size(fsm, instr);
2505 if (fsm->is64bit && (instr->operand_size == 4)) {
2511 fsm_advance(fsm, 1, node_regmodrm);
2514 fsm_advance(fsm, 1, node_dmo);
2516 fsm_advance(fsm, 1, node_stlo);
2518 fsm_advance(fsm, 1, node_movs);
2520 fsm_advance(fsm, 1, node_cmps);
2529 node_secondary_opcode(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2534 if (fsm_read(fsm, &byte, sizeof(byte)) == -1) {
2545 instr->operand_size = get_operand_size(fsm, instr);
2546 instr->address_size = get_address_size(fsm, instr);
2548 if (fsm->is64bit && (instr->operand_size == 4)) {
2564 fsm_advance(fsm, 1, node_regmodrm);
2573 node_main(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2582 if (fsm_read(fsm, &byte, sizeof(byte)) == -1) {
2591 fsm_advance(fsm, 1, node_secondary_opcode);
2598 fsm->fn = node_primary_opcode;
2601 fsm->fn = node_primary_opcode;
2608 node_rex_prefix(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2614 if (fsm_read(fsm, &byte, sizeof(byte)) == -1) {
2619 if (__predict_false(!fsm->is64bit)) {
2630 fsm_advance(fsm, n, node_main);
2635 node_legacy_prefix(struct x86_decode_fsm *fsm, struct x86_instr *instr)
2639 if (fsm_read(fsm, &byte, sizeof(byte)) == -1) {
2667 fsm_advance(fsm, 0, node_rex_prefix);
2671 fsm_advance(fsm, 1, node_legacy_prefix);
2679 struct x86_decode_fsm fsm;
2687 fsm.is64bit = is_64bit(state);
2688 fsm.is32bit = is_32bit(state);
2689 fsm.is16bit = is_16bit(state);
2691 fsm.fn = node_legacy_prefix;
2692 fsm.buf = inst_bytes;
2693 fsm.end = inst_bytes + inst_len;
2695 while (fsm.fn != NULL) {
2696 ret = (*fsm.fn)(&fsm, instr);
2710 instr->len = fsm.buf - inst_bytes;