Merge remote-tracking branch 'remotes/elmarco/tags/slirp-pull-request' into staging
[qemu.git] / scripts / tracetool / format / tcg_helper_wrapper_h.py
1 # -*- coding: utf-8 -*-
2
3 """
4 Generate trace/generated-helpers-wrappers.h.
5 """
6
7 __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
8 __copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
9 __license__ = "GPL version 2 or (at your option) any later version"
10
11 __maintainer__ = "Stefan Hajnoczi"
12 __email__ = "stefanha@linux.vnet.ibm.com"
13
14
15 from tracetool import out
16 from tracetool.transform import *
17 import tracetool.vcpu
18
19
20 def generate(events, backend, group):
21 events = [e for e in events
22 if "disable" not in e.properties]
23
24 out('/* This file is autogenerated by tracetool, do not edit. */',
25 '',
26 '#define tcg_temp_new_nop(v) (v)',
27 '#define tcg_temp_free_nop(v)',
28 '',
29 )
30
31 for e in events:
32 if "tcg-exec" not in e.properties:
33 continue
34
35 # tracetool.generate always transforms types to host
36 e_args = tracetool.vcpu.transform_args("tcg_helper_c", e.original, "wrapper")
37
38 # mixed-type to TCG helper bridge
39 args_tcg_compat = e_args.transform(HOST_2_TCG_COMPAT)
40
41 code_new = [
42 "%(tcg_type)s __%(name)s = %(tcg_func)s(%(name)s);" %
43 {"tcg_type": transform_type(type_, HOST_2_TCG),
44 "tcg_func": transform_type(type_, HOST_2_TCG_TMP_NEW),
45 "name": name}
46 for (type_, name) in args_tcg_compat
47 ]
48
49 code_free = [
50 "%(tcg_func)s(__%(name)s);" %
51 {"tcg_func": transform_type(type_, HOST_2_TCG_TMP_FREE),
52 "name": name}
53 for (type_, name) in args_tcg_compat
54 ]
55
56 gen_name = "gen_helper_" + e.api()
57
58 out('static inline void %(name)s(%(args)s)',
59 '{',
60 ' %(code_new)s',
61 ' %(proxy_name)s(%(tmp_names)s);',
62 ' %(code_free)s',
63 '}',
64 name=gen_name,
65 args=e_args,
66 proxy_name=gen_name + "_proxy",
67 code_new="\n ".join(code_new),
68 code_free="\n ".join(code_free),
69 tmp_names=", ".join(["__%s" % name for _, name in e_args]),
70 )