cpu: move exec-all.h inclusion out of cpu.h
[qemu/ar7.git] / disas / tci.c
blob7233343fa109a882cb5b85a22a62df8666fbb4c1
1 /*
2 * Tiny Code Interpreter for QEMU - disassembler
4 * Copyright (c) 2011 Stefan Weil
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "qemu/osdep.h"
21 #include "qemu-common.h"
22 #include "disas/bfd.h"
23 #include "exec/exec-all.h"
24 #include "tcg/tcg.h"
26 /* Disassemble TCI bytecode. */
27 int print_insn_tci(bfd_vma addr, disassemble_info *info)
29 int length;
30 uint8_t byte;
31 int status;
32 TCGOpcode op;
34 status = info->read_memory_func(addr, &byte, 1, info);
35 if (status != 0) {
36 info->memory_error_func(status, addr, info);
37 return -1;
39 op = byte;
41 addr++;
42 status = info->read_memory_func(addr, &byte, 1, info);
43 if (status != 0) {
44 info->memory_error_func(status, addr, info);
45 return -1;
47 length = byte;
49 if (op >= tcg_op_defs_max) {
50 info->fprintf_func(info->stream, "illegal opcode %d", op);
51 } else {
52 const TCGOpDef *def = &tcg_op_defs[op];
53 int nb_oargs = def->nb_oargs;
54 int nb_iargs = def->nb_iargs;
55 int nb_cargs = def->nb_cargs;
56 /* TODO: Improve disassembler output. */
57 info->fprintf_func(info->stream, "%s\to=%d i=%d c=%d",
58 def->name, nb_oargs, nb_iargs, nb_cargs);
61 return length;