X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Ffilter%2Ffilter-visitor-generate-ir.c;h=d2165e640204934304882239206b8b7abf57b716;hb=5e0d83f005858aac77bec1c8eeecf723879f63da;hp=cd7930ad5476cb36e62f949d7a9ae818b4cf3723;hpb=bff988fac4f8d1ffab3f85f0eec9546c76e57706;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/filter/filter-visitor-generate-ir.c b/src/lib/lttng-ctl/filter/filter-visitor-generate-ir.c index cd7930ad5..d2165e640 100644 --- a/src/lib/lttng-ctl/filter/filter-visitor-generate-ir.c +++ b/src/lib/lttng-ctl/filter/filter-visitor-generate-ir.c @@ -254,6 +254,11 @@ struct ir_load_expression *create_load_expression(struct filter_node *node) bracket_node != NULL; bracket_node = bracket_node->u.expression.next_bracket) { prev_op = load_exp_op; + if (bracket_node->type != NODE_EXPRESSION || + bracket_node->u.expression.type != AST_EXP_CONSTANT) { + fprintf(stderr, "[error] Expecting constant index in array expression\n"); + goto error; + } load_exp_op = calloc(sizeof(struct ir_load_expression_op), 1); if (!load_exp_op) goto error; @@ -358,6 +363,13 @@ struct ir_op *make_op_unary_not(struct ir_op *child, enum ir_side side) child, side); } +static +struct ir_op *make_op_unary_bit_not(struct ir_op *child, enum ir_side side) +{ + return make_op_unary(AST_UNARY_BIT_NOT, "~", child->signedness, + child, side); +} + static struct ir_op *make_op_binary_compare(enum op_type bin_op_type, const char *op_str, struct ir_op *left, struct ir_op *right, @@ -538,6 +550,20 @@ struct ir_op *make_op_binary_logical_or(struct ir_op *left, struct ir_op *right, return make_op_binary_logical(AST_OP_OR, "||", left, right, side); } +static +struct ir_op *make_op_binary_bitwise_rshift(struct ir_op *left, struct ir_op *right, + enum ir_side side) +{ + return make_op_binary_bitwise(AST_OP_BIT_RSHIFT, ">>", left, right, side); +} + +static +struct ir_op *make_op_binary_bitwise_lshift(struct ir_op *left, struct ir_op *right, + enum ir_side side) +{ + return make_op_binary_bitwise(AST_OP_BIT_LSHIFT, "<<", left, right, side); +} + static struct ir_op *make_op_binary_bitwise_and(struct ir_op *left, struct ir_op *right, enum ir_side side) @@ -662,13 +688,9 @@ struct ir_op *make_op(struct filter_parser_ctx *ctx, case AST_OP_MINUS: op_str = "-"; goto error_not_supported; - case AST_OP_RSHIFT: - op_str = ">>"; - goto error_not_supported; - case AST_OP_LSHIFT: - op_str = "<<"; - goto error_not_supported; + case AST_OP_BIT_RSHIFT: + case AST_OP_BIT_LSHIFT: case AST_OP_BIT_AND: case AST_OP_BIT_OR: case AST_OP_BIT_XOR: @@ -740,6 +762,12 @@ struct ir_op *make_op(struct filter_parser_ctx *ctx, case AST_OP_LE: op = make_op_binary_le(lchild, rchild, side); break; + case AST_OP_BIT_RSHIFT: + op = make_op_binary_bitwise_rshift(lchild, rchild, side); + break; + case AST_OP_BIT_LSHIFT: + op = make_op_binary_bitwise_lshift(lchild, rchild, side); + break; case AST_OP_BIT_AND: op = make_op_binary_bitwise_and(lchild, rchild, side); break; @@ -769,8 +797,6 @@ static struct ir_op *make_unary_op(struct filter_parser_ctx *ctx, struct filter_node *node, enum ir_side side) { - const char *op_str = "?"; - switch (node->u.unary_op.type) { case AST_UNARY_UNKNOWN: default: @@ -824,14 +850,21 @@ struct ir_op *make_unary_op(struct filter_parser_ctx *ctx, } case AST_UNARY_BIT_NOT: { - op_str = "~"; - goto error_not_supported; + struct ir_op *op, *child; + + child = generate_ir_recursive(ctx, node->u.unary_op.child, + side); + if (!child) + return NULL; + op = make_op_unary_bit_not(child, side); + if (!op) { + filter_free_ir_recursive(child); + return NULL; + } + return op; } } -error_not_supported: - fprintf(stderr, "[error] %s: unary operation '%s' not supported\n", - __func__, op_str); return NULL; }