Linux Audio

Check our new training course

Loading...
v3.5.6
  1
 
 
  2%option prefix="parse_events_"
  3%option stack
 
 
 
  4
  5%{
  6#include <errno.h>
 
 
 
  7#include "../perf.h"
  8#include "parse-events-bison.h"
  9#include "parse-events.h"
 
 
 
 
 
 10
 11static int __value(char *str, int base, int token)
 12{
 13	long num;
 14
 15	errno = 0;
 16	num = strtoul(str, NULL, base);
 17	if (errno)
 18		return PE_ERROR;
 19
 20	parse_events_lval.num = num;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 21	return token;
 22}
 23
 24static int value(int base)
 25{
 26	return __value(parse_events_text, base, PE_VALUE);
 
 
 
 
 
 
 27}
 28
 29static int raw(void)
 30{
 31	return __value(parse_events_text + 1, 16, PE_RAW);
 
 
 
 
 
 
 
 
 
 32}
 33
 34static int str(int token)
 35{
 36	parse_events_lval.str = strdup(parse_events_text);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 37	return token;
 38}
 39
 40static int sym(int type, int config)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 41{
 42	parse_events_lval.num = (type << 16) + config;
 43	return PE_VALUE_SYM;
 
 
 44}
 45
 46static int term(int type)
 47{
 48	parse_events_lval.num = type;
 
 
 49	return PE_TERM;
 50}
 51
 
 
 
 
 
 
 
 
 
 
 
 52%}
 53
 54%x mem
 
 
 
 
 
 
 
 
 
 55
 56num_dec		[0-9]+
 57num_hex		0x[a-fA-F0-9]+
 58num_raw_hex	[a-fA-F0-9]+
 59name		[a-zA-Z_*?][a-zA-Z0-9_*?]*
 60modifier_event	[ukhpGH]{1,8}
 61modifier_bp	[rwx]
 
 
 
 
 62
 63%%
 64cpu-cycles|cycles				{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); }
 65stalled-cycles-frontend|idle-cycles-frontend	{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
 66stalled-cycles-backend|idle-cycles-backend	{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
 67instructions					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); }
 68cache-references				{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); }
 69cache-misses					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); }
 70branch-instructions|branches			{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); }
 71branch-misses					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); }
 72bus-cycles					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); }
 73ref-cycles					{ return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); }
 74cpu-clock					{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); }
 75task-clock					{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); }
 76page-faults|faults				{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); }
 77minor-faults					{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); }
 78major-faults					{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); }
 79context-switches|cs				{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); }
 80cpu-migrations|migrations			{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); }
 81alignment-faults				{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); }
 82emulation-faults				{ return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); }
 83
 84L1-dcache|l1-d|l1d|L1-data		|
 85L1-icache|l1-i|l1i|L1-instruction	|
 86LLC|L2					|
 87dTLB|d-tlb|Data-TLB			|
 88iTLB|i-tlb|Instruction-TLB		|
 89branch|branches|bpu|btb|bpc		|
 90node					{ return str(PE_NAME_CACHE_TYPE); }
 91
 92load|loads|read				|
 93store|stores|write			|
 94prefetch|prefetches			|
 95speculative-read|speculative-load	|
 96refs|Reference|ops|access		|
 97misses|miss				{ return str(PE_NAME_CACHE_OP_RESULT); }
 98
 99	/*
100	 * These are event config hardcoded term names to be specified
101	 * within xxx/.../ syntax. So far we dont clash with other names,
102	 * so we can put them here directly. In case the we have a conflict
103	 * in future, this needs to go into '//' condition block.
104	 */
105config			{ return term(PARSE_EVENTS__TERM_TYPE_CONFIG); }
106config1			{ return term(PARSE_EVENTS__TERM_TYPE_CONFIG1); }
107config2			{ return term(PARSE_EVENTS__TERM_TYPE_CONFIG2); }
108name			{ return term(PARSE_EVENTS__TERM_TYPE_NAME); }
109period			{ return term(PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
110branch_type		{ return term(PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
 
 
 
 
 
111
112mem:			{ BEGIN(mem); return PE_PREFIX_MEM; }
113r{num_raw_hex}		{ return raw(); }
114{num_dec}		{ return value(10); }
115{num_hex}		{ return value(16); }
116
117{modifier_event}	{ return str(PE_MODIFIER_EVENT); }
118{name}			{ return str(PE_NAME); }
119"/"			{ return '/'; }
120-			{ return '-'; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121,			{ return ','; }
122:			{ return ':'; }
123=			{ return '='; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
125<mem>{
126{modifier_bp}		{ return str(PE_MODIFIER_BP); }
127:			{ return ':'; }
128{num_dec}		{ return value(10); }
129{num_hex}		{ return value(16); }
 
130	/*
131	 * We need to separate 'mem:' scanner part, in order to get specific
132	 * modifier bits parsed out. Otherwise we would need to handle PE_NAME
133	 * and we'd need to parse it manually. During the escape from <mem>
134	 * state we need to put the escaping char back, so we dont miss it.
135	 */
136.			{ unput(*parse_events_text); BEGIN(INITIAL); }
137	/*
138	 * We destroy the scanner after reaching EOF,
139	 * but anyway just to be sure get back to INIT state.
140	 */
141<<EOF>>			{ BEGIN(INITIAL); }
142}
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144%%
145
146int parse_events_wrap(void)
147{
148	return 1;
149}
v5.9
  1
  2%option reentrant
  3%option bison-bridge
  4%option prefix="parse_events_"
  5%option stack
  6%option bison-locations
  7%option yylineno
  8%option reject
  9
 10%{
 11#include <errno.h>
 12#include <sys/types.h>
 13#include <sys/stat.h>
 14#include <unistd.h>
 15#include "../perf.h"
 
 16#include "parse-events.h"
 17#include "parse-events-bison.h"
 18#include "evsel.h"
 19
 20char *parse_events_get_text(yyscan_t yyscanner);
 21YYSTYPE *parse_events_get_lval(yyscan_t yyscanner);
 22
 23static int __value(YYSTYPE *yylval, char *str, int base, int token)
 24{
 25	u64 num;
 26
 27	errno = 0;
 28	num = strtoull(str, NULL, base);
 29	if (errno)
 30		return PE_ERROR;
 31
 32	yylval->num = num;
 33	return token;
 34}
 35
 36static int value(yyscan_t scanner, int base)
 37{
 38	YYSTYPE *yylval = parse_events_get_lval(scanner);
 39	char *text = parse_events_get_text(scanner);
 40
 41	return __value(yylval, text, base, PE_VALUE);
 42}
 43
 44static int str(yyscan_t scanner, int token)
 45{
 46	YYSTYPE *yylval = parse_events_get_lval(scanner);
 47	char *text = parse_events_get_text(scanner);
 48
 49	if (text[0] != '\'') {
 50		yylval->str = strdup(text);
 51	} else {
 52		/*
 53		 * If a text tag specified on the command line
 54		 * contains opening single quite ' then it is
 55		 * expected that the tag ends with single quote
 56		 * as well, like this:
 57		 *     name=\'CPU_CLK_UNHALTED.THREAD:cmask=1\'
 58		 * quotes need to be escaped to bypass shell
 59		 * processing.
 60		 */
 61		yylval->str = strndup(&text[1], strlen(text) - 2);
 62	}
 63
 64	return token;
 65}
 66
 67static int raw(yyscan_t scanner)
 68{
 69	YYSTYPE *yylval = parse_events_get_lval(scanner);
 70	char *text = parse_events_get_text(scanner);
 71
 72	if (perf_pmu__parse_check(text) == PMU_EVENT_SYMBOL)
 73		return str(scanner, PE_NAME);
 74
 75	return __value(yylval, text + 1, 16, PE_RAW);
 76}
 77
 78static bool isbpf_suffix(char *text)
 79{
 80	int len = strlen(text);
 81
 82	if (len < 2)
 83		return false;
 84	if ((text[len - 1] == 'c' || text[len - 1] == 'o') &&
 85	    text[len - 2] == '.')
 86		return true;
 87	if (len > 4 && !strcmp(text + len - 4, ".obj"))
 88		return true;
 89	return false;
 90}
 91
 92static bool isbpf(yyscan_t scanner)
 93{
 94	char *text = parse_events_get_text(scanner);
 95	struct stat st;
 96
 97	if (!isbpf_suffix(text))
 98		return false;
 99
100	return stat(text, &st) == 0;
101}
102
103/*
104 * This function is called when the parser gets two kind of input:
105 *
106 * 	@cfg1 or @cfg2=config
107 *
108 * The leading '@' is stripped off before 'cfg1' and 'cfg2=config' are given to
109 * bison.  In the latter case it is necessary to keep the string intact so that
110 * the PMU kernel driver can determine what configurable is associated to
111 * 'config'.
112 */
113static int drv_str(yyscan_t scanner, int token)
114{
115	YYSTYPE *yylval = parse_events_get_lval(scanner);
116	char *text = parse_events_get_text(scanner);
117
118	/* Strip off the '@' */
119	yylval->str = strdup(text + 1);
120	return token;
121}
122
123#define REWIND(__alloc)				\
124do {								\
125	YYSTYPE *__yylval = parse_events_get_lval(yyscanner);	\
126	char *text = parse_events_get_text(yyscanner);		\
127								\
128	if (__alloc)						\
129		__yylval->str = strdup(text);			\
130								\
131	yycolumn -= strlen(text);				\
132	yyless(0);						\
133} while (0)
134
135static int pmu_str_check(yyscan_t scanner, struct parse_events_state *parse_state)
136{
137	YYSTYPE *yylval = parse_events_get_lval(scanner);
138	char *text = parse_events_get_text(scanner);
139
140	yylval->str = strdup(text);
141
142	if (parse_state->fake_pmu)
143		return PE_PMU_EVENT_FAKE;
144
145	switch (perf_pmu__parse_check(text)) {
146		case PMU_EVENT_SYMBOL_PREFIX:
147			return PE_PMU_EVENT_PRE;
148		case PMU_EVENT_SYMBOL_SUFFIX:
149			return PE_PMU_EVENT_SUF;
150		case PMU_EVENT_SYMBOL:
151			return PE_KERNEL_PMU_EVENT;
152		default:
153			return PE_NAME;
154	}
155}
156
157static int sym(yyscan_t scanner, int type, int config)
158{
159	YYSTYPE *yylval = parse_events_get_lval(scanner);
160
161	yylval->num = (type << 16) + config;
162	return type == PERF_TYPE_HARDWARE ? PE_VALUE_SYM_HW : PE_VALUE_SYM_SW;
163}
164
165static int tool(yyscan_t scanner, enum perf_tool_event event)
166{
167	YYSTYPE *yylval = parse_events_get_lval(scanner);
168
169	yylval->num = event;
170	return PE_VALUE_SYM_TOOL;
171}
172
173static int term(yyscan_t scanner, int type)
174{
175	YYSTYPE *yylval = parse_events_get_lval(scanner);
176
177	yylval->num = type;
178	return PE_TERM;
179}
180
181#define YY_USER_ACTION					\
182do {							\
183	yylloc->last_column  = yylloc->first_column;	\
184	yylloc->first_column = yycolumn;		\
185	yycolumn += yyleng;				\
186} while (0);
187
188#define USER_REJECT		\
189	yycolumn -= yyleng;	\
190	REJECT
191
192%}
193
194%x mem
195%s config
196%x event
197%x array
198
199group		[^,{}/]*[{][^}]*[}][^,{}/]*
200event_pmu	[^,{}/]+[/][^/]*[/][^,{}/]*
201event		[^,{}/]+
202bpf_object	[^,{}]+\.(o|bpf)[a-zA-Z0-9._]*
203bpf_source	[^,{}]+\.c[a-zA-Z0-9._]*
204
205num_dec		[0-9]+
206num_hex		0x[a-fA-F0-9]+
207num_raw_hex	[a-fA-F0-9]+
208name		[a-zA-Z_*?\[\]][a-zA-Z0-9_*?.\[\]]*
209name_tag	[\'][a-zA-Z_*?\[\]][a-zA-Z0-9_*?\-,\.\[\]:=]*[\']
210name_minus	[a-zA-Z_*?][a-zA-Z0-9\-_*?.:]*
211drv_cfg_term	[a-zA-Z0-9_\.]+(=[a-zA-Z0-9_*?\.:]+)?
212/* If you add a modifier you need to update check_modifier() */
213modifier_event	[ukhpPGHSDIW]+
214modifier_bp	[rwx]{1,3}
215
216%%
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
218%{
219	struct parse_events_state *_parse_state = parse_events_get_extra(yyscanner);
 
 
 
 
 
220
221	{
222		int start_token = _parse_state->stoken;
 
 
 
 
223
224		if (start_token == PE_START_TERMS)
225			BEGIN(config);
226		else if (start_token == PE_START_EVENTS)
227			BEGIN(event);
228
229		if (start_token) {
230			_parse_state->stoken = 0;
231			/*
232			 * The flex parser does not init locations variable
233			 * via the scan_string interface, so we need do the
234			 * init in here.
235			 */
236			yycolumn = 0;
237			return start_token;
238		}
239         }
240%}
241
242<event>{
 
 
 
243
244{group}		{
245			BEGIN(INITIAL);
246			REWIND(0);
247		}
248
249{event_pmu}	|
250{bpf_object}	|
251{bpf_source}	|
252{event}		{
253			BEGIN(INITIAL);
254			REWIND(1);
255			return PE_EVENT_NAME;
256		}
257
258<<EOF>>		{
259			BEGIN(INITIAL);
260			REWIND(0);
261		}
262,		{
263			return ',';
264		}
265}
266
267<array>{
268"]"			{ BEGIN(config); return ']'; }
269{num_dec}		{ return value(yyscanner, 10); }
270{num_hex}		{ return value(yyscanner, 16); }
271,			{ return ','; }
272"\.\.\."		{ return PE_ARRAY_RANGE; }
273}
274
275<config>{
276	/*
277	 * Please update config_term_names when new static term is added.
278	 */
279config			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); }
280config1			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); }
281config2			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); }
282name			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
283period			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
284freq			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); }
285branch_type		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
286time			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); }
287call-graph		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CALLGRAPH); }
288stack-size		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_STACKSIZE); }
289max-stack		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_STACK); }
290nr			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_MAX_EVENTS); }
291inherit			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_INHERIT); }
292no-inherit		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOINHERIT); }
293overwrite		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_OVERWRITE); }
294no-overwrite		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NOOVERWRITE); }
295percore			{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_PERCORE); }
296aux-output		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_OUTPUT); }
297aux-sample-size		{ return term(yyscanner, PARSE_EVENTS__TERM_TYPE_AUX_SAMPLE_SIZE); }
298r{num_raw_hex}		{ return raw(yyscanner); }
299r0x{num_raw_hex}	{ return raw(yyscanner); }
300,			{ return ','; }
301"/"			{ BEGIN(INITIAL); return '/'; }
302{name_minus}		{ return str(yyscanner, PE_NAME); }
303\[all\]			{ return PE_ARRAY_ALL; }
304"["			{ BEGIN(array); return '['; }
305@{drv_cfg_term}		{ return drv_str(yyscanner, PE_DRV_CFG_TERM); }
306}
307
308<mem>{
309{modifier_bp}		{ return str(yyscanner, PE_MODIFIER_BP); }
310:			{ return ':'; }
311"/"			{ return '/'; }
312{num_dec}		{ return value(yyscanner, 10); }
313{num_hex}		{ return value(yyscanner, 16); }
314	/*
315	 * We need to separate 'mem:' scanner part, in order to get specific
316	 * modifier bits parsed out. Otherwise we would need to handle PE_NAME
317	 * and we'd need to parse it manually. During the escape from <mem>
318	 * state we need to put the escaping char back, so we dont miss it.
319	 */
320.			{ unput(*yytext); BEGIN(INITIAL); }
321	/*
322	 * We destroy the scanner after reaching EOF,
323	 * but anyway just to be sure get back to INIT state.
324	 */
325<<EOF>>			{ BEGIN(INITIAL); }
326}
327
328cpu-cycles|cycles				{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); }
329stalled-cycles-frontend|idle-cycles-frontend	{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
330stalled-cycles-backend|idle-cycles-backend	{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
331instructions					{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); }
332cache-references				{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); }
333cache-misses					{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); }
334branch-instructions|branches			{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); }
335branch-misses					{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); }
336bus-cycles					{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); }
337ref-cycles					{ return sym(yyscanner, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); }
338cpu-clock					{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); }
339task-clock					{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); }
340page-faults|faults				{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); }
341minor-faults					{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); }
342major-faults					{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); }
343context-switches|cs				{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); }
344cpu-migrations|migrations			{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); }
345alignment-faults				{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); }
346emulation-faults				{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); }
347dummy						{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_DUMMY); }
348duration_time					{ return tool(yyscanner, PERF_TOOL_DURATION_TIME); }
349bpf-output					{ return sym(yyscanner, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_BPF_OUTPUT); }
350
351	/*
352	 * We have to handle the kernel PMU event cycles-ct/cycles-t/mem-loads/mem-stores separately.
353	 * Because the prefix cycles is mixed up with cpu-cycles.
354	 * loads and stores are mixed up with cache event
355	 */
356cycles-ct				|
357cycles-t				|
358mem-loads				|
359mem-stores				|
360topdown-[a-z-]+				|
361tx-capacity-[a-z-]+			|
362el-capacity-[a-z-]+			{ return str(yyscanner, PE_KERNEL_PMU_EVENT); }
363
364L1-dcache|l1-d|l1d|L1-data		|
365L1-icache|l1-i|l1i|L1-instruction	|
366LLC|L2					|
367dTLB|d-tlb|Data-TLB			|
368iTLB|i-tlb|Instruction-TLB		|
369branch|branches|bpu|btb|bpc		|
370node					{ return str(yyscanner, PE_NAME_CACHE_TYPE); }
371
372load|loads|read				|
373store|stores|write			|
374prefetch|prefetches			|
375speculative-read|speculative-load	|
376refs|Reference|ops|access		|
377misses|miss				{ return str(yyscanner, PE_NAME_CACHE_OP_RESULT); }
378
379mem:			{ BEGIN(mem); return PE_PREFIX_MEM; }
380r{num_raw_hex}		{ return raw(yyscanner); }
381{num_dec}		{ return value(yyscanner, 10); }
382{num_hex}		{ return value(yyscanner, 16); }
383
384{modifier_event}	{ return str(yyscanner, PE_MODIFIER_EVENT); }
385{bpf_object}		{ if (!isbpf(yyscanner)) { USER_REJECT }; return str(yyscanner, PE_BPF_OBJECT); }
386{bpf_source}		{ if (!isbpf(yyscanner)) { USER_REJECT }; return str(yyscanner, PE_BPF_SOURCE); }
387{name}			{ return pmu_str_check(yyscanner, _parse_state); }
388{name_tag}		{ return str(yyscanner, PE_NAME); }
389"/"			{ BEGIN(config); return '/'; }
390-			{ return '-'; }
391,			{ BEGIN(event); return ','; }
392:			{ return ':'; }
393"{"			{ BEGIN(event); return '{'; }
394"}"			{ return '}'; }
395=			{ return '='; }
396\n			{ }
397.			{ }
398
399%%
400
401int parse_events_wrap(void *scanner __maybe_unused)
402{
403	return 1;
404}