Filter: Specialize unary operators
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 13 Jul 2012 21:58:59 +0000 (17:58 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 13 Jul 2012 21:58:59 +0000 (17:58 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/lttng-filter.c

index 8a62c518e9a7e9d0427fefcb4dec7c78e5d98227..7fe2a7b5d5642cb3ac92f0de76589448956ea2c6 100644 (file)
@@ -576,59 +576,53 @@ int lttng_filter_interpret_bytecode(void *filter_data,
 
                /* unary */
                OP(FILTER_OP_UNARY_PLUS):
+               OP(FILTER_OP_UNARY_MINUS):
+               OP(FILTER_OP_UNARY_NOT):
+                       ERR("unsupported non-specialized bytecode op %u\n",
+                               (unsigned int) *(filter_opcode_t *) pc);
+                       ret = -EINVAL;
+                       goto end;
+
+
+               OP(FILTER_OP_UNARY_PLUS_S64):
+               OP(FILTER_OP_UNARY_PLUS_DOUBLE):
                {
                        next_pc += sizeof(struct unary_op);
                        PO;
                }
-               OP(FILTER_OP_UNARY_MINUS):
+               OP(FILTER_OP_UNARY_MINUS_S64):
                {
                        struct unary_op *insn = (struct unary_op *) pc;
 
-                       switch (reg[insn->reg].type) {
-                       default:
-                               ERR("unknown register type\n");
-                               ret = -EINVAL;
-                               goto end;
-
-                       case REG_STRING:
-                               ERR("Unary minus can only be applied to numeric or floating point registers\n");
-                               ret = -EINVAL;
-                               goto end;
-                       case REG_S64:
-                               reg[insn->reg].v = -reg[insn->reg].v;
-                               break;
-                       case REG_DOUBLE:
-                               reg[insn->reg].d = -reg[insn->reg].d;
-                               break;
-                       }
+                       reg[insn->reg].v = -reg[insn->reg].v;
                        next_pc += sizeof(struct unary_op);
                        PO;
                }
-               OP(FILTER_OP_UNARY_NOT):
+               OP(FILTER_OP_UNARY_MINUS_DOUBLE):
                {
                        struct unary_op *insn = (struct unary_op *) pc;
 
-                       switch (reg[insn->reg].type) {
-                       default:
-                               ERR("unknown register type\n");
-                               ret = -EINVAL;
-                               goto end;
+                       reg[insn->reg].d = -reg[insn->reg].d;
+                       next_pc += sizeof(struct unary_op);
+                       PO;
+               }
+               OP(FILTER_OP_UNARY_NOT_S64):
+               {
+                       struct unary_op *insn = (struct unary_op *) pc;
 
-                       case REG_STRING:
-                               ERR("Unary not can only be applied to numeric or floating point registers\n");
-                               ret = -EINVAL;
-                               goto end;
-                       case REG_S64:
-                               reg[insn->reg].v = !reg[insn->reg].v;
-                               break;
-                       case REG_DOUBLE:
-                               reg[insn->reg].d = !reg[insn->reg].d;
-                               break;
-                       }
                        reg[insn->reg].v = !reg[insn->reg].v;
                        next_pc += sizeof(struct unary_op);
                        PO;
                }
+               OP(FILTER_OP_UNARY_NOT_DOUBLE):
+               {
+                       struct unary_op *insn = (struct unary_op *) pc;
+
+                       reg[insn->reg].d = !reg[insn->reg].d;
+                       next_pc += sizeof(struct unary_op);
+                       PO;
+               }
+
                /* logical */
                OP(FILTER_OP_AND):
                {
@@ -1438,7 +1432,6 @@ int lttng_filter_specialize_bytecode(struct bytecode_runtime *bytecode)
                        break;
                }
 
-
                /* unary */
                case FILTER_OP_UNARY_PLUS:
                {
This page took 0.02771 seconds and 4 git commands to generate.