1%define api.pure full 2%parse-param {void *format} 3%parse-param {void *scanner} 4%lex-param {void* scanner} 5 6%{ 7 8#include <linux/compiler.h> 9#include <linux/list.h> 10#include <linux/bitmap.h> 11#include <string.h> 12#include "pmu.h" 13#include "pmu-bison.h" 14 15int perf_pmu_lex(YYSTYPE * yylval_param , void *yyscanner); 16 17#define ABORT_ON(val) \ 18do { \ 19 if (val) \ 20 YYABORT; \ 21} while (0) 22 23static void perf_pmu_error(void *format, void *scanner, const char *msg); 24 25static void perf_pmu__set_format(unsigned long *bits, long from, long to) 26{ 27 long b; 28 29 if (!to) 30 to = from; 31 32 memset(bits, 0, BITS_TO_BYTES(PERF_PMU_FORMAT_BITS)); 33 for (b = from; b <= to; b++) 34 __set_bit(b, bits); 35} 36 37%} 38 39%token PP_CONFIG 40%token PP_VALUE PP_ERROR 41%type <num> PP_VALUE 42%type <bits> bit_term 43%type <bits> bits 44 45%union 46{ 47 unsigned long num; 48 DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS); 49} 50 51%% 52 53format: 54format format_term 55| 56format_term 57 58format_term: 59PP_CONFIG ':' bits 60{ 61 perf_pmu_format__set_value(format, PERF_PMU_FORMAT_VALUE_CONFIG, $3); 62} 63| 64PP_CONFIG PP_VALUE ':' bits 65{ 66 perf_pmu_format__set_value(format, $2, $4); 67} 68 69bits: 70bits ',' bit_term 71{ 72 bitmap_or($$, $1, $3, 64); 73} 74| 75bit_term 76{ 77 memcpy($$, $1, sizeof($1)); 78} 79 80bit_term: 81PP_VALUE '-' PP_VALUE 82{ 83 perf_pmu__set_format($$, $1, $3); 84} 85| 86PP_VALUE 87{ 88 perf_pmu__set_format($$, $1, 0); 89} 90 91%% 92 93static void perf_pmu_error(void *format __maybe_unused, 94 void *scanner __maybe_unused, 95 const char *msg __maybe_unused) 96{ 97} 98