]> git.proxmox.com Git - mirror_qemu.git/blame - scripts/tracetool/format/tcg_helper_c.py
trace: switch to modular code generation for sub-directories
[mirror_qemu.git] / scripts / tracetool / format / tcg_helper_c.py
CommitLineData
341ea691
LV
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""
5Generate trace/generated-helpers.c.
6"""
7
8__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
3d211d9f 9__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
341ea691
LV
10__license__ = "GPL version 2 or (at your option) any later version"
11
12__maintainer__ = "Stefan Hajnoczi"
13__email__ = "stefanha@linux.vnet.ibm.com"
14
15
3d211d9f 16from tracetool import Arguments, out
341ea691 17from tracetool.transform import *
3d211d9f
LV
18import tracetool.vcpu
19
20
21def 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]),
29 ])
30 else:
31 args = Arguments([
32 # NOTE: Current helper code uses TCGv_env (CPUArchState*)
33 ("CPUArchState *", args.names()[0]),
34 ])
35 if mode == "header":
36 return args
37 elif mode == "wrapper":
38 return args.transform(HOST_2_TCG)
39 else:
40 assert False
341ea691
LV
41
42
80dd5c49 43def generate(events, backend, group):
0ab8ed18
DB
44 if group == "root":
45 header = "trace-root.h"
46 else:
47 header = "trace.h"
48
341ea691
LV
49 events = [e for e in events
50 if "disable" not in e.properties]
51
52 out('/* This file is autogenerated by tracetool, do not edit. */',
53 '',
2aef8c91 54 '#include "qemu/osdep.h"',
341ea691 55 '#include "qemu-common.h"',
33c11879 56 '#include "cpu.h"',
341ea691
LV
57 '#include "exec/helper-proto.h"',
58 '',
59 )
60
61 for e in events:
62 if "tcg-exec" not in e.properties:
63 continue
64
3d211d9f
LV
65 e_args_api = tracetool.vcpu.transform_args(
66 "tcg_helper_c", e.original, "header").transform(
67 HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_DEF)
68 e_args_call = tracetool.vcpu.transform_args(
69 "tcg_helper_c", e, "code")
341ea691 70
3d211d9f 71 out('void %(name_tcg)s(%(args_api)s)',
341ea691 72 '{',
3d211d9f 73 ' %(name)s(%(args_call)s);',
341ea691
LV
74 '}',
75 name_tcg="helper_%s_proxy" % e.api(),
76 name=e.api(),
3d211d9f
LV
77 args_api=e_args_api,
78 args_call=", ".join(e_args_call.casted()),
341ea691 79 )