]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf expr: Move actions to the left.
authorIan Rogers <irogers@google.com>
Thu, 23 Sep 2021 07:46:09 +0000 (00:46 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 29 Sep 2021 16:41:49 +0000 (13:41 -0300)
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>
tools/perf/util/expr.y

index 5535badeef0affbc63198dce7b2d8d13e98d9f5d..78cbe377eb0e98067db98576f81f584e683fa052 100644 (file)
@@ -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;
+}
+;
 
 %%