target/i386: Fix bad patch application to translate.c
[qemu/ar7.git] / scripts / tracetool / format / tcg_helper_c.py
blobcc26e03008fdbb37609210ce6c7c062d55e091aa
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 """
5 Generate trace/generated-helpers.c.
6 """
8 __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
9 __copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
10 __license__ = "GPL version 2 or (at your option) any later version"
12 __maintainer__ = "Stefan Hajnoczi"
13 __email__ = "stefanha@linux.vnet.ibm.com"
16 from tracetool import Arguments, out
17 from tracetool.transform import *
18 import tracetool.vcpu
21 def vcpu_transform_args(args, mode):
22 assert len(args) == 1
23 # NOTE: this name must be kept in sync with the one in "tcg_h"
24 args = Arguments([(args.types()[0], "__tcg_" + args.names()[0])])
25 if mode == "code":
26 return Arguments([
27 # Does cast from helper requirements to tracing types
28 ("CPUState *", "ENV_GET_CPU(%s)" % args.names()[0]),
30 else:
31 args = Arguments([
32 # NOTE: Current helper code uses TCGv_env (CPUArchState*)
33 ("CPUArchState *", args.names()[0]),
35 if mode == "header":
36 return args
37 elif mode == "wrapper":
38 return args.transform(HOST_2_TCG)
39 else:
40 assert False
43 def generate(events, backend, group):
44 events = [e for e in events
45 if "disable" not in e.properties]
47 out('/* This file is autogenerated by tracetool, do not edit. */',
48 '',
49 '#include "qemu/osdep.h"',
50 '#include "qemu-common.h"',
51 '#include "cpu.h"',
52 '#include "trace.h"',
53 '#include "exec/helper-proto.h"',
54 '',
57 for e in events:
58 if "tcg-exec" not in e.properties:
59 continue
61 e_args_api = tracetool.vcpu.transform_args(
62 "tcg_helper_c", e.original, "header").transform(
63 HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_DEF)
64 e_args_call = tracetool.vcpu.transform_args(
65 "tcg_helper_c", e, "code")
67 out('void %(name_tcg)s(%(args_api)s)',
68 '{',
69 ' %(name)s(%(args_call)s);',
70 '}',
71 name_tcg="helper_%s_proxy" % e.api(),
72 name=e.api(),
73 args_api=e_args_api,
74 args_call=", ".join(e_args_call.casted()),