[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210923074616.674826-7-irogers@google.com>
Date: Thu, 23 Sep 2021 00:46:09 -0700
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
Jin Yao <yao.jin@...ux.intel.com>,
John Garry <john.garry@...wei.com>,
Paul Clarke <pc@...ibm.com>, kajoljain <kjain@...ux.ibm.com>,
linux-perf-users@...r.kernel.org
Cc: Stephane Eranian <eranian@...gle.com>,
Sandeep Dasgupta <sdasgup@...gle.com>,
Ian Rogers <irogers@...gle.com>
Subject: [PATCH v9 06/13] 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@...gle.com>
---
tools/perf/util/expr.y | 124 +++++++++++++++++++++++++----------------
1 file 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;
+}
+;
%%
--
2.33.0.464.g1972c5931b-goog
Powered by blists - more mailing lists