Filter code relicensing to MIT license
[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 *
7e50015d 9 * Copyright 2012-2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
cd54f6d9 10 *
7e50015d
MD
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
cd54f6d9 17 *
7e50015d
MD
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
cd54f6d9 20 *
7e50015d
MD
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
cd54f6d9
MD
28 */
29
30#include <lttng/ust-abi.h>
31
32/*
33 * offsets are absolute from start of bytecode.
34 */
35
cd54f6d9
MD
36struct field_ref {
37 /* Initially, symbol offset. After link, field offset. */
38 uint16_t offset;
cd54f6d9
MD
39} __attribute__((packed));
40
41struct literal_numeric {
42 int64_t v;
43} __attribute__((packed));
44
da6eed25
MD
45struct literal_double {
46 double v;
47} __attribute__((packed));
48
cd54f6d9
MD
49struct literal_string {
50 char string[0];
51} __attribute__((packed));
52
53enum filter_op {
54 FILTER_OP_UNKNOWN = 0,
55
56 FILTER_OP_RETURN,
57
58 /* binary */
59 FILTER_OP_MUL,
60 FILTER_OP_DIV,
61 FILTER_OP_MOD,
62 FILTER_OP_PLUS,
63 FILTER_OP_MINUS,
64 FILTER_OP_RSHIFT,
65 FILTER_OP_LSHIFT,
66 FILTER_OP_BIN_AND,
67 FILTER_OP_BIN_OR,
68 FILTER_OP_BIN_XOR,
226106c0
MD
69
70 /* binary comparators */
cd54f6d9
MD
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
226106c0
MD
78 /* string binary comparator */
79 FILTER_OP_EQ_STRING,
80 FILTER_OP_NE_STRING,
81 FILTER_OP_GT_STRING,
82 FILTER_OP_LT_STRING,
83 FILTER_OP_GE_STRING,
84 FILTER_OP_LE_STRING,
85
86 /* s64 binary comparator */
87 FILTER_OP_EQ_S64,
88 FILTER_OP_NE_S64,
89 FILTER_OP_GT_S64,
90 FILTER_OP_LT_S64,
91 FILTER_OP_GE_S64,
92 FILTER_OP_LE_S64,
93
94 /* double binary comparator */
95 FILTER_OP_EQ_DOUBLE,
96 FILTER_OP_NE_DOUBLE,
97 FILTER_OP_GT_DOUBLE,
98 FILTER_OP_LT_DOUBLE,
99 FILTER_OP_GE_DOUBLE,
100 FILTER_OP_LE_DOUBLE,
101
dbea82ec
MD
102 /* Mixed S64-double binary comparators */
103 FILTER_OP_EQ_DOUBLE_S64,
104 FILTER_OP_NE_DOUBLE_S64,
105 FILTER_OP_GT_DOUBLE_S64,
106 FILTER_OP_LT_DOUBLE_S64,
107 FILTER_OP_GE_DOUBLE_S64,
108 FILTER_OP_LE_DOUBLE_S64,
109
110 FILTER_OP_EQ_S64_DOUBLE,
111 FILTER_OP_NE_S64_DOUBLE,
112 FILTER_OP_GT_S64_DOUBLE,
113 FILTER_OP_LT_S64_DOUBLE,
114 FILTER_OP_GE_S64_DOUBLE,
115 FILTER_OP_LE_S64_DOUBLE,
116
cd54f6d9
MD
117 /* unary */
118 FILTER_OP_UNARY_PLUS,
119 FILTER_OP_UNARY_MINUS,
120 FILTER_OP_UNARY_NOT,
08c84b15
MD
121 FILTER_OP_UNARY_PLUS_S64,
122 FILTER_OP_UNARY_MINUS_S64,
123 FILTER_OP_UNARY_NOT_S64,
124 FILTER_OP_UNARY_PLUS_DOUBLE,
125 FILTER_OP_UNARY_MINUS_DOUBLE,
126 FILTER_OP_UNARY_NOT_DOUBLE,
cd54f6d9
MD
127
128 /* logical */
129 FILTER_OP_AND,
130 FILTER_OP_OR,
131
77aa5901 132 /* load field ref */
cd54f6d9 133 FILTER_OP_LOAD_FIELD_REF,
2f0145d1
MD
134 FILTER_OP_LOAD_FIELD_REF_STRING,
135 FILTER_OP_LOAD_FIELD_REF_SEQUENCE,
136 FILTER_OP_LOAD_FIELD_REF_S64,
137 FILTER_OP_LOAD_FIELD_REF_DOUBLE,
138
77aa5901 139 /* load immediate from operand */
cd54f6d9
MD
140 FILTER_OP_LOAD_STRING,
141 FILTER_OP_LOAD_S64,
da6eed25 142 FILTER_OP_LOAD_DOUBLE,
cd54f6d9 143
49905038
MD
144 /* cast */
145 FILTER_OP_CAST_TO_S64,
146 FILTER_OP_CAST_DOUBLE_TO_S64,
147 FILTER_OP_CAST_NOP,
148
77aa5901
MD
149 /* get context ref */
150 FILTER_OP_GET_CONTEXT_REF,
151 FILTER_OP_GET_CONTEXT_REF_STRING,
152 FILTER_OP_GET_CONTEXT_REF_S64,
153 FILTER_OP_GET_CONTEXT_REF_DOUBLE,
154
cd54f6d9
MD
155 NR_FILTER_OPS,
156};
157
158typedef uint8_t filter_opcode_t;
159
160struct load_op {
161 filter_opcode_t op;
cd54f6d9
MD
162 char data[0];
163 /* data to load. Size known by enum filter_opcode and null-term char. */
164} __attribute__((packed));
165
166struct binary_op {
167 filter_opcode_t op;
168} __attribute__((packed));
169
170struct unary_op {
171 filter_opcode_t op;
cd54f6d9
MD
172} __attribute__((packed));
173
174/* skip_offset is absolute from start of bytecode */
175struct logical_op {
176 filter_opcode_t op;
177 uint16_t skip_offset; /* bytecode insn, if skip second test */
178} __attribute__((packed));
179
49905038
MD
180struct cast_op {
181 filter_opcode_t op;
49905038
MD
182} __attribute__((packed));
183
cd54f6d9
MD
184struct return_op {
185 filter_opcode_t op;
186} __attribute__((packed));
187
188#endif /* _FILTER_BYTECODE_H */
This page took 0.032819 seconds and 4 git commands to generate.