Commit 7f8fdcbb authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo
Browse files

perf expr: Remove unused headers and inline d_ratio



No functional change. Inlining d_ratio makes it easier to special case
for constants in a later patch.

Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarJohn Garry <john.garry@huawei.com>
Acked-by: default avatarJiri 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: Kajol Jain <kjain@linux.ibm.com>
Cc: Jin Yao <yao.jin@linux.intel.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-4-irogers@google.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent edfe7f55
Loading
Loading
Loading
Loading
+7 −15
Original line number Diff line number Diff line
@@ -2,23 +2,10 @@
%{
#define YYDEBUG 1
#include <math.h>
#include <stdio.h>
#include "util.h"
#include "util/debug.h"
#include <stdlib.h> // strtod()
#include "smt.h"
#define IN_EXPR_Y 1
#include "expr.h"
#include "smt.h"
#include <string.h>

static double d_ratio(double val0, double val1)
{
	if (val1 == 0) {
		return 0;
	}
	return  val0 / val1;
}

%}

%define api.pure full
@@ -120,7 +107,12 @@ expr: NUMBER
	| MIN '(' expr ',' expr ')' { $$ = $3 < $5 ? $3 : $5; }
	| MAX '(' expr ',' expr ')' { $$ = $3 > $5 ? $3 : $5; }
	| SMT_ON		 { $$ = smt_on() > 0; }
	| D_RATIO '(' expr ',' expr ')' { $$ = d_ratio($3,$5); }
	| D_RATIO '(' expr ',' expr ')' { if ($5 == 0) {
						$$ = 0;
					  } else {
						$$ = $3 / $5;
					  }
					}
	;

%%