tcg_helper_c.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Generate trace/generated-helpers.c.
  5. """
  6. __author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
  7. __copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
  8. __license__ = "GPL version 2 or (at your option) any later version"
  9. __maintainer__ = "Stefan Hajnoczi"
  10. __email__ = "stefanha@linux.vnet.ibm.com"
  11. from tracetool import out
  12. from tracetool.transform import *
  13. def generate(events, backend):
  14. events = [e for e in events
  15. if "disable" not in e.properties]
  16. out('/* This file is autogenerated by tracetool, do not edit. */',
  17. '',
  18. '#include "qemu-common.h"',
  19. '#include "trace.h"',
  20. '#include "exec/helper-proto.h"',
  21. '',
  22. )
  23. for e in events:
  24. if "tcg-exec" not in e.properties:
  25. continue
  26. # tracetool.generate always transforms types to host
  27. e_args = e.original.args
  28. values = ["(%s)%s" % (t, n)
  29. for t, n in e.args.transform(TCG_2_TCG_HELPER_DEF)]
  30. out('void %(name_tcg)s(%(args)s)',
  31. '{',
  32. ' %(name)s(%(values)s);',
  33. '}',
  34. name_tcg="helper_%s_proxy" % e.api(),
  35. name=e.api(),
  36. args=e_args.transform(HOST_2_TCG_COMPAT, TCG_2_TCG_HELPER_DEF),
  37. values=", ".join(values),
  38. )