diff options
author | Ian Rogers <irogers@google.com> | 2021-09-23 10:46:09 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2021-09-29 19:41:49 +0300 |
commit | c924e0cc0576b4e45b9c495174cd785aa41d51ad (patch) | |
tree | 8257479edf689ce0d12f161606ab0285b0b6184f /tools/perf/util/expr.y | |
parent | e87576c5ac14e038ac96145d289bf0134eb08506 (diff) | |
download | linux-c924e0cc0576b4e45b9c495174cd785aa41d51ad.tar.xz |
perf expr: Move actions to the left.
No functional change, just modifying whitespace. This creates additional
space for adding logic to actions in later changes.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: John Garry <john.garry@huawei.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sandeep Dasgupta <sdasgup@google.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20210923074616.674826-7-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/expr.y')
-rw-r--r-- | tools/perf/util/expr.y | 124 |
1 files changed, 75 insertions, 49 deletions
diff --git a/tools/perf/util/expr.y b/tools/perf/util/expr.y index 5535badeef0a..78cbe377eb0e 100644 --- a/tools/perf/util/expr.y +++ b/tools/perf/util/expr.y @@ -70,54 +70,80 @@ MIN | MAX | IF | ELSE | SMT_ON | NUMBER | '|' | '^' | '&' | '-' | '+' | '*' | '/ '<' | '>' | D_RATIO all_expr: if_expr { *final_val = $1; } - ; - -if_expr: - expr IF expr ELSE expr { $$ = $3 ? $1 : $5; } - | expr - ; - -expr: NUMBER - | ID { - struct expr_id_data *data; - - $$ = NAN; - if (expr__resolve_id(ctx, $1, &data) == 0) - $$ = expr_id_data__value(data); - - free($1); - } - | expr '|' expr { BINARY_LONG_OP($$, |, $1, $3); } - | expr '&' expr { BINARY_LONG_OP($$, &, $1, $3); } - | expr '^' expr { BINARY_LONG_OP($$, ^, $1, $3); } - | expr '<' expr { BINARY_OP($$, <, $1, $3); } - | expr '>' expr { BINARY_OP($$, >, $1, $3); } - | expr '+' expr { BINARY_OP($$, +, $1, $3); } - | expr '-' expr { BINARY_OP($$, -, $1, $3); } - | expr '*' expr { BINARY_OP($$, *, $1, $3); } - | expr '/' expr { if ($3 == 0) { - pr_debug("division by zero\n"); - YYABORT; - } - $$ = $1 / $3; - } - | expr '%' expr { if ((long)$3 == 0) { - pr_debug("division by zero\n"); - YYABORT; - } - $$ = (long)$1 % (long)$3; - } - | '-' expr %prec NEG { $$ = -$2; } - | '(' if_expr ')' { $$ = $2; } - | MIN '(' expr ',' expr ')' { $$ = $3 < $5 ? $3 : $5; } - | MAX '(' expr ',' expr ')' { $$ = $3 > $5 ? $3 : $5; } - | SMT_ON { $$ = smt_on() > 0; } - | D_RATIO '(' expr ',' expr ')' { if ($5 == 0) { - $$ = 0; - } else { - $$ = $3 / $5; - } - } - ; + +if_expr: expr IF expr ELSE expr +{ + $$ = $3 ? $1 : $5; +} +| expr +; + +expr: NUMBER +{ + $$ = $1; +} +| ID +{ + struct expr_id_data *data; + + $$ = NAN; + if (expr__resolve_id(ctx, $1, &data) == 0) + $$ = expr_id_data__value(data); + + free($1); +} +| expr '|' expr { BINARY_LONG_OP($$, |, $1, $3); } +| expr '&' expr { BINARY_LONG_OP($$, &, $1, $3); } +| expr '^' expr { BINARY_LONG_OP($$, ^, $1, $3); } +| expr '<' expr { BINARY_OP($$, <, $1, $3); } +| expr '>' expr { BINARY_OP($$, >, $1, $3); } +| expr '+' expr { BINARY_OP($$, +, $1, $3); } +| expr '-' expr { BINARY_OP($$, -, $1, $3); } +| expr '*' expr { BINARY_OP($$, *, $1, $3); } +| expr '/' expr +{ + if ($3 == 0) { + pr_debug("division by zero\n"); + YYABORT; + } + $$ = $1 / $3; +} +| expr '%' expr +{ + if ((long)$3 == 0) { + pr_debug("division by zero\n"); + YYABORT; + } + $$ = (long)$1 % (long)$3; +} +| D_RATIO '(' expr ',' expr ')' +{ + if ($5 == 0) { + $$ = 0; + } else { + $$ = $3 / $5; + } +} +| '-' expr %prec NEG +{ + $$ = -$2; +} +| '(' if_expr ')' +{ + $$ = $2; +} +| MIN '(' expr ',' expr ')' +{ + $$ = $3 < $5 ? $3 : $5; +} +| MAX '(' expr ',' expr ')' +{ + $$ = $3 > $5 ? $3 : $5; +} +| SMT_ON +{ + $$ = smt_on() > 0 ? 1.0 : 0.0; +} +; %% |