pmu.y 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. %parse-param {struct list_head *format}
  2. %parse-param {char *name}
  3. %{
  4. #include <linux/compiler.h>
  5. #include <linux/list.h>
  6. #include <linux/bitmap.h>
  7. #include <string.h>
  8. #include "pmu.h"
  9. extern int perf_pmu_lex (void);
  10. #define ABORT_ON(val) \
  11. do { \
  12. if (val) \
  13. YYABORT; \
  14. } while (0)
  15. %}
  16. %token PP_CONFIG PP_CONFIG1 PP_CONFIG2
  17. %token PP_VALUE PP_ERROR
  18. %type <num> PP_VALUE
  19. %type <bits> bit_term
  20. %type <bits> bits
  21. %union
  22. {
  23. unsigned long num;
  24. DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
  25. }
  26. %%
  27. format:
  28. format format_term
  29. |
  30. format_term
  31. format_term:
  32. PP_CONFIG ':' bits
  33. {
  34. ABORT_ON(perf_pmu__new_format(format, name,
  35. PERF_PMU_FORMAT_VALUE_CONFIG,
  36. $3));
  37. }
  38. |
  39. PP_CONFIG1 ':' bits
  40. {
  41. ABORT_ON(perf_pmu__new_format(format, name,
  42. PERF_PMU_FORMAT_VALUE_CONFIG1,
  43. $3));
  44. }
  45. |
  46. PP_CONFIG2 ':' bits
  47. {
  48. ABORT_ON(perf_pmu__new_format(format, name,
  49. PERF_PMU_FORMAT_VALUE_CONFIG2,
  50. $3));
  51. }
  52. bits:
  53. bits ',' bit_term
  54. {
  55. bitmap_or($$, $1, $3, 64);
  56. }
  57. |
  58. bit_term
  59. {
  60. memcpy($$, $1, sizeof($1));
  61. }
  62. bit_term:
  63. PP_VALUE '-' PP_VALUE
  64. {
  65. perf_pmu__set_format($$, $1, $3);
  66. }
  67. |
  68. PP_VALUE
  69. {
  70. perf_pmu__set_format($$, $1, 0);
  71. }
  72. %%
  73. void perf_pmu_error(struct list_head *list __maybe_unused,
  74. char *name __maybe_unused,
  75. char const *msg __maybe_unused)
  76. {
  77. }