]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/tracetool/format/tcg_helper_c.py
scripts/tracetool: Update maintainer email address
[mirror_qemu.git] / scripts / tracetool / format / tcg_helper_c.py
CommitLineData
341ea691
LV
1# -*- coding: utf-8 -*-
2
3"""
4Generate trace/generated-helpers.c.
5"""
6
7__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
864a2178 8__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
341ea691
LV
9__license__ = "GPL version 2 or (at your option) any later version"
10
11__maintainer__ = "Stefan Hajnoczi"
f892b494 12__email__ = "stefanha@redhat.com"
341ea691
LV
13
14
3d211d9f 15from tracetool import Arguments, out
341ea691 16from tracetool.transform import *
3d211d9f
LV
17import tracetool.vcpu
18
19
20def vcpu_transform_args(args, mode):
21 assert len(args) == 1
22 # NOTE: this name must be kept in sync with the one in "tcg_h"
23 args = Arguments([(args.types()[0], "__tcg_" + args.names()[0])])
24 if mode == "code":
25 return Arguments([
26 # Does cast from helper requirements to tracing types
29a0af61 27 ("CPUState *", "env_cpu(%s)" % args.names()[0]),
3d211d9f
LV
28 ])
29 else:
30 args = Arguments([
31 # NOTE: Current helper code uses TCGv_env (CPUArchState*)
32 ("CPUArchState *", args.names()[0]),
33 ])
34 if mode == "header":
35 return args
36 elif mode == "wrapper":
37 return args.transform(HOST_2_TCG)
38 else:
39 assert False
341ea691
LV
40
41
80dd5c49 42def generate(events, backend, group):
0ab8ed18
DB
43 if group == "root":
44 header = "trace-root.h"
45 else:
46 header = "trace.h"
47
341ea691
LV
48 events = [e for e in events
49 if "disable" not in e.properties]
50
51 out('/* This file is autogenerated by tracetool, do not edit. */',
52 '',
2aef8c91 53 '#include "qemu/osdep.h"',
33c11879 54 '#include "cpu.h"',
341ea691 55 '#include "exec/helper-proto.h"',
7609ffb9 56 '#include "%s"' % header,
341ea691
LV
57 '',
58 )
59
60 for e in events:
61 if "tcg-exec" not in e.properties:
62 continue
63
3d211d9f
LV
64 e_args_api = tracetool.vcpu.transform_args(
65 "tcg_helper_c", e.original, "header").transform(
66 HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_DEF)
67 e_args_call = tracetool.vcpu.transform_args(
68 "tcg_helper_c", e, "code")
341ea691 69
3d211d9f 70 out('void %(name_tcg)s(%(args_api)s)',
341ea691 71 '{',
864a2178 72 # NOTE: the check was already performed at TCG-generation time
3d211d9f 73 ' %(name)s(%(args_call)s);',
341ea691
LV
74 '}',
75 name_tcg="helper_%s_proxy" % e.api(),
864a2178 76 name=e.api(e.QEMU_TRACE_NOCHECK),
3d211d9f
LV
77 args_api=e_args_api,
78 args_call=", ".join(e_args_call.casted()),
341ea691 79 )