tcg_h.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Generate .h file for TCG code generation.
  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. def generate(events, backend):
  13. out('/* This file is autogenerated by tracetool, do not edit. */',
  14. '/* You must include this file after the inclusion of helper.h */',
  15. '',
  16. '#ifndef TRACE__GENERATED_TCG_TRACERS_H',
  17. '#define TRACE__GENERATED_TCG_TRACERS_H',
  18. '',
  19. '#include <stdint.h>',
  20. '',
  21. '#include "trace.h"',
  22. '#include "exec/helper-proto.h"',
  23. '',
  24. )
  25. for e in events:
  26. # just keep one of them
  27. if "tcg-trans" not in e.properties:
  28. continue
  29. # get the original event definition
  30. e = e.original.original
  31. out('static inline void %(name_tcg)s(%(args)s)',
  32. '{',
  33. name_tcg=e.api(e.QEMU_TRACE_TCG),
  34. args=e.args)
  35. if "disable" not in e.properties:
  36. out(' %(name_trans)s(%(argnames_trans)s);',
  37. ' gen_helper_%(name_exec)s(%(argnames_exec)s);',
  38. name_trans=e.event_trans.api(e.QEMU_TRACE),
  39. name_exec=e.event_exec.api(e.QEMU_TRACE),
  40. argnames_trans=", ".join(e.event_trans.args.names()),
  41. argnames_exec=", ".join(e.event_exec.args.names()))
  42. out('}')
  43. out('',
  44. '#endif /* TRACE__GENERATED_TCG_TRACERS_H */')