fix: relayd: unaligned access in trace_chunk_registry_ht_key_hash
[lttng-tools.git] / src / common / filter / filter-ir.hpp
1 #ifndef _FILTER_IR_H
2 #define _FILTER_IR_H
3
4 /*
5 * filter-ir.h
6 *
7 * LTTng filter ir
8 *
9 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
11 * SPDX-License-Identifier: LGPL-2.1-only
12 *
13 */
14
15 #include "filter-ast.hpp"
16
17 #include <cstdlib>
18
19 enum ir_op_signedness {
20 IR_SIGN_UNKNOWN = 0,
21 IR_SIGNED,
22 IR_UNSIGNED,
23 IR_SIGN_DYN, /* signedness determined dynamically */
24 };
25
26 enum ir_data_type {
27 IR_DATA_UNKNOWN = 0,
28 IR_DATA_STRING,
29 IR_DATA_NUMERIC, /* numeric and boolean */
30 IR_DATA_FLOAT,
31 IR_DATA_FIELD_REF,
32 IR_DATA_GET_CONTEXT_REF,
33 IR_DATA_EXPRESSION,
34 };
35
36 static inline const char *ir_data_type_str(enum ir_data_type type)
37 {
38 switch (type) {
39 case IR_DATA_UNKNOWN:
40 return "IR_DATA_UNKNOWN";
41 case IR_DATA_STRING:
42 return "IR_DATA_STRING";
43 case IR_DATA_NUMERIC:
44 return "IR_DATA_NUMERIC";
45 case IR_DATA_FLOAT:
46 return "IR_DATA_FLOAT";
47 case IR_DATA_FIELD_REF:
48 return "IR_DATA_FIELD_REF";
49 case IR_DATA_GET_CONTEXT_REF:
50 return "IR_DATA_GET_CONTEXT_REF";
51 case IR_DATA_EXPRESSION:
52 return "IR_DATA_EXPRESSION";
53 default:
54 abort();
55 }
56 }
57
58 enum ir_op_type {
59 IR_OP_UNKNOWN = 0,
60 IR_OP_ROOT,
61 IR_OP_LOAD,
62 IR_OP_UNARY,
63 IR_OP_BINARY,
64 IR_OP_LOGICAL,
65 };
66
67 static inline const char *ir_op_type_str(enum ir_op_type type)
68 {
69 switch (type) {
70 case IR_OP_UNKNOWN:
71 return "IR_OP_UNKNOWN";
72 case IR_OP_ROOT:
73 return "IR_OP_ROOT";
74 case IR_OP_LOAD:
75 return "IR_OP_LOAD";
76 case IR_OP_UNARY:
77 return "IR_OP_UNARY";
78 case IR_OP_BINARY:
79 return "IR_OP_BINARY";
80 case IR_OP_LOGICAL:
81 return "IR_OP_LOGICAL";
82 default:
83 abort();
84 }
85 }
86
87 /* left or right child */
88 enum ir_side {
89 IR_SIDE_UNKNOWN = 0,
90 IR_LEFT,
91 IR_RIGHT,
92 };
93
94 enum ir_load_string_type {
95 /* Plain, no globbing at all: `hello world`. */
96 IR_LOAD_STRING_TYPE_PLAIN = 0,
97
98 /* Star at the end only: `hello *`. */
99 IR_LOAD_STRING_TYPE_GLOB_STAR_END,
100
101 /* At least one star, anywhere, but not at the end only: `he*wor*`. */
102 IR_LOAD_STRING_TYPE_GLOB_STAR,
103 };
104
105 struct ir_op_root {
106 struct ir_op *child;
107 };
108
109 enum ir_load_expression_type {
110 IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT,
111 IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT,
112 IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT,
113 IR_LOAD_EXPRESSION_GET_SYMBOL,
114 IR_LOAD_EXPRESSION_GET_INDEX,
115 IR_LOAD_EXPRESSION_LOAD_FIELD,
116 };
117
118 static inline const char *ir_load_expression_type_str(enum ir_load_expression_type type)
119 {
120 switch (type) {
121 case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT:
122 return "IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT";
123 case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT:
124 return "IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT";
125 case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
126 return "IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT";
127 case IR_LOAD_EXPRESSION_GET_SYMBOL:
128 return "IR_LOAD_EXPRESSION_GET_SYMBOL";
129 case IR_LOAD_EXPRESSION_GET_INDEX:
130 return "IR_LOAD_EXPRESSION_GET_INDEX";
131 case IR_LOAD_EXPRESSION_LOAD_FIELD:
132 return "IR_LOAD_EXPRESSION_LOAD_FIELD";
133 default:
134 abort();
135 }
136 }
137
138 struct ir_load_expression_op {
139 struct ir_load_expression_op *next;
140 enum ir_load_expression_type type;
141 union {
142 char *symbol;
143 uint64_t index;
144 } u;
145 };
146
147 struct ir_load_expression {
148 struct ir_load_expression_op *child;
149 };
150
151 struct ir_op_load {
152 union {
153 struct {
154 enum ir_load_string_type type;
155 char *value;
156 } string;
157 int64_t num;
158 double flt;
159 char *ref;
160 struct ir_load_expression *expression;
161 } u;
162 };
163
164 struct ir_op_unary {
165 enum unary_op_type type;
166 struct ir_op *child;
167 };
168
169 struct ir_op_binary {
170 enum op_type type;
171 struct ir_op *left;
172 struct ir_op *right;
173 };
174
175 struct ir_op_logical {
176 enum op_type type;
177 struct ir_op *left;
178 struct ir_op *right;
179 };
180
181 struct ir_op {
182 /* common to all ops */
183 enum ir_op_type op;
184 enum ir_data_type data_type;
185 enum ir_op_signedness signedness;
186 enum ir_side side;
187
188 union {
189 struct ir_op_root root;
190 struct ir_op_load load;
191 struct ir_op_unary unary;
192 struct ir_op_binary binary;
193 struct ir_op_logical logical;
194 } u;
195 };
196
197 #endif /* _FILTER_IR_H */
This page took 0.035111 seconds and 4 git commands to generate.