]> Git Repo - qemu.git/blob - scripts/tracetool/format/tcg_h.py
7ddc4a52ce607b97e99b0005de00cfc0e9821532
[qemu.git] / scripts / tracetool / format / tcg_h.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 Generate .h file for TCG code generation.
6 """
7
8 __author__     = "Lluís Vilanova <[email protected]>"
9 __copyright__  = "Copyright 2012-2016, Lluís Vilanova <[email protected]>"
10 __license__    = "GPL version 2 or (at your option) any later version"
11
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__      = "[email protected]"
14
15
16 from tracetool import out, Arguments
17 import tracetool.vcpu
18
19
20 def vcpu_transform_args(args):
21     assert len(args) == 1
22     return Arguments([
23         args,
24         # NOTE: this name must be kept in sync with the one in "tcg_h"
25         # NOTE: Current helper code uses TCGv_env (CPUArchState*)
26         ("TCGv_env", "__tcg_" + args.names()[0]),
27     ])
28
29
30 def generate(events, backend, group):
31     if group == "root":
32         header = "trace-root.h"
33     else:
34         header = "trace.h"
35
36     out('/* This file is autogenerated by tracetool, do not edit. */',
37         '/* You must include this file after the inclusion of helper.h */',
38         '',
39         '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
40         '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
41         '',
42         '#include "exec/helper-proto.h"',
43         '',
44         )
45
46     for e in events:
47         # just keep one of them
48         if "tcg-trans" not in e.properties:
49             continue
50
51         out('static inline void %(name_tcg)s(%(args)s)',
52             '{',
53             name_tcg=e.original.api(e.QEMU_TRACE_TCG),
54             args=tracetool.vcpu.transform_args("tcg_h", e.original))
55
56         if "disable" not in e.properties:
57             args_trans = e.original.event_trans.args
58             args_exec = tracetool.vcpu.transform_args(
59                 "tcg_helper_c", e.original.event_exec, "wrapper")
60             out('    %(name_trans)s(%(argnames_trans)s);',
61                 '    gen_helper_%(name_exec)s(%(argnames_exec)s);',
62                 name_trans=e.original.event_trans.api(e.QEMU_TRACE),
63                 name_exec=e.original.event_exec.api(e.QEMU_TRACE),
64                 argnames_trans=", ".join(args_trans.names()),
65                 argnames_exec=", ".join(args_exec.names()))
66
67         out('}')
68
69     out('',
70         '#endif /* TRACE_%s_GENERATED_TCG_TRACERS_H */' % group.upper())
This page took 0.018251 seconds and 2 git commands to generate.