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 #include "pmu-bison.h" 15 16 int perf_pmu_lex(YYSTYPE * yylval_param , void *yyscanner); 17 18 #define ABORT_ON(val) \ 19 do { \ 20 if (val) \ 21 YYABORT; \ 22 } while (0) 23 24 %} 25 26 %token PP_CONFIG 27 %token PP_VALUE PP_ERROR 28 %type <num> PP_VALUE 29 %type <bits> bit_term 30 %type <bits> bits 31 32 %union 33 { 34 unsigned long num; 35 DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS); 36 } 37 38 %% 39 40 format: 41 format format_term 42 | 43 format_term 44 45 format_term: 46 PP_CONFIG ':' bits 47 { 48 ABORT_ON(perf_pmu__new_format(format, name, 49 PERF_PMU_FORMAT_VALUE_CONFIG, 50 $3)); 51 } 52 | 53 PP_CONFIG PP_VALUE ':' bits 54 { 55 ABORT_ON(perf_pmu__new_format(format, name, 56 $2, 57 $4)); 58 } 59 60 bits: 61 bits ',' bit_term 62 { 63 bitmap_or($$, $1, $3, 64); 64 } 65 | 66 bit_term 67 { 68 memcpy($$, $1, sizeof($1)); 69 } 70 71 bit_term: 72 PP_VALUE '-' PP_VALUE 73 { 74 perf_pmu__set_format($$, $1, $3); 75 } 76 | 77 PP_VALUE 78 { 79 perf_pmu__set_format($$, $1, 0); 80 } 81 82 %% 83 84 void perf_pmu_error(struct list_head *list __maybe_unused, 85 char *name __maybe_unused, 86 void *scanner __maybe_unused, 87 char const *msg __maybe_unused) 88 { 89 } 90