SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / src / common / filter / filter-ir.h
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.h"
16
17 enum ir_op_signedness {
18 IR_SIGN_UNKNOWN = 0,
19 IR_SIGNED,
20 IR_UNSIGNED,
21 IR_SIGN_DYN, /* signedness determined dynamically */
22 };
23
24 enum ir_data_type {
25 IR_DATA_UNKNOWN = 0,
26 IR_DATA_STRING,
27 IR_DATA_NUMERIC, /* numeric and boolean */
28 IR_DATA_FLOAT,
29 IR_DATA_FIELD_REF,
30 IR_DATA_GET_CONTEXT_REF,
31 IR_DATA_EXPRESSION,
32 };
33
34 static inline
35 const char *ir_data_type_str(enum ir_data_type type)
36 {
37 switch (type) {
38 case IR_DATA_UNKNOWN:
39 return "IR_DATA_UNKNOWN";
40 case IR_DATA_STRING:
41 return "IR_DATA_STRING";
42 case IR_DATA_NUMERIC:
43 return "IR_DATA_NUMERIC";
44 case IR_DATA_FLOAT:
45 return "IR_DATA_FLOAT";
46 case IR_DATA_FIELD_REF:
47 return "IR_DATA_FIELD_REF";
48 case IR_DATA_GET_CONTEXT_REF:
49 return "IR_DATA_GET_CONTEXT_REF";
50 case IR_DATA_EXPRESSION:
51 return "IR_DATA_EXPRESSION";
52 default:
53 abort();
54 }
55 }
56
57 enum ir_op_type {
58 IR_OP_UNKNOWN = 0,
59 IR_OP_ROOT,
60 IR_OP_LOAD,
61 IR_OP_UNARY,
62 IR_OP_BINARY,
63 IR_OP_LOGICAL,
64 };
65
66 static inline
67 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
119 const char *ir_load_expression_type_str(enum ir_load_expression_type type)
120 {
121 switch (type) {
122 case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT:
123 return "IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT";
124 case IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT:
125 return "IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT";
126 case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
127 return "IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT";
128 case IR_LOAD_EXPRESSION_GET_SYMBOL:
129 return "IR_LOAD_EXPRESSION_GET_SYMBOL";
130 case IR_LOAD_EXPRESSION_GET_INDEX:
131 return "IR_LOAD_EXPRESSION_GET_INDEX";
132 case IR_LOAD_EXPRESSION_LOAD_FIELD:
133 return "IR_LOAD_EXPRESSION_LOAD_FIELD";
134 default:
135 abort();
136 }
137 }
138
139 struct ir_load_expression_op {
140 struct ir_load_expression_op *next;
141 enum ir_load_expression_type type;
142 union {
143 char *symbol;
144 uint64_t index;
145 } u;
146 };
147
148 struct ir_load_expression {
149 struct ir_load_expression_op *child;
150 };
151
152 struct ir_op_load {
153 union {
154 struct {
155 enum ir_load_string_type type;
156 char *value;
157 } string;
158 int64_t num;
159 double flt;
160 char *ref;
161 struct ir_load_expression *expression;
162 } u;
163 };
164
165 struct ir_op_unary {
166 enum unary_op_type type;
167 struct ir_op *child;
168 };
169
170 struct ir_op_binary {
171 enum op_type type;
172 struct ir_op *left;
173 struct ir_op *right;
174 };
175
176 struct ir_op_logical {
177 enum op_type type;
178 struct ir_op *left;
179 struct ir_op *right;
180 };
181
182 struct ir_op {
183 /* common to all ops */
184 enum ir_op_type op;
185 enum ir_data_type data_type;
186 enum ir_op_signedness signedness;
187 enum ir_side side;
188
189 union {
190 struct ir_op_root root;
191 struct ir_op_load load;
192 struct ir_op_unary unary;
193 struct ir_op_binary binary;
194 struct ir_op_logical logical;
195 } u;
196 };
197
198 #endif /* _FILTER_IR_H */
This page took 0.049298 seconds and 5 git commands to generate.