Add qemu 2.4.0
[kvmfornfv.git] / qemu / scripts / tracetool / format / tcg_helper_c.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 Generate trace/generated-helpers.c.
6 """
7
8 __author__     = "Lluís Vilanova <vilanova@ac.upc.edu>"
9 __copyright__  = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
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
16 from tracetool import out
17 from tracetool.transform import *
18
19
20 def generate(events, backend):
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         '#include "qemu-common.h"',
27         '#include "trace.h"',
28         '#include "exec/helper-proto.h"',
29         '',
30         )
31
32     for e in events:
33         if "tcg-exec" not in e.properties:
34             continue
35
36         # tracetool.generate always transforms types to host
37         e_args = e.original.args
38
39         values = ["(%s)%s" % (t, n)
40                   for t, n in e.args.transform(TCG_2_TCG_HELPER_DEF)]
41
42         out('void %(name_tcg)s(%(args)s)',
43             '{',
44             '    %(name)s(%(values)s);',
45             '}',
46             name_tcg="helper_%s_proxy" % e.api(),
47             name=e.api(),
48             args=e_args.transform(HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_DEF),
49             values=", ".join(values),
50             )