]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/tracetool/format/tcg_h.py
iotests/281: Let NBD connection yield in iothread
[mirror_qemu.git] / scripts / tracetool / format / tcg_h.py
CommitLineData
465830fb
LV
1# -*- coding: utf-8 -*-
2
3"""
4Generate .h file for TCG code generation.
5"""
6
7__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
864a2178 8__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
465830fb
LV
9__license__ = "GPL version 2 or (at your option) any later version"
10
11__maintainer__ = "Stefan Hajnoczi"
f892b494 12__email__ = "stefanha@redhat.com"
465830fb
LV
13
14
3d211d9f
LV
15from tracetool import out, Arguments
16import tracetool.vcpu
17
18
19def vcpu_transform_args(args):
20 assert len(args) == 1
21 return Arguments([
22 args,
23 # NOTE: this name must be kept in sync with the one in "tcg_h"
24 # NOTE: Current helper code uses TCGv_env (CPUArchState*)
25 ("TCGv_env", "__tcg_" + args.names()[0]),
26 ])
465830fb
LV
27
28
80dd5c49 29def generate(events, backend, group):
0ab8ed18 30 if group == "root":
243af022 31 header = "trace/trace-root.h"
0ab8ed18
DB
32 else:
33 header = "trace.h"
34
465830fb
LV
35 out('/* This file is autogenerated by tracetool, do not edit. */',
36 '/* You must include this file after the inclusion of helper.h */',
37 '',
80dd5c49
DB
38 '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
39 '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
465830fb 40 '',
465830fb 41 '#include "exec/helper-proto.h"',
7609ffb9 42 '#include "%s"' % header,
465830fb
LV
43 '',
44 )
45
46 for e in events:
47 # just keep one of them
864a2178 48 if "tcg-exec" not in e.properties:
465830fb
LV
49 continue
50
465830fb
LV
51 out('static inline void %(name_tcg)s(%(args)s)',
52 '{',
3d211d9f
LV
53 name_tcg=e.original.api(e.QEMU_TRACE_TCG),
54 args=tracetool.vcpu.transform_args("tcg_h", e.original))
465830fb
LV
55
56 if "disable" not in e.properties:
3d211d9f
LV
57 args_trans = e.original.event_trans.args
58 args_exec = tracetool.vcpu.transform_args(
59 "tcg_helper_c", e.original.event_exec, "wrapper")
864a2178
LV
60 if "vcpu" in e.properties:
61 trace_cpu = e.args.names()[0]
62 cond = "trace_event_get_vcpu_state(%(cpu)s,"\
63 " TRACE_%(id)s)"\
64 % dict(
65 cpu=trace_cpu,
66 id=e.original.event_exec.name.upper())
67 else:
68 cond = "true"
69
465830fb 70 out(' %(name_trans)s(%(argnames_trans)s);',
864a2178
LV
71 ' if (%(cond)s) {',
72 ' gen_helper_%(name_exec)s(%(argnames_exec)s);',
73 ' }',
3d211d9f
LV
74 name_trans=e.original.event_trans.api(e.QEMU_TRACE),
75 name_exec=e.original.event_exec.api(e.QEMU_TRACE),
76 argnames_trans=", ".join(args_trans.names()),
864a2178
LV
77 argnames_exec=", ".join(args_exec.names()),
78 cond=cond)
465830fb
LV
79
80 out('}')
81
82 out('',
80dd5c49 83 '#endif /* TRACE_%s_GENERATED_TCG_TRACERS_H */' % group.upper())