~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/util/expr.y

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/perf/util/expr.y (Architecture alpha) and /tools/perf/util/expr.y (Architecture sparc)


  1 /* Simple expression parser */                      1 /* Simple expression parser */
  2 %{                                                  2 %{
  3 #ifndef NDEBUG                                      3 #ifndef NDEBUG
  4 #define YYDEBUG 1                                   4 #define YYDEBUG 1
  5 #endif                                              5 #endif
  6 #include <assert.h>                                 6 #include <assert.h>
  7 #include <math.h>                                   7 #include <math.h>
  8 #include <stdlib.h>                                 8 #include <stdlib.h>
  9 #include "util/debug.h"                             9 #include "util/debug.h"
 10 #define IN_EXPR_Y 1                                10 #define IN_EXPR_Y 1
 11 #include "expr.h"                                  11 #include "expr.h"
 12 #include "expr-bison.h"                            12 #include "expr-bison.h"
 13 int expr_lex(YYSTYPE * yylval_param , void *yy     13 int expr_lex(YYSTYPE * yylval_param , void *yyscanner);
 14 %}                                                 14 %}
 15                                                    15 
 16 %define api.pure full                              16 %define api.pure full
 17                                                    17 
 18 %parse-param { double *final_val }                 18 %parse-param { double *final_val }
 19 %parse-param { struct expr_parse_ctx *ctx }        19 %parse-param { struct expr_parse_ctx *ctx }
 20 %parse-param { bool compute_ids }                  20 %parse-param { bool compute_ids }
 21 %parse-param {void *scanner}                       21 %parse-param {void *scanner}
 22 %lex-param {void* scanner}                         22 %lex-param {void* scanner}
 23                                                    23 
 24 %union {                                           24 %union {
 25         double   num;                              25         double   num;
 26         char    *str;                              26         char    *str;
 27         struct ids {                               27         struct ids {
 28                 /*                                 28                 /*
 29                  * When creating ids, holds th     29                  * When creating ids, holds the working set of event ids. NULL
 30                  * implies the set is empty.       30                  * implies the set is empty.
 31                  */                                31                  */
 32                 struct hashmap *ids;               32                 struct hashmap *ids;
 33                 /*                                 33                 /*
 34                  * The metric value. When not      34                  * The metric value. When not creating ids this is the value
 35                  * read from a counter, a cons     35                  * read from a counter, a constant or some computed value. When
 36                  * creating ids the value is e     36                  * creating ids the value is either a constant or BOTTOM. NAN is
 37                  * used as the special BOTTOM      37                  * used as the special BOTTOM value, representing a "set of all
 38                  * values" case.                   38                  * values" case.
 39                  */                                39                  */
 40                 double val;                        40                 double val;
 41         } ids;                                     41         } ids;
 42 }                                                  42 }
 43                                                    43 
 44 %token ID NUMBER MIN MAX IF ELSE LITERAL D_RAT     44 %token ID NUMBER MIN MAX IF ELSE LITERAL D_RATIO SOURCE_COUNT HAS_EVENT STRCMP_CPUID_STR EXPR_ERROR
 45 %left MIN MAX IF                                   45 %left MIN MAX IF
 46 %left '|'                                          46 %left '|'
 47 %left '^'                                          47 %left '^'
 48 %left '&'                                          48 %left '&'
 49 %left '<' '>'                                      49 %left '<' '>'
 50 %left '-' '+'                                      50 %left '-' '+'
 51 %left '*' '/' '%'                                  51 %left '*' '/' '%'
 52 %left NEG NOT                                      52 %left NEG NOT
 53 %type <num> NUMBER LITERAL                         53 %type <num> NUMBER LITERAL
 54 %type <str> ID                                     54 %type <str> ID
 55 %destructor { free ($$); } <str>                   55 %destructor { free ($$); } <str>
 56 %type <ids> expr if_expr                           56 %type <ids> expr if_expr
 57 %destructor { ids__free($$.ids); } <ids>           57 %destructor { ids__free($$.ids); } <ids>
 58                                                    58 
 59 %{                                                 59 %{
 60 static void expr_error(double *final_val __may     60 static void expr_error(double *final_val __maybe_unused,
 61                        struct expr_parse_ctx *     61                        struct expr_parse_ctx *ctx __maybe_unused,
 62                        bool compute_ids __mayb     62                        bool compute_ids __maybe_unused,
 63                        void *scanner __maybe_u     63                        void *scanner __maybe_unused,
 64                        const char *s)              64                        const char *s)
 65 {                                                  65 {
 66         pr_debug("%s\n", s);                       66         pr_debug("%s\n", s);
 67 }                                                  67 }
 68                                                    68 
 69 /*                                                 69 /*
 70  * During compute ids, the special "bottom" va     70  * During compute ids, the special "bottom" value uses NAN to represent the set
 71  * of all values. NAN is selected as it isn't      71  * of all values. NAN is selected as it isn't a useful constant value.
 72  */                                                72  */
 73 #define BOTTOM NAN                                 73 #define BOTTOM NAN
 74                                                    74 
 75 /* During computing ids, does val represent a      75 /* During computing ids, does val represent a constant (non-BOTTOM) value? */
 76 static bool is_const(double val)                   76 static bool is_const(double val)
 77 {                                                  77 {
 78         return isfinite(val);                      78         return isfinite(val);
 79 }                                                  79 }
 80                                                    80 
 81 static struct ids union_expr(struct ids ids1,      81 static struct ids union_expr(struct ids ids1, struct ids ids2)
 82 {                                                  82 {
 83         struct ids result = {                      83         struct ids result = {
 84                 .val = BOTTOM,                     84                 .val = BOTTOM,
 85                 .ids = ids__union(ids1.ids, id     85                 .ids = ids__union(ids1.ids, ids2.ids),
 86         };                                         86         };
 87         return result;                             87         return result;
 88 }                                                  88 }
 89                                                    89 
 90 static struct ids handle_id(struct expr_parse_     90 static struct ids handle_id(struct expr_parse_ctx *ctx, char *id,
 91                             bool compute_ids,      91                             bool compute_ids, bool source_count)
 92 {                                                  92 {
 93         struct ids result;                         93         struct ids result;
 94                                                    94 
 95         if (!compute_ids) {                        95         if (!compute_ids) {
 96                 /*                                 96                 /*
 97                  * Compute the event's value f     97                  * Compute the event's value from ID. If the ID isn't known then
 98                  * it isn't used to compute th     98                  * it isn't used to compute the formula so set to NAN.
 99                  */                                99                  */
100                 struct expr_id_data *data;        100                 struct expr_id_data *data;
101                                                   101 
102                 result.val = NAN;                 102                 result.val = NAN;
103                 if (expr__resolve_id(ctx, id,     103                 if (expr__resolve_id(ctx, id, &data) == 0) {
104                         result.val = source_co    104                         result.val = source_count
105                                 ? expr_id_data    105                                 ? expr_id_data__source_count(data)
106                                 : expr_id_data    106                                 : expr_id_data__value(data);
107                 }                                 107                 }
108                 result.ids = NULL;                108                 result.ids = NULL;
109                 free(id);                         109                 free(id);
110         } else {                                  110         } else {
111                 /*                                111                 /*
112                  * Set the value to BOTTOM to     112                  * Set the value to BOTTOM to show that any value is possible
113                  * when the event is computed.    113                  * when the event is computed. Create a set of just the ID.
114                  */                               114                  */
115                 result.val = BOTTOM;              115                 result.val = BOTTOM;
116                 result.ids = ids__new();          116                 result.ids = ids__new();
117                 if (!result.ids || ids__insert    117                 if (!result.ids || ids__insert(result.ids, id)) {
118                         pr_err("Error creating    118                         pr_err("Error creating IDs for '%s'", id);
119                         free(id);                 119                         free(id);
120                 }                                 120                 }
121         }                                         121         }
122         return result;                            122         return result;
123 }                                                 123 }
124                                                   124 
125 /*                                                125 /*
126  * If we're not computing ids or $1 and $3 are    126  * If we're not computing ids or $1 and $3 are constants, compute the new
127  * constant value using OP. Its invariant that    127  * constant value using OP. Its invariant that there are no ids.  If computing
128  * ids for non-constants union the set of IDs     128  * ids for non-constants union the set of IDs that must be computed.
129  */                                               129  */
130 #define BINARY_OP(RESULT, OP, LHS, RHS)           130 #define BINARY_OP(RESULT, OP, LHS, RHS)                                 \
131         if (!compute_ids || (is_const(LHS.val)    131         if (!compute_ids || (is_const(LHS.val) && is_const(RHS.val))) { \
132                 assert(LHS.ids == NULL);          132                 assert(LHS.ids == NULL);                                \
133                 assert(RHS.ids == NULL);          133                 assert(RHS.ids == NULL);                                \
134                 if (isnan(LHS.val) || isnan(RH    134                 if (isnan(LHS.val) || isnan(RHS.val)) {                 \
135                         RESULT.val = NAN;         135                         RESULT.val = NAN;                               \
136                 } else {                          136                 } else {                                                \
137                         RESULT.val = LHS.val O    137                         RESULT.val = LHS.val OP RHS.val;                \
138                 }                                 138                 }                                                       \
139                 RESULT.ids = NULL;                139                 RESULT.ids = NULL;                                      \
140         } else {                                  140         } else {                                                        \
141                 RESULT = union_expr(LHS, RHS);    141                 RESULT = union_expr(LHS, RHS);                          \
142         }                                         142         }
143                                                   143 
144 %}                                                144 %}
145 %%                                                145 %%
146                                                   146 
147 start: if_expr                                    147 start: if_expr
148 {                                                 148 {
149         if (compute_ids)                          149         if (compute_ids)
150                 ctx->ids = ids__union($1.ids,     150                 ctx->ids = ids__union($1.ids, ctx->ids);
151                                                   151 
152         if (final_val)                            152         if (final_val)
153                 *final_val = $1.val;              153                 *final_val = $1.val;
154 }                                                 154 }
155 ;                                                 155 ;
156                                                   156 
157 if_expr: expr IF expr ELSE if_expr                157 if_expr: expr IF expr ELSE if_expr
158 {                                                 158 {
159         if (fpclassify($3.val) == FP_ZERO) {      159         if (fpclassify($3.val) == FP_ZERO) {
160                 /*                                160                 /*
161                  * The IF expression evaluated    161                  * The IF expression evaluated to 0 so treat as false, take the
162                  * ELSE and discard everything    162                  * ELSE and discard everything else.
163                  */                               163                  */
164                 $$.val = $5.val;                  164                 $$.val = $5.val;
165                 $$.ids = $5.ids;                  165                 $$.ids = $5.ids;
166                 ids__free($1.ids);                166                 ids__free($1.ids);
167                 ids__free($3.ids);                167                 ids__free($3.ids);
168         } else if (!compute_ids || is_const($3    168         } else if (!compute_ids || is_const($3.val)) {
169                 /*                                169                 /*
170                  * If ids aren't computed then    170                  * If ids aren't computed then treat the expression as true. If
171                  * ids are being computed and     171                  * ids are being computed and the IF expr is a non-zero
172                  * constant, then also evaluat    172                  * constant, then also evaluate the true case.
173                  */                               173                  */
174                 $$.val = $1.val;                  174                 $$.val = $1.val;
175                 $$.ids = $1.ids;                  175                 $$.ids = $1.ids;
176                 ids__free($3.ids);                176                 ids__free($3.ids);
177                 ids__free($5.ids);                177                 ids__free($5.ids);
178         } else if ($1.val == $5.val) {            178         } else if ($1.val == $5.val) {
179                 /*                                179                 /*
180                  * LHS == RHS, so both are an     180                  * LHS == RHS, so both are an identical constant. No need to
181                  * evaluate any events.           181                  * evaluate any events.
182                  */                               182                  */
183                 $$.val = $1.val;                  183                 $$.val = $1.val;
184                 $$.ids = NULL;                    184                 $$.ids = NULL;
185                 ids__free($1.ids);                185                 ids__free($1.ids);
186                 ids__free($3.ids);                186                 ids__free($3.ids);
187                 ids__free($5.ids);                187                 ids__free($5.ids);
188         } else {                                  188         } else {
189                 /*                                189                 /*
190                  * Value is either the LHS or     190                  * Value is either the LHS or RHS and we need the IF expression
191                  * to compute it.                 191                  * to compute it.
192                  */                               192                  */
193                 $$ = union_expr($1, union_expr    193                 $$ = union_expr($1, union_expr($3, $5));
194         }                                         194         }
195 }                                                 195 }
196 | expr                                            196 | expr
197 ;                                                 197 ;
198                                                   198 
199 expr: NUMBER                                      199 expr: NUMBER
200 {                                                 200 {
201         $$.val = $1;                              201         $$.val = $1;
202         $$.ids = NULL;                            202         $$.ids = NULL;
203 }                                                 203 }
204 | ID                            { $$ = handle_    204 | ID                            { $$ = handle_id(ctx, $1, compute_ids, /*source_count=*/false); }
205 | SOURCE_COUNT '(' ID ')'       { $$ = handle_    205 | SOURCE_COUNT '(' ID ')'       { $$ = handle_id(ctx, $3, compute_ids, /*source_count=*/true); }
206 | HAS_EVENT '(' ID ')'                            206 | HAS_EVENT '(' ID ')'
207 {                                                 207 {
208         $$.val = expr__has_event(ctx, compute_    208         $$.val = expr__has_event(ctx, compute_ids, $3);
209         $$.ids = NULL;                            209         $$.ids = NULL;
210         free($3);                                 210         free($3);
211 }                                                 211 }
212 | STRCMP_CPUID_STR '(' ID ')'                     212 | STRCMP_CPUID_STR '(' ID ')'
213 {                                                 213 {
214         $$.val = expr__strcmp_cpuid_str(ctx, c    214         $$.val = expr__strcmp_cpuid_str(ctx, compute_ids, $3);
215         $$.ids = NULL;                            215         $$.ids = NULL;
216         free($3);                                 216         free($3);
217 }                                                 217 }
218 | expr '|' expr                                   218 | expr '|' expr
219 {                                                 219 {
220         if (is_const($1.val) && is_const($3.va    220         if (is_const($1.val) && is_const($3.val)) {
221                 assert($1.ids == NULL);           221                 assert($1.ids == NULL);
222                 assert($3.ids == NULL);           222                 assert($3.ids == NULL);
223                 $$.ids = NULL;                    223                 $$.ids = NULL;
224                 $$.val = (fpclassify($1.val) =    224                 $$.val = (fpclassify($1.val) == FP_ZERO && fpclassify($3.val) == FP_ZERO) ? 0 : 1;
225         } else if (is_const($1.val)) {            225         } else if (is_const($1.val)) {
226                 assert($1.ids == NULL);           226                 assert($1.ids == NULL);
227                 if (fpclassify($1.val) == FP_Z    227                 if (fpclassify($1.val) == FP_ZERO) {
228                         $$ = $3;                  228                         $$ = $3;
229                 } else {                          229                 } else {
230                         $$.val = 1;               230                         $$.val = 1;
231                         $$.ids = NULL;            231                         $$.ids = NULL;
232                         ids__free($3.ids);        232                         ids__free($3.ids);
233                 }                                 233                 }
234         } else if (is_const($3.val)) {            234         } else if (is_const($3.val)) {
235                 assert($3.ids == NULL);           235                 assert($3.ids == NULL);
236                 if (fpclassify($3.val) == FP_Z    236                 if (fpclassify($3.val) == FP_ZERO) {
237                         $$ = $1;                  237                         $$ = $1;
238                 } else {                          238                 } else {
239                         $$.val = 1;               239                         $$.val = 1;
240                         $$.ids = NULL;            240                         $$.ids = NULL;
241                         ids__free($1.ids);        241                         ids__free($1.ids);
242                 }                                 242                 }
243         } else {                                  243         } else {
244                 $$ = union_expr($1, $3);          244                 $$ = union_expr($1, $3);
245         }                                         245         }
246 }                                                 246 }
247 | expr '&' expr                                   247 | expr '&' expr
248 {                                                 248 {
249         if (is_const($1.val) && is_const($3.va    249         if (is_const($1.val) && is_const($3.val)) {
250                 assert($1.ids == NULL);           250                 assert($1.ids == NULL);
251                 assert($3.ids == NULL);           251                 assert($3.ids == NULL);
252                 $$.val = (fpclassify($1.val) !    252                 $$.val = (fpclassify($1.val) != FP_ZERO && fpclassify($3.val) != FP_ZERO) ? 1 : 0;
253                 $$.ids = NULL;                    253                 $$.ids = NULL;
254         } else if (is_const($1.val)) {            254         } else if (is_const($1.val)) {
255                 assert($1.ids == NULL);           255                 assert($1.ids == NULL);
256                 if (fpclassify($1.val) != FP_Z    256                 if (fpclassify($1.val) != FP_ZERO) {
257                         $$ = $3;                  257                         $$ = $3;
258                 } else {                          258                 } else {
259                         $$.val = 0;               259                         $$.val = 0;
260                         $$.ids = NULL;            260                         $$.ids = NULL;
261                         ids__free($3.ids);        261                         ids__free($3.ids);
262                 }                                 262                 }
263         } else if (is_const($3.val)) {            263         } else if (is_const($3.val)) {
264                 assert($3.ids == NULL);           264                 assert($3.ids == NULL);
265                 if (fpclassify($3.val) != FP_Z    265                 if (fpclassify($3.val) != FP_ZERO) {
266                         $$ = $1;                  266                         $$ = $1;
267                 } else {                          267                 } else {
268                         $$.val = 0;               268                         $$.val = 0;
269                         $$.ids = NULL;            269                         $$.ids = NULL;
270                         ids__free($1.ids);        270                         ids__free($1.ids);
271                 }                                 271                 }
272         } else {                                  272         } else {
273                 $$ = union_expr($1, $3);          273                 $$ = union_expr($1, $3);
274         }                                         274         }
275 }                                                 275 }
276 | expr '^' expr                                   276 | expr '^' expr
277 {                                                 277 {
278         if (is_const($1.val) && is_const($3.va    278         if (is_const($1.val) && is_const($3.val)) {
279                 assert($1.ids == NULL);           279                 assert($1.ids == NULL);
280                 assert($3.ids == NULL);           280                 assert($3.ids == NULL);
281                 $$.val = (fpclassify($1.val) =    281                 $$.val = (fpclassify($1.val) == FP_ZERO) != (fpclassify($3.val) == FP_ZERO) ? 1 : 0;
282                 $$.ids = NULL;                    282                 $$.ids = NULL;
283         } else {                                  283         } else {
284                 $$ = union_expr($1, $3);          284                 $$ = union_expr($1, $3);
285         }                                         285         }
286 }                                                 286 }
287 | expr '<' expr { BINARY_OP($$, <, $1, $3); }     287 | expr '<' expr { BINARY_OP($$, <, $1, $3); }
288 | expr '>' expr { BINARY_OP($$, >, $1, $3); }     288 | expr '>' expr { BINARY_OP($$, >, $1, $3); }
289 | expr '+' expr { BINARY_OP($$, +, $1, $3); }     289 | expr '+' expr { BINARY_OP($$, +, $1, $3); }
290 | expr '-' expr { BINARY_OP($$, -, $1, $3); }     290 | expr '-' expr { BINARY_OP($$, -, $1, $3); }
291 | expr '*' expr { BINARY_OP($$, *, $1, $3); }     291 | expr '*' expr { BINARY_OP($$, *, $1, $3); }
292 | expr '/' expr                                   292 | expr '/' expr
293 {                                                 293 {
294         if (fpclassify($3.val) == FP_ZERO) {      294         if (fpclassify($3.val) == FP_ZERO) {
295                 pr_debug("division by zero\n")    295                 pr_debug("division by zero\n");
296                 assert($3.ids == NULL);           296                 assert($3.ids == NULL);
297                 if (compute_ids)                  297                 if (compute_ids)
298                         ids__free($1.ids);        298                         ids__free($1.ids);
299                 $$.val = NAN;                     299                 $$.val = NAN;
300                 $$.ids = NULL;                    300                 $$.ids = NULL;
301         } else if (!compute_ids || (is_const($    301         } else if (!compute_ids || (is_const($1.val) && is_const($3.val))) {
302                 assert($1.ids == NULL);           302                 assert($1.ids == NULL);
303                 assert($3.ids == NULL);           303                 assert($3.ids == NULL);
304                 $$.val = $1.val / $3.val;         304                 $$.val = $1.val / $3.val;
305                 $$.ids = NULL;                    305                 $$.ids = NULL;
306         } else {                                  306         } else {
307                 /* LHS and/or RHS need computi    307                 /* LHS and/or RHS need computing from event IDs so union. */
308                 $$ = union_expr($1, $3);          308                 $$ = union_expr($1, $3);
309         }                                         309         }
310 }                                                 310 }
311 | expr '%' expr                                   311 | expr '%' expr
312 {                                                 312 {
313         if (fpclassify($3.val) == FP_ZERO) {      313         if (fpclassify($3.val) == FP_ZERO) {
314                 pr_debug("division by zero\n")    314                 pr_debug("division by zero\n");
315                 YYABORT;                          315                 YYABORT;
316         } else if (!compute_ids || (is_const($    316         } else if (!compute_ids || (is_const($1.val) && is_const($3.val))) {
317                 assert($1.ids == NULL);           317                 assert($1.ids == NULL);
318                 assert($3.ids == NULL);           318                 assert($3.ids == NULL);
319                 $$.val = (long)$1.val % (long)    319                 $$.val = (long)$1.val % (long)$3.val;
320                 $$.ids = NULL;                    320                 $$.ids = NULL;
321         } else {                                  321         } else {
322                 /* LHS and/or RHS need computi    322                 /* LHS and/or RHS need computing from event IDs so union. */
323                 $$ = union_expr($1, $3);          323                 $$ = union_expr($1, $3);
324         }                                         324         }
325 }                                                 325 }
326 | D_RATIO '(' expr ',' expr ')'                   326 | D_RATIO '(' expr ',' expr ')'
327 {                                                 327 {
328         if (fpclassify($5.val) == FP_ZERO) {      328         if (fpclassify($5.val) == FP_ZERO) {
329                 /*                                329                 /*
330                  * Division by constant zero a    330                  * Division by constant zero always yields zero and no events
331                  * are necessary.                 331                  * are necessary.
332                  */                               332                  */
333                 assert($5.ids == NULL);           333                 assert($5.ids == NULL);
334                 $$.val = 0.0;                     334                 $$.val = 0.0;
335                 $$.ids = NULL;                    335                 $$.ids = NULL;
336                 ids__free($3.ids);                336                 ids__free($3.ids);
337         } else if (!compute_ids || (is_const($    337         } else if (!compute_ids || (is_const($3.val) && is_const($5.val))) {
338                 assert($3.ids == NULL);           338                 assert($3.ids == NULL);
339                 assert($5.ids == NULL);           339                 assert($5.ids == NULL);
340                 $$.val = $3.val / $5.val;         340                 $$.val = $3.val / $5.val;
341                 $$.ids = NULL;                    341                 $$.ids = NULL;
342         } else {                                  342         } else {
343                 /* LHS and/or RHS need computi    343                 /* LHS and/or RHS need computing from event IDs so union. */
344                 $$ = union_expr($3, $5);          344                 $$ = union_expr($3, $5);
345         }                                         345         }
346 }                                                 346 }
347 | '-' expr %prec NEG                              347 | '-' expr %prec NEG
348 {                                                 348 {
349         $$.val = -$2.val;                         349         $$.val = -$2.val;
350         $$.ids = $2.ids;                          350         $$.ids = $2.ids;
351 }                                                 351 }
352 | '(' if_expr ')'                                 352 | '(' if_expr ')'
353 {                                                 353 {
354         $$ = $2;                                  354         $$ = $2;
355 }                                                 355 }
356 | MIN '(' expr ',' expr ')'                       356 | MIN '(' expr ',' expr ')'
357 {                                                 357 {
358         if (!compute_ids) {                       358         if (!compute_ids) {
359                 $$.val = $3.val < $5.val ? $3.    359                 $$.val = $3.val < $5.val ? $3.val : $5.val;
360                 $$.ids = NULL;                    360                 $$.ids = NULL;
361         } else {                                  361         } else {
362                 $$ = union_expr($3, $5);          362                 $$ = union_expr($3, $5);
363         }                                         363         }
364 }                                                 364 }
365 | MAX '(' expr ',' expr ')'                       365 | MAX '(' expr ',' expr ')'
366 {                                                 366 {
367         if (!compute_ids) {                       367         if (!compute_ids) {
368                 $$.val = $3.val > $5.val ? $3.    368                 $$.val = $3.val > $5.val ? $3.val : $5.val;
369                 $$.ids = NULL;                    369                 $$.ids = NULL;
370         } else {                                  370         } else {
371                 $$ = union_expr($3, $5);          371                 $$ = union_expr($3, $5);
372         }                                         372         }
373 }                                                 373 }
374 | LITERAL                                         374 | LITERAL
375 {                                                 375 {
376         $$.val = $1;                              376         $$.val = $1;
377         $$.ids = NULL;                            377         $$.ids = NULL;
378 }                                                 378 }
379 ;                                                 379 ;
380                                                   380 
381 %%                                                381 %%
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php