Commit | Line | Data |
---|---|---|
ac20de6f | 1 | %pure-parser |
46010ab2 | 2 | %parse-param {void *_data} |
ac20de6f ZY |
3 | %parse-param {void *scanner} |
4 | %lex-param {void* scanner} | |
6297d423 | 5 | %locations |
89812fc8 JO |
6 | |
7 | %{ | |
8 | ||
9 | #define YYDEBUG 1 | |
10 | ||
11 | #include <linux/compiler.h> | |
12 | #include <linux/list.h> | |
d944c4ee | 13 | #include <linux/types.h> |
89812fc8 | 14 | #include "util.h" |
231bb2aa | 15 | #include "pmu.h" |
f2361024 | 16 | #include "debug.h" |
89812fc8 | 17 | #include "parse-events.h" |
ac20de6f | 18 | #include "parse-events-bison.h" |
89812fc8 | 19 | |
34a0548f ACM |
20 | void parse_events_error(YYLTYPE *loc, void *data, void *scanner, char const *msg); |
21 | ||
89812fc8 JO |
22 | #define ABORT_ON(val) \ |
23 | do { \ | |
24 | if (val) \ | |
25 | YYABORT; \ | |
26 | } while (0) | |
27 | ||
c5cd8ac0 DA |
28 | #define ALLOC_LIST(list) \ |
29 | do { \ | |
30 | list = malloc(sizeof(*list)); \ | |
31 | ABORT_ON(!list); \ | |
32 | INIT_LIST_HEAD(list); \ | |
33 | } while (0) | |
34 | ||
07ef7574 | 35 | static void inc_group_count(struct list_head *list, |
5d369a75 | 36 | struct parse_events_state *data) |
97f63e4a NK |
37 | { |
38 | /* Count groups only have more than 1 members */ | |
39 | if (!list_is_last(list->next, list)) | |
40 | data->nr_groups++; | |
41 | } | |
42 | ||
89812fc8 JO |
43 | %} |
44 | ||
90e2b22d | 45 | %token PE_START_EVENTS PE_START_TERMS |
cf3506dc | 46 | %token PE_VALUE PE_VALUE_SYM_HW PE_VALUE_SYM_SW PE_RAW PE_TERM |
ac2ba9f3 | 47 | %token PE_EVENT_NAME |
89812fc8 | 48 | %token PE_NAME |
d509db04 | 49 | %token PE_BPF_OBJECT PE_BPF_SOURCE |
89812fc8 JO |
50 | %token PE_MODIFIER_EVENT PE_MODIFIER_BP |
51 | %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT | |
89efb029 | 52 | %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP |
89812fc8 | 53 | %token PE_ERROR |
ba32a451 | 54 | %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT |
e571e029 | 55 | %token PE_ARRAY_ALL PE_ARRAY_RANGE |
dd60fba7 | 56 | %token PE_DRV_CFG_TERM |
89812fc8 | 57 | %type <num> PE_VALUE |
cf3506dc JO |
58 | %type <num> PE_VALUE_SYM_HW |
59 | %type <num> PE_VALUE_SYM_SW | |
89812fc8 | 60 | %type <num> PE_RAW |
8f707d84 | 61 | %type <num> PE_TERM |
89812fc8 | 62 | %type <str> PE_NAME |
84c86ca1 | 63 | %type <str> PE_BPF_OBJECT |
d509db04 | 64 | %type <str> PE_BPF_SOURCE |
89812fc8 JO |
65 | %type <str> PE_NAME_CACHE_TYPE |
66 | %type <str> PE_NAME_CACHE_OP_RESULT | |
67 | %type <str> PE_MODIFIER_EVENT | |
68 | %type <str> PE_MODIFIER_BP | |
ac2ba9f3 | 69 | %type <str> PE_EVENT_NAME |
ba32a451 | 70 | %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT |
dd60fba7 | 71 | %type <str> PE_DRV_CFG_TERM |
cf3506dc | 72 | %type <num> value_sym |
8f707d84 | 73 | %type <head> event_config |
1d55e8ef | 74 | %type <head> opt_event_config |
8f707d84 | 75 | %type <term> event_term |
b847cbdc JO |
76 | %type <head> event_pmu |
77 | %type <head> event_legacy_symbol | |
78 | %type <head> event_legacy_cache | |
79 | %type <head> event_legacy_mem | |
80 | %type <head> event_legacy_tracepoint | |
865582c3 | 81 | %type <tracepoint_name> tracepoint_name |
b847cbdc JO |
82 | %type <head> event_legacy_numeric |
83 | %type <head> event_legacy_raw | |
84c86ca1 | 84 | %type <head> event_bpf_file |
b847cbdc | 85 | %type <head> event_def |
ac2ba9f3 RR |
86 | %type <head> event_mod |
87 | %type <head> event_name | |
89efb029 JO |
88 | %type <head> event |
89 | %type <head> events | |
90 | %type <head> group_def | |
91 | %type <head> group | |
92 | %type <head> groups | |
e571e029 WN |
93 | %type <array> array |
94 | %type <array> array_term | |
95 | %type <array> array_terms | |
89812fc8 JO |
96 | |
97 | %union | |
98 | { | |
99 | char *str; | |
b527bab5 | 100 | u64 num; |
8f707d84 | 101 | struct list_head *head; |
6cee6cd3 | 102 | struct parse_events_term *term; |
865582c3 HK |
103 | struct tracepoint_name { |
104 | char *sys; | |
105 | char *event; | |
106 | } tracepoint_name; | |
e571e029 | 107 | struct parse_events_array array; |
89812fc8 JO |
108 | } |
109 | %% | |
110 | ||
90e2b22d | 111 | start: |
89efb029 | 112 | PE_START_EVENTS start_events |
90e2b22d | 113 | | |
89efb029 JO |
114 | PE_START_TERMS start_terms |
115 | ||
116 | start_events: groups | |
117 | { | |
5d369a75 | 118 | struct parse_events_state *data = _data; |
89efb029 JO |
119 | |
120 | parse_events_update_lists($1, &data->list); | |
121 | } | |
122 | ||
123 | groups: | |
124 | groups ',' group | |
125 | { | |
126 | struct list_head *list = $1; | |
127 | struct list_head *group = $3; | |
128 | ||
129 | parse_events_update_lists(group, list); | |
130 | $$ = list; | |
131 | } | |
132 | | | |
133 | groups ',' event | |
134 | { | |
135 | struct list_head *list = $1; | |
136 | struct list_head *event = $3; | |
137 | ||
138 | parse_events_update_lists(event, list); | |
139 | $$ = list; | |
140 | } | |
141 | | | |
142 | group | |
143 | | | |
144 | event | |
145 | ||
146 | group: | |
147 | group_def ':' PE_MODIFIER_EVENT | |
148 | { | |
149 | struct list_head *list = $1; | |
150 | ||
151 | ABORT_ON(parse_events__modifier_group(list, $3)); | |
152 | $$ = list; | |
153 | } | |
154 | | | |
155 | group_def | |
156 | ||
157 | group_def: | |
158 | PE_NAME '{' events '}' | |
159 | { | |
160 | struct list_head *list = $3; | |
161 | ||
97f63e4a | 162 | inc_group_count(list, _data); |
63dab225 | 163 | parse_events__set_leader($1, list); |
89efb029 JO |
164 | $$ = list; |
165 | } | |
166 | | | |
167 | '{' events '}' | |
168 | { | |
169 | struct list_head *list = $2; | |
170 | ||
97f63e4a | 171 | inc_group_count(list, _data); |
63dab225 | 172 | parse_events__set_leader(NULL, list); |
89efb029 JO |
173 | $$ = list; |
174 | } | |
90e2b22d | 175 | |
89812fc8 | 176 | events: |
89efb029 JO |
177 | events ',' event |
178 | { | |
179 | struct list_head *event = $3; | |
180 | struct list_head *list = $1; | |
181 | ||
182 | parse_events_update_lists(event, list); | |
183 | $$ = list; | |
184 | } | |
185 | | | |
186 | event | |
89812fc8 | 187 | |
ac2ba9f3 RR |
188 | event: event_mod |
189 | ||
190 | event_mod: | |
191 | event_name PE_MODIFIER_EVENT | |
89812fc8 | 192 | { |
89efb029 | 193 | struct list_head *list = $1; |
46010ab2 | 194 | |
5d7be90e JO |
195 | /* |
196 | * Apply modifier on all events added by single event definition | |
197 | * (there could be more events added for multiple tracepoint | |
198 | * definitions via '*?'. | |
199 | */ | |
f5b1135b | 200 | ABORT_ON(parse_events__modifier_event(list, $2, false)); |
89efb029 | 201 | $$ = list; |
89812fc8 JO |
202 | } |
203 | | | |
ac2ba9f3 RR |
204 | event_name |
205 | ||
206 | event_name: | |
207 | PE_EVENT_NAME event_def | |
208 | { | |
209 | ABORT_ON(parse_events_name($2, $1)); | |
210 | free($1); | |
211 | $$ = $2; | |
212 | } | |
213 | | | |
89812fc8 JO |
214 | event_def |
215 | ||
5f537a26 JO |
216 | event_def: event_pmu | |
217 | event_legacy_symbol | | |
89812fc8 JO |
218 | event_legacy_cache sep_dc | |
219 | event_legacy_mem | | |
220 | event_legacy_tracepoint sep_dc | | |
221 | event_legacy_numeric sep_dc | | |
84c86ca1 WN |
222 | event_legacy_raw sep_dc | |
223 | event_bpf_file | |
89812fc8 | 224 | |
5f537a26 | 225 | event_pmu: |
bb109acc | 226 | PE_NAME opt_event_config |
5f537a26 | 227 | { |
8255718f AK |
228 | struct list_head *list, *orig_terms, *terms; |
229 | ||
230 | if (parse_events_copy_term_list($2, &orig_terms)) | |
231 | YYABORT; | |
b847cbdc | 232 | |
c5cd8ac0 | 233 | ALLOC_LIST(list); |
07806a1d | 234 | if (parse_events_add_pmu(_data, list, $1, $2)) { |
8255718f AK |
235 | struct perf_pmu *pmu = NULL; |
236 | int ok = 0; | |
237 | ||
238 | while ((pmu = perf_pmu__scan(pmu)) != NULL) { | |
239 | char *name = pmu->name; | |
240 | ||
a820e335 AK |
241 | if (!strncmp(name, "uncore_", 7) && |
242 | strncmp($1, "uncore_", 7)) | |
243 | name += 7; | |
8255718f AK |
244 | if (!strncmp($1, name, strlen($1))) { |
245 | if (parse_events_copy_term_list(orig_terms, &terms)) | |
246 | YYABORT; | |
07806a1d | 247 | if (!parse_events_add_pmu(_data, list, pmu->name, terms)) |
8255718f AK |
248 | ok++; |
249 | parse_events_terms__delete(terms); | |
250 | } | |
251 | } | |
252 | if (!ok) | |
253 | YYABORT; | |
254 | } | |
bb109acc | 255 | parse_events_terms__delete($2); |
8255718f | 256 | parse_events_terms__delete(orig_terms); |
b847cbdc | 257 | $$ = list; |
5f537a26 | 258 | } |
ad962273 | 259 | | |
ba32a451 KL |
260 | PE_KERNEL_PMU_EVENT sep_dc |
261 | { | |
ba32a451 KL |
262 | struct list_head *list; |
263 | ||
2073ad33 | 264 | if (parse_events_multi_pmu_add(_data, $1, &list) < 0) |
231bb2aa | 265 | YYABORT; |
ba32a451 KL |
266 | $$ = list; |
267 | } | |
268 | | | |
269 | PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc | |
270 | { | |
ba32a451 KL |
271 | struct list_head *list; |
272 | char pmu_name[128]; | |
ba32a451 | 273 | |
8255718f AK |
274 | snprintf(&pmu_name, 128, "%s-%s", $1, $3); |
275 | if (parse_events_multi_pmu_add(_data, pmu_name, &list) < 0) | |
276 | YYABORT; | |
ba32a451 KL |
277 | $$ = list; |
278 | } | |
5f537a26 | 279 | |
cf3506dc JO |
280 | value_sym: |
281 | PE_VALUE_SYM_HW | |
282 | | | |
283 | PE_VALUE_SYM_SW | |
284 | ||
89812fc8 | 285 | event_legacy_symbol: |
cf3506dc | 286 | value_sym '/' event_config '/' |
89812fc8 | 287 | { |
c5cd8ac0 | 288 | struct list_head *list; |
89812fc8 JO |
289 | int type = $1 >> 16; |
290 | int config = $1 & 255; | |
291 | ||
c5cd8ac0 | 292 | ALLOC_LIST(list); |
07806a1d | 293 | ABORT_ON(parse_events_add_numeric(_data, list, type, config, $3)); |
2146afc6 | 294 | parse_events_terms__delete($3); |
b847cbdc | 295 | $$ = list; |
8f707d84 JO |
296 | } |
297 | | | |
cf3506dc | 298 | value_sym sep_slash_dc |
8f707d84 | 299 | { |
c5cd8ac0 | 300 | struct list_head *list; |
8f707d84 JO |
301 | int type = $1 >> 16; |
302 | int config = $1 & 255; | |
303 | ||
c5cd8ac0 | 304 | ALLOC_LIST(list); |
07806a1d | 305 | ABORT_ON(parse_events_add_numeric(_data, list, type, config, NULL)); |
b847cbdc | 306 | $$ = list; |
89812fc8 JO |
307 | } |
308 | ||
309 | event_legacy_cache: | |
43d0b978 | 310 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT '-' PE_NAME_CACHE_OP_RESULT opt_event_config |
89812fc8 | 311 | { |
5d369a75 | 312 | struct parse_events_state *data = _data; |
43d0b978 | 313 | struct parse_events_error *error = data->error; |
c5cd8ac0 | 314 | struct list_head *list; |
b847cbdc | 315 | |
c5cd8ac0 | 316 | ALLOC_LIST(list); |
43d0b978 WN |
317 | ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, $5, error, $6)); |
318 | parse_events_terms__delete($6); | |
b847cbdc | 319 | $$ = list; |
89812fc8 JO |
320 | } |
321 | | | |
43d0b978 | 322 | PE_NAME_CACHE_TYPE '-' PE_NAME_CACHE_OP_RESULT opt_event_config |
89812fc8 | 323 | { |
5d369a75 | 324 | struct parse_events_state *data = _data; |
43d0b978 | 325 | struct parse_events_error *error = data->error; |
c5cd8ac0 | 326 | struct list_head *list; |
b847cbdc | 327 | |
c5cd8ac0 | 328 | ALLOC_LIST(list); |
43d0b978 WN |
329 | ABORT_ON(parse_events_add_cache(list, &data->idx, $1, $3, NULL, error, $4)); |
330 | parse_events_terms__delete($4); | |
b847cbdc | 331 | $$ = list; |
89812fc8 JO |
332 | } |
333 | | | |
43d0b978 | 334 | PE_NAME_CACHE_TYPE opt_event_config |
89812fc8 | 335 | { |
5d369a75 | 336 | struct parse_events_state *data = _data; |
43d0b978 | 337 | struct parse_events_error *error = data->error; |
c5cd8ac0 | 338 | struct list_head *list; |
b847cbdc | 339 | |
c5cd8ac0 | 340 | ALLOC_LIST(list); |
43d0b978 WN |
341 | ABORT_ON(parse_events_add_cache(list, &data->idx, $1, NULL, NULL, error, $2)); |
342 | parse_events_terms__delete($2); | |
b847cbdc | 343 | $$ = list; |
89812fc8 JO |
344 | } |
345 | ||
346 | event_legacy_mem: | |
3741eb9f JS |
347 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE ':' PE_MODIFIER_BP sep_dc |
348 | { | |
5d369a75 | 349 | struct parse_events_state *data = _data; |
3741eb9f JS |
350 | struct list_head *list; |
351 | ||
352 | ALLOC_LIST(list); | |
353 | ABORT_ON(parse_events_add_breakpoint(list, &data->idx, | |
354 | (void *) $2, $6, $4)); | |
355 | $$ = list; | |
356 | } | |
357 | | | |
358 | PE_PREFIX_MEM PE_VALUE '/' PE_VALUE sep_dc | |
359 | { | |
5d369a75 | 360 | struct parse_events_state *data = _data; |
3741eb9f JS |
361 | struct list_head *list; |
362 | ||
363 | ALLOC_LIST(list); | |
364 | ABORT_ON(parse_events_add_breakpoint(list, &data->idx, | |
365 | (void *) $2, NULL, $4)); | |
366 | $$ = list; | |
367 | } | |
368 | | | |
89812fc8 JO |
369 | PE_PREFIX_MEM PE_VALUE ':' PE_MODIFIER_BP sep_dc |
370 | { | |
5d369a75 | 371 | struct parse_events_state *data = _data; |
c5cd8ac0 | 372 | struct list_head *list; |
b847cbdc | 373 | |
c5cd8ac0 DA |
374 | ALLOC_LIST(list); |
375 | ABORT_ON(parse_events_add_breakpoint(list, &data->idx, | |
3741eb9f | 376 | (void *) $2, $4, 0)); |
b847cbdc | 377 | $$ = list; |
89812fc8 JO |
378 | } |
379 | | | |
380 | PE_PREFIX_MEM PE_VALUE sep_dc | |
381 | { | |
5d369a75 | 382 | struct parse_events_state *data = _data; |
c5cd8ac0 | 383 | struct list_head *list; |
b847cbdc | 384 | |
c5cd8ac0 DA |
385 | ALLOC_LIST(list); |
386 | ABORT_ON(parse_events_add_breakpoint(list, &data->idx, | |
3741eb9f | 387 | (void *) $2, NULL, 0)); |
b847cbdc | 388 | $$ = list; |
89812fc8 JO |
389 | } |
390 | ||
391 | event_legacy_tracepoint: | |
1d55e8ef | 392 | tracepoint_name opt_event_config |
2b9032e0 | 393 | { |
5d369a75 | 394 | struct parse_events_state *data = _data; |
19658171 | 395 | struct parse_events_error *error = data->error; |
2b9032e0 | 396 | struct list_head *list; |
2b9032e0 AY |
397 | |
398 | ALLOC_LIST(list); | |
e637d177 HK |
399 | if (error) |
400 | error->idx = @1.first_column; | |
401 | ||
865582c3 | 402 | if (parse_events_add_tracepoint(list, &data->idx, $1.sys, $1.event, |
1d55e8ef | 403 | error, $2)) |
e637d177 HK |
404 | return -1; |
405 | ||
2b9032e0 AY |
406 | $$ = list; |
407 | } | |
865582c3 HK |
408 | |
409 | tracepoint_name: | |
410 | PE_NAME '-' PE_NAME ':' PE_NAME | |
411 | { | |
412 | char sys_name[128]; | |
413 | struct tracepoint_name tracepoint; | |
414 | ||
415 | snprintf(&sys_name, 128, "%s-%s", $1, $3); | |
416 | tracepoint.sys = &sys_name; | |
417 | tracepoint.event = $5; | |
418 | ||
419 | $$ = tracepoint; | |
420 | } | |
2b9032e0 | 421 | | |
89812fc8 JO |
422 | PE_NAME ':' PE_NAME |
423 | { | |
865582c3 | 424 | struct tracepoint_name tracepoint = {$1, $3}; |
b847cbdc | 425 | |
865582c3 | 426 | $$ = tracepoint; |
89812fc8 JO |
427 | } |
428 | ||
429 | event_legacy_numeric: | |
10bf358a | 430 | PE_VALUE ':' PE_VALUE opt_event_config |
89812fc8 | 431 | { |
c5cd8ac0 | 432 | struct list_head *list; |
b847cbdc | 433 | |
c5cd8ac0 | 434 | ALLOC_LIST(list); |
07806a1d | 435 | ABORT_ON(parse_events_add_numeric(_data, list, (u32)$1, $3, $4)); |
10bf358a | 436 | parse_events_terms__delete($4); |
b847cbdc | 437 | $$ = list; |
89812fc8 JO |
438 | } |
439 | ||
440 | event_legacy_raw: | |
10bf358a | 441 | PE_RAW opt_event_config |
89812fc8 | 442 | { |
c5cd8ac0 | 443 | struct list_head *list; |
b847cbdc | 444 | |
c5cd8ac0 | 445 | ALLOC_LIST(list); |
07806a1d | 446 | ABORT_ON(parse_events_add_numeric(_data, list, PERF_TYPE_RAW, $1, $2)); |
10bf358a | 447 | parse_events_terms__delete($2); |
b847cbdc | 448 | $$ = list; |
8f707d84 JO |
449 | } |
450 | ||
84c86ca1 | 451 | event_bpf_file: |
a34f3be7 | 452 | PE_BPF_OBJECT opt_event_config |
84c86ca1 | 453 | { |
5d369a75 | 454 | struct parse_events_state *data = _data; |
84c86ca1 WN |
455 | struct parse_events_error *error = data->error; |
456 | struct list_head *list; | |
457 | ||
458 | ALLOC_LIST(list); | |
a34f3be7 WN |
459 | ABORT_ON(parse_events_load_bpf(data, list, $1, false, $2)); |
460 | parse_events_terms__delete($2); | |
d509db04 WN |
461 | $$ = list; |
462 | } | |
463 | | | |
a34f3be7 | 464 | PE_BPF_SOURCE opt_event_config |
d509db04 | 465 | { |
d509db04 WN |
466 | struct list_head *list; |
467 | ||
468 | ALLOC_LIST(list); | |
07806a1d | 469 | ABORT_ON(parse_events_load_bpf(_data, list, $1, true, $2)); |
a34f3be7 | 470 | parse_events_terms__delete($2); |
84c86ca1 WN |
471 | $$ = list; |
472 | } | |
473 | ||
1d55e8ef ACM |
474 | opt_event_config: |
475 | '/' event_config '/' | |
476 | { | |
477 | $$ = $2; | |
478 | } | |
479 | | | |
480 | '/' '/' | |
481 | { | |
482 | $$ = NULL; | |
483 | } | |
484 | | | |
485 | { | |
486 | $$ = NULL; | |
487 | } | |
488 | ||
89efb029 | 489 | start_terms: event_config |
90e2b22d | 490 | { |
23b6339b | 491 | struct parse_events_terms *data = _data; |
90e2b22d JO |
492 | data->terms = $1; |
493 | } | |
494 | ||
8f707d84 JO |
495 | event_config: |
496 | event_config ',' event_term | |
497 | { | |
498 | struct list_head *head = $1; | |
6cee6cd3 | 499 | struct parse_events_term *term = $3; |
8f707d84 JO |
500 | |
501 | ABORT_ON(!head); | |
502 | list_add_tail(&term->list, head); | |
503 | $$ = $1; | |
504 | } | |
505 | | | |
506 | event_term | |
507 | { | |
508 | struct list_head *head = malloc(sizeof(*head)); | |
6cee6cd3 | 509 | struct parse_events_term *term = $1; |
8f707d84 JO |
510 | |
511 | ABORT_ON(!head); | |
512 | INIT_LIST_HEAD(head); | |
513 | list_add_tail(&term->list, head); | |
514 | $$ = head; | |
515 | } | |
516 | ||
517 | event_term: | |
518 | PE_NAME '=' PE_NAME | |
519 | { | |
6cee6cd3 | 520 | struct parse_events_term *term; |
8f707d84 | 521 | |
6cee6cd3 | 522 | ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, |
cecf3a2e | 523 | $1, $3, &@1, &@3)); |
8f707d84 JO |
524 | $$ = term; |
525 | } | |
526 | | | |
527 | PE_NAME '=' PE_VALUE | |
528 | { | |
6cee6cd3 | 529 | struct parse_events_term *term; |
8f707d84 | 530 | |
6cee6cd3 | 531 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
99e7138e | 532 | $1, $3, false, &@1, &@3)); |
8f707d84 JO |
533 | $$ = term; |
534 | } | |
535 | | | |
1d33d6dc JO |
536 | PE_NAME '=' PE_VALUE_SYM_HW |
537 | { | |
6cee6cd3 | 538 | struct parse_events_term *term; |
1d33d6dc JO |
539 | int config = $3 & 255; |
540 | ||
6cee6cd3 | 541 | ABORT_ON(parse_events_term__sym_hw(&term, $1, config)); |
1d33d6dc JO |
542 | $$ = term; |
543 | } | |
544 | | | |
8f707d84 JO |
545 | PE_NAME |
546 | { | |
6cee6cd3 | 547 | struct parse_events_term *term; |
8f707d84 | 548 | |
6cee6cd3 | 549 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, |
99e7138e | 550 | $1, 1, true, &@1, NULL)); |
8f707d84 JO |
551 | $$ = term; |
552 | } | |
553 | | | |
1d33d6dc JO |
554 | PE_VALUE_SYM_HW |
555 | { | |
6cee6cd3 | 556 | struct parse_events_term *term; |
1d33d6dc JO |
557 | int config = $1 & 255; |
558 | ||
6cee6cd3 | 559 | ABORT_ON(parse_events_term__sym_hw(&term, NULL, config)); |
1d33d6dc JO |
560 | $$ = term; |
561 | } | |
562 | | | |
6b5fc39b JO |
563 | PE_TERM '=' PE_NAME |
564 | { | |
6cee6cd3 | 565 | struct parse_events_term *term; |
6b5fc39b | 566 | |
cecf3a2e | 567 | ABORT_ON(parse_events_term__str(&term, (int)$1, NULL, $3, &@1, &@3)); |
6b5fc39b JO |
568 | $$ = term; |
569 | } | |
570 | | | |
8f707d84 JO |
571 | PE_TERM '=' PE_VALUE |
572 | { | |
6cee6cd3 | 573 | struct parse_events_term *term; |
8f707d84 | 574 | |
99e7138e | 575 | ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, $3, false, &@1, &@3)); |
8f707d84 JO |
576 | $$ = term; |
577 | } | |
578 | | | |
579 | PE_TERM | |
580 | { | |
6cee6cd3 | 581 | struct parse_events_term *term; |
8f707d84 | 582 | |
99e7138e | 583 | ABORT_ON(parse_events_term__num(&term, (int)$1, NULL, 1, true, &@1, NULL)); |
8f707d84 | 584 | $$ = term; |
89812fc8 | 585 | } |
e571e029 WN |
586 | | |
587 | PE_NAME array '=' PE_NAME | |
588 | { | |
589 | struct parse_events_term *term; | |
590 | int i; | |
591 | ||
592 | ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_USER, | |
593 | $1, $4, &@1, &@4)); | |
594 | ||
595 | term->array = $2; | |
596 | $$ = term; | |
597 | } | |
598 | | | |
599 | PE_NAME array '=' PE_VALUE | |
600 | { | |
601 | struct parse_events_term *term; | |
602 | ||
603 | ABORT_ON(parse_events_term__num(&term, PARSE_EVENTS__TERM_TYPE_USER, | |
99e7138e | 604 | $1, $4, false, &@1, &@4)); |
e571e029 WN |
605 | term->array = $2; |
606 | $$ = term; | |
607 | } | |
dd60fba7 MP |
608 | | |
609 | PE_DRV_CFG_TERM | |
610 | { | |
611 | struct parse_events_term *term; | |
612 | ||
613 | ABORT_ON(parse_events_term__str(&term, PARSE_EVENTS__TERM_TYPE_DRV_CFG, | |
614 | $1, $1, &@1, NULL)); | |
615 | $$ = term; | |
616 | } | |
e571e029 WN |
617 | |
618 | array: | |
619 | '[' array_terms ']' | |
620 | { | |
621 | $$ = $2; | |
622 | } | |
623 | | | |
624 | PE_ARRAY_ALL | |
625 | { | |
626 | $$.nr_ranges = 0; | |
627 | $$.ranges = NULL; | |
628 | } | |
629 | ||
630 | array_terms: | |
631 | array_terms ',' array_term | |
632 | { | |
633 | struct parse_events_array new_array; | |
634 | ||
635 | new_array.nr_ranges = $1.nr_ranges + $3.nr_ranges; | |
636 | new_array.ranges = malloc(sizeof(new_array.ranges[0]) * | |
637 | new_array.nr_ranges); | |
638 | ABORT_ON(!new_array.ranges); | |
639 | memcpy(&new_array.ranges[0], $1.ranges, | |
640 | $1.nr_ranges * sizeof(new_array.ranges[0])); | |
641 | memcpy(&new_array.ranges[$1.nr_ranges], $3.ranges, | |
642 | $3.nr_ranges * sizeof(new_array.ranges[0])); | |
643 | free($1.ranges); | |
644 | free($3.ranges); | |
645 | $$ = new_array; | |
646 | } | |
647 | | | |
648 | array_term | |
649 | ||
650 | array_term: | |
651 | PE_VALUE | |
652 | { | |
653 | struct parse_events_array array; | |
654 | ||
655 | array.nr_ranges = 1; | |
656 | array.ranges = malloc(sizeof(array.ranges[0])); | |
657 | ABORT_ON(!array.ranges); | |
658 | array.ranges[0].start = $1; | |
659 | array.ranges[0].length = 1; | |
660 | $$ = array; | |
661 | } | |
662 | | | |
663 | PE_VALUE PE_ARRAY_RANGE PE_VALUE | |
664 | { | |
665 | struct parse_events_array array; | |
666 | ||
667 | ABORT_ON($3 < $1); | |
668 | array.nr_ranges = 1; | |
669 | array.ranges = malloc(sizeof(array.ranges[0])); | |
670 | ABORT_ON(!array.ranges); | |
671 | array.ranges[0].start = $1; | |
672 | array.ranges[0].length = $3 - $1 + 1; | |
673 | $$ = array; | |
674 | } | |
89812fc8 JO |
675 | |
676 | sep_dc: ':' | | |
677 | ||
8f707d84 JO |
678 | sep_slash_dc: '/' | ':' | |
679 | ||
89812fc8 JO |
680 | %% |
681 | ||
6297d423 JO |
682 | void parse_events_error(YYLTYPE *loc, void *data, |
683 | void *scanner __maybe_unused, | |
1d037ca1 | 684 | char const *msg __maybe_unused) |
89812fc8 | 685 | { |
6297d423 | 686 | parse_events_evlist_error(data, loc->last_column, "parser error"); |
89812fc8 | 687 | } |