Filter: specialize comparators
[lttng-ust.git] / liblttng-ust / filter-bytecode.h
CommitLineData
cd54f6d9
MD
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 <lttng/ust-abi.h>
26
27/*
28 * offsets are absolute from start of bytecode.
29 */
30
31enum filter_register {
32 REG_R0 = 0,
33 REG_R1 = 1,
34 REG_ERROR,
35};
36
cd54f6d9
MD
37struct field_ref {
38 /* Initially, symbol offset. After link, field offset. */
39 uint16_t offset;
cd54f6d9
MD
40} __attribute__((packed));
41
42struct literal_numeric {
43 int64_t v;
44} __attribute__((packed));
45
da6eed25
MD
46struct literal_double {
47 double v;
48} __attribute__((packed));
49
cd54f6d9
MD
50struct literal_string {
51 char string[0];
52} __attribute__((packed));
53
54enum filter_op {
55 FILTER_OP_UNKNOWN = 0,
56
57 FILTER_OP_RETURN,
58
59 /* binary */
60 FILTER_OP_MUL,
61 FILTER_OP_DIV,
62 FILTER_OP_MOD,
63 FILTER_OP_PLUS,
64 FILTER_OP_MINUS,
65 FILTER_OP_RSHIFT,
66 FILTER_OP_LSHIFT,
67 FILTER_OP_BIN_AND,
68 FILTER_OP_BIN_OR,
69 FILTER_OP_BIN_XOR,
226106c0
MD
70
71 /* binary comparators */
cd54f6d9
MD
72 FILTER_OP_EQ,
73 FILTER_OP_NE,
74 FILTER_OP_GT,
75 FILTER_OP_LT,
76 FILTER_OP_GE,
77 FILTER_OP_LE,
78
226106c0
MD
79 /* string binary comparator */
80 FILTER_OP_EQ_STRING,
81 FILTER_OP_NE_STRING,
82 FILTER_OP_GT_STRING,
83 FILTER_OP_LT_STRING,
84 FILTER_OP_GE_STRING,
85 FILTER_OP_LE_STRING,
86
87 /* s64 binary comparator */
88 FILTER_OP_EQ_S64,
89 FILTER_OP_NE_S64,
90 FILTER_OP_GT_S64,
91 FILTER_OP_LT_S64,
92 FILTER_OP_GE_S64,
93 FILTER_OP_LE_S64,
94
95 /* double binary comparator */
96 FILTER_OP_EQ_DOUBLE,
97 FILTER_OP_NE_DOUBLE,
98 FILTER_OP_GT_DOUBLE,
99 FILTER_OP_LT_DOUBLE,
100 FILTER_OP_GE_DOUBLE,
101 FILTER_OP_LE_DOUBLE,
102
cd54f6d9
MD
103 /* unary */
104 FILTER_OP_UNARY_PLUS,
105 FILTER_OP_UNARY_MINUS,
106 FILTER_OP_UNARY_NOT,
08c84b15
MD
107 FILTER_OP_UNARY_PLUS_S64,
108 FILTER_OP_UNARY_MINUS_S64,
109 FILTER_OP_UNARY_NOT_S64,
110 FILTER_OP_UNARY_PLUS_DOUBLE,
111 FILTER_OP_UNARY_MINUS_DOUBLE,
112 FILTER_OP_UNARY_NOT_DOUBLE,
cd54f6d9
MD
113
114 /* logical */
115 FILTER_OP_AND,
116 FILTER_OP_OR,
117
118 /* load */
119 FILTER_OP_LOAD_FIELD_REF,
2f0145d1
MD
120 FILTER_OP_LOAD_FIELD_REF_STRING,
121 FILTER_OP_LOAD_FIELD_REF_SEQUENCE,
122 FILTER_OP_LOAD_FIELD_REF_S64,
123 FILTER_OP_LOAD_FIELD_REF_DOUBLE,
124
cd54f6d9
MD
125 FILTER_OP_LOAD_STRING,
126 FILTER_OP_LOAD_S64,
da6eed25 127 FILTER_OP_LOAD_DOUBLE,
cd54f6d9
MD
128
129 NR_FILTER_OPS,
130};
131
132typedef uint8_t filter_opcode_t;
133
134struct load_op {
135 filter_opcode_t op;
136 uint8_t reg; /* enum filter_register */
137 char data[0];
138 /* data to load. Size known by enum filter_opcode and null-term char. */
139} __attribute__((packed));
140
141struct binary_op {
142 filter_opcode_t op;
143} __attribute__((packed));
144
145struct unary_op {
146 filter_opcode_t op;
147 uint8_t reg; /* enum filter_register */
148} __attribute__((packed));
149
150/* skip_offset is absolute from start of bytecode */
151struct logical_op {
152 filter_opcode_t op;
153 uint16_t skip_offset; /* bytecode insn, if skip second test */
154} __attribute__((packed));
155
156struct return_op {
157 filter_opcode_t op;
158} __attribute__((packed));
159
160#endif /* _FILTER_BYTECODE_H */
This page took 0.029089 seconds and 4 git commands to generate.