Filter: add floating point support
[lttng-ust.git] / liblttng-ust / filter-bytecode.h
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
31 enum filter_register {
32 REG_R0 = 0,
33 REG_R1 = 1,
34 REG_ERROR,
35 };
36
37 enum field_ref_type {
38 FIELD_REF_UNKNOWN = 0,
39 FIELD_REF_STRING,
40 FIELD_REF_SEQUENCE,
41 FIELD_REF_S64,
42 FIELD_REF_DOUBLE,
43 };
44
45 struct field_ref {
46 /* Initially, symbol offset. After link, field offset. */
47 uint16_t offset;
48 uint8_t type; /* enum field_ref_type */
49 } __attribute__((packed));
50
51 struct literal_numeric {
52 int64_t v;
53 } __attribute__((packed));
54
55 struct literal_double {
56 double v;
57 } __attribute__((packed));
58
59 struct literal_string {
60 char string[0];
61 } __attribute__((packed));
62
63 enum filter_op {
64 FILTER_OP_UNKNOWN = 0,
65
66 FILTER_OP_RETURN,
67
68 /* binary */
69 FILTER_OP_MUL,
70 FILTER_OP_DIV,
71 FILTER_OP_MOD,
72 FILTER_OP_PLUS,
73 FILTER_OP_MINUS,
74 FILTER_OP_RSHIFT,
75 FILTER_OP_LSHIFT,
76 FILTER_OP_BIN_AND,
77 FILTER_OP_BIN_OR,
78 FILTER_OP_BIN_XOR,
79 FILTER_OP_EQ,
80 FILTER_OP_NE,
81 FILTER_OP_GT,
82 FILTER_OP_LT,
83 FILTER_OP_GE,
84 FILTER_OP_LE,
85
86 /* unary */
87 FILTER_OP_UNARY_PLUS,
88 FILTER_OP_UNARY_MINUS,
89 FILTER_OP_UNARY_NOT,
90
91 /* logical */
92 FILTER_OP_AND,
93 FILTER_OP_OR,
94
95 /* load */
96 FILTER_OP_LOAD_FIELD_REF,
97 FILTER_OP_LOAD_STRING,
98 FILTER_OP_LOAD_S64,
99 FILTER_OP_LOAD_DOUBLE,
100
101 NR_FILTER_OPS,
102 };
103
104 typedef uint8_t filter_opcode_t;
105
106 struct load_op {
107 filter_opcode_t op;
108 uint8_t reg; /* enum filter_register */
109 char data[0];
110 /* data to load. Size known by enum filter_opcode and null-term char. */
111 } __attribute__((packed));
112
113 struct binary_op {
114 filter_opcode_t op;
115 } __attribute__((packed));
116
117 struct unary_op {
118 filter_opcode_t op;
119 uint8_t reg; /* enum filter_register */
120 } __attribute__((packed));
121
122 /* skip_offset is absolute from start of bytecode */
123 struct logical_op {
124 filter_opcode_t op;
125 uint16_t skip_offset; /* bytecode insn, if skip second test */
126 } __attribute__((packed));
127
128 struct return_op {
129 filter_opcode_t op;
130 } __attribute__((packed));
131
132 #endif /* _FILTER_BYTECODE_H */
This page took 0.032773 seconds and 5 git commands to generate.