pmu.y 1.3 KB

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