Filter: Specialize unary ops
[lttng-tools.git] / src / lib / lttng-ctl / filter-bytecode.h
... / ...
CommitLineData
1#ifndef _FILTER_BYTECODE_H
2#define _FILTER_BYTECODE_H
3
4/*
5 * filter-bytecode.h
6 *
7 * LTTng filter bytecode
8 *
9 * Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * This library is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License, version 2.1 only,
13 * as published by the Free Software Foundation.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this library; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25#include "filter-ast.h"
26#include "../../common/sessiond-comm/sessiond-comm.h"
27
28/*
29 * offsets are absolute from start of bytecode.
30 */
31
32enum filter_register {
33 REG_R0 = 0,
34 REG_R1 = 1,
35 REG_ERROR,
36};
37
38struct field_ref {
39 /* Initially, symbol offset. After link, field offset. */
40 uint16_t offset;
41} __attribute__((packed));
42
43struct literal_numeric {
44 int64_t v;
45} __attribute__((packed));
46
47struct literal_double {
48 double v;
49} __attribute__((packed));
50
51struct literal_string {
52 char string[0];
53} __attribute__((packed));
54
55enum filter_op {
56 FILTER_OP_UNKNOWN = 0,
57
58 FILTER_OP_RETURN,
59
60 /* binary */
61 FILTER_OP_MUL,
62 FILTER_OP_DIV,
63 FILTER_OP_MOD,
64 FILTER_OP_PLUS,
65 FILTER_OP_MINUS,
66 FILTER_OP_RSHIFT,
67 FILTER_OP_LSHIFT,
68 FILTER_OP_BIN_AND,
69 FILTER_OP_BIN_OR,
70 FILTER_OP_BIN_XOR,
71 FILTER_OP_EQ,
72 FILTER_OP_NE,
73 FILTER_OP_GT,
74 FILTER_OP_LT,
75 FILTER_OP_GE,
76 FILTER_OP_LE,
77
78 /* unary */
79 FILTER_OP_UNARY_PLUS,
80 FILTER_OP_UNARY_MINUS,
81 FILTER_OP_UNARY_NOT,
82 FILTER_OP_UNARY_PLUS_S64,
83 FILTER_OP_UNARY_MINUS_S64,
84 FILTER_OP_UNARY_NOT_S64,
85 FILTER_OP_UNARY_PLUS_DOUBLE,
86 FILTER_OP_UNARY_MINUS_DOUBLE,
87 FILTER_OP_UNARY_NOT_DOUBLE,
88
89 /* logical */
90 FILTER_OP_AND,
91 FILTER_OP_OR,
92
93 /* load */
94 FILTER_OP_LOAD_FIELD_REF,
95 FILTER_OP_LOAD_FIELD_REF_STRING,
96 FILTER_OP_LOAD_FIELD_REF_SEQUENCE,
97 FILTER_OP_LOAD_FIELD_REF_S64,
98 FILTER_OP_LOAD_FIELD_REF_DOUBLE,
99
100 FILTER_OP_LOAD_STRING,
101 FILTER_OP_LOAD_S64,
102 FILTER_OP_LOAD_DOUBLE,
103
104 NR_FILTER_OPS,
105};
106
107typedef uint8_t filter_opcode_t;
108
109struct load_op {
110 filter_opcode_t op;
111 uint8_t reg; /* enum filter_register */
112 char data[0];
113 /* data to load. Size known by enum filter_opcode and null-term char. */
114} __attribute__((packed));
115
116struct binary_op {
117 filter_opcode_t op;
118} __attribute__((packed));
119
120struct unary_op {
121 filter_opcode_t op;
122 uint8_t reg; /* enum filter_register */
123} __attribute__((packed));
124
125/* skip_offset is absolute from start of bytecode */
126struct logical_op {
127 filter_opcode_t op;
128 uint16_t skip_offset; /* bytecode insn, if skip second test */
129} __attribute__((packed));
130
131struct return_op {
132 filter_opcode_t op;
133} __attribute__((packed));
134
135struct lttng_filter_bytecode_alloc {
136 uint16_t alloc_len;
137 struct lttng_filter_bytecode b;
138};
139
140static inline
141unsigned int bytecode_get_len(struct lttng_filter_bytecode *bytecode)
142{
143 return bytecode->len;
144}
145
146#endif /* _FILTER_BYTECODE_H */
This page took 0.022355 seconds and 4 git commands to generate.