]> git.ipfire.org Git - thirdparty/qemu.git/blame - scripts/tracetool/format/tcg_h.py
trace: switch to modular code generation for sub-directories
[thirdparty/qemu.git] / scripts / tracetool / format / tcg_h.py
CommitLineData
465830fb
LV
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""
5Generate .h file for TCG code generation.
6"""
7
8__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
56797b1f 9__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
465830fb
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
LV
16from tracetool import out, Arguments
17import tracetool.vcpu
18
19
20def 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 ])
465830fb
LV
28
29
80dd5c49 30def generate(events, backend, group):
0ab8ed18
DB
31 if group == "root":
32 header = "trace-root.h"
33 else:
34 header = "trace.h"
35
465830fb
LV
36 out('/* This file is autogenerated by tracetool, do not edit. */',
37 '/* You must include this file after the inclusion of helper.h */',
38 '',
80dd5c49
DB
39 '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
40 '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
465830fb 41 '',
465830fb
LV
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
465830fb
LV
51 out('static inline void %(name_tcg)s(%(args)s)',
52 '{',
3d211d9f
LV
53 name_tcg=e.original.api(e.QEMU_TRACE_TCG),
54 args=tracetool.vcpu.transform_args("tcg_h", e.original))
465830fb
LV
55
56 if "disable" not in e.properties:
3d211d9f
LV
57 args_trans = e.original.event_trans.args
58 args_exec = tracetool.vcpu.transform_args(
59 "tcg_helper_c", e.original.event_exec, "wrapper")
465830fb
LV
60 out(' %(name_trans)s(%(argnames_trans)s);',
61 ' gen_helper_%(name_exec)s(%(argnames_exec)s);',
3d211d9f
LV
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()))
465830fb
LV
66
67 out('}')
68
69 out('',
80dd5c49 70 '#endif /* TRACE_%s_GENERATED_TCG_TRACERS_H */' % group.upper())