2 %option prefix="parse_events_"
7 #include "parse-events-bison.h"
8 #include "parse-events.h"
10 static int __value(char *str, int base, int token)
15 num = strtoul(str, NULL, base);
19 parse_events_lval.num = num;
23 static int value(int base)
25 return __value(parse_events_text, base, PE_VALUE);
30 return __value(parse_events_text + 1, 16, PE_RAW);
33 static int str(int token)
35 parse_events_lval.str = strdup(parse_events_text);
39 static int sym(int type, int config)
41 parse_events_lval.num = (type << 16) + config;
45 static int term(int type)
47 parse_events_lval.num = type;
54 num_hex 0x[a-fA-F0-9]+
55 num_raw_hex [a-fA-F0-9]+
56 name [a-zA-Z_*?][a-zA-Z0-9_*?]*
57 modifier_event [ukhpGH]{1,8}
61 cpu-cycles|cycles { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES); }
62 stalled-cycles-frontend|idle-cycles-frontend { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND); }
63 stalled-cycles-backend|idle-cycles-backend { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND); }
64 instructions { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS); }
65 cache-references { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES); }
66 cache-misses { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES); }
67 branch-instructions|branches { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS); }
68 branch-misses { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES); }
69 bus-cycles { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_BUS_CYCLES); }
70 ref-cycles { return sym(PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES); }
71 cpu-clock { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK); }
72 task-clock { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK); }
73 page-faults|faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS); }
74 minor-faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN); }
75 major-faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MAJ); }
76 context-switches|cs { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CONTEXT_SWITCHES); }
77 cpu-migrations|migrations { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS); }
78 alignment-faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_ALIGNMENT_FAULTS); }
79 emulation-faults { return sym(PERF_TYPE_SOFTWARE, PERF_COUNT_SW_EMULATION_FAULTS); }
81 L1-dcache|l1-d|l1d|L1-data |
82 L1-icache|l1-i|l1i|L1-instruction |
85 iTLB|i-tlb|Instruction-TLB |
86 branch|branches|bpu|btb|bpc |
87 node { return str(PE_NAME_CACHE_TYPE); }
92 speculative-read|speculative-load |
93 refs|Reference|ops|access |
94 misses|miss { return str(PE_NAME_CACHE_OP_RESULT); }
97 * These are event config hardcoded term names to be specified
98 * within xxx/.../ syntax. So far we dont clash with other names,
99 * so we can put them here directly. In case the we have a conflict
100 * in future, this needs to go into '//' condition block.
102 config { return term(PARSE_EVENTS__TERM_TYPE_CONFIG); }
103 config1 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG1); }
104 config2 { return term(PARSE_EVENTS__TERM_TYPE_CONFIG2); }
105 period { return term(PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
106 branch_type { return term(PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
108 mem: { return PE_PREFIX_MEM; }
109 r{num_raw_hex} { return raw(); }
110 {num_dec} { return value(10); }
111 {num_hex} { return value(16); }
113 {modifier_event} { return str(PE_MODIFIER_EVENT); }
114 {modifier_bp} { return str(PE_MODIFIER_BP); }
115 {name} { return str(PE_NAME); }
124 int parse_events_wrap(void)