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