Merge tag 'pull-target-arm-20221114' of https://git.linaro.org/people/pmaydell/qemu...
[qemu/ar7.git] / include / exec / plugin-gen.h
blob5004728c61dfffa60ca356a0fa1d06763ccda868
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 "qemu/plugin.h"
16 #include "tcg/tcg.h"
18 struct DisasContextBase;
20 #ifdef CONFIG_PLUGIN
22 bool plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db,
23 bool supress);
24 void plugin_gen_tb_end(CPUState *cpu);
25 void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db);
26 void plugin_gen_insn_end(void);
28 void plugin_gen_disable_mem_helpers(void);
29 void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info);
31 static inline void plugin_insn_append(abi_ptr pc, const void *from, size_t size)
33 struct qemu_plugin_insn *insn = tcg_ctx->plugin_insn;
34 abi_ptr off;
36 if (insn == NULL) {
37 return;
39 off = pc - insn->vaddr;
40 if (off < insn->data->len) {
41 g_byte_array_set_size(insn->data, off);
42 } else if (off > insn->data->len) {
43 /* we have an unexpected gap */
44 g_assert_not_reached();
47 insn->data = g_byte_array_append(insn->data, from, size);
50 #else /* !CONFIG_PLUGIN */
52 static inline bool
53 plugin_gen_tb_start(CPUState *cpu, const struct DisasContextBase *db, bool sup)
55 return false;
58 static inline
59 void plugin_gen_insn_start(CPUState *cpu, const struct DisasContextBase *db)
60 { }
62 static inline void plugin_gen_insn_end(void)
63 { }
65 static inline void plugin_gen_tb_end(CPUState *cpu)
66 { }
68 static inline void plugin_gen_disable_mem_helpers(void)
69 { }
71 static inline void plugin_gen_empty_mem_callback(TCGv addr, uint32_t info)
72 { }
74 static inline void plugin_insn_append(abi_ptr pc, const void *from, size_t size)
75 { }
77 #endif /* CONFIG_PLUGIN */
79 #endif /* QEMU_PLUGIN_GEN_H */