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