hw/arm/virt: Consolidate GIC finalize logic
[qemu.git] / include / exec / plugin-gen.h
blob5f5506f1cc2c4766e0c999f6e047a691fee469d8
1 /*
2 * Copyright (C) 2017, Emilio G. Cota <cota@braap.org>
4 * License: GNU GPL, version 2 or later.
5 * See the COPYING file in the top-level directory.
7 * plugin-gen.h - TCG-dependent definitions for generating plugin code
9 * This header should be included only from plugin.c and C files that emit
10 * TCG code.
12 #ifndef QEMU_PLUGIN_GEN_H
13 #define QEMU_PLUGIN_GEN_H
15 #include "exec/cpu_ldst.h"
16 #include "qemu/plugin.h"
17 #include "tcg/tcg.h"
19 struct DisasContextBase;
21 #ifdef CONFIG_PLUGIN
23 bool plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db,
24 bool supress);
25 void plugin_gen_tb_end(CPUState *cpu);
26 void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db);
27 void plugin_gen_insn_end(void);
29 void plugin_gen_disable_mem_helpers(void);
30 void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info);
32 static inline void plugin_insn_append(abi_ptr pc, const void *from, size_t size)
34 struct qemu_plugin_insn *insn = tcg_ctx->plugin_insn;
35 abi_ptr off;
37 if (insn == NULL) {
38 return;
40 off = pc - insn->vaddr;
41 if (off < insn->data->len) {
42 g_byte_array_set_size(insn->data, off);
43 } else if (off > insn->data->len) {
44 /* we have an unexpected gap */
45 g_assert_not_reached();
48 insn->data = g_byte_array_append(insn->data, from, size);
51 #else /* !CONFIG_PLUGIN */
53 static inline bool
54 plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db, bool sup)
56 return false;
59 static inline
60 void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db)
61 { }
63 static inline void plugin_gen_insn_end(void)
64 { }
66 static inline void plugin_gen_tb_end(CPUState *cpu)
67 { }
69 static inline void plugin_gen_disable_mem_helpers(void)
70 { }
72 static inline void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info)
73 { }
75 static inline void plugin_insn_append(abi_ptr pc, const void *from, size_t size)
76 { }
78 #endif /* CONFIG_PLUGIN */
80 #endif /* QEMU_PLUGIN_GEN_H */