SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / src / common / filter / filter-ir.h
CommitLineData
953192ba
MD
1#ifndef _FILTER_IR_H
2#define _FILTER_IR_H
3
4/*
5 * filter-ir.h
6 *
7 * LTTng filter ir
8 *
ab5be9fa 9 * Copyright 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
953192ba 10 *
ab5be9fa 11 * SPDX-License-Identifier: LGPL-2.1-only
953192ba 12 *
953192ba
MD
13 */
14
15#include "filter-ast.h"
16
17enum ir_op_signedness {
18 IR_SIGN_UNKNOWN = 0,
19 IR_SIGNED,
20 IR_UNSIGNED,
21 IR_SIGN_DYN, /* signedness determined dynamically */
22};
23
24enum ir_data_type {
25 IR_DATA_UNKNOWN = 0,
26 IR_DATA_STRING,
27 IR_DATA_NUMERIC, /* numeric and boolean */
e90d8561 28 IR_DATA_FLOAT,
953192ba 29 IR_DATA_FIELD_REF,
586dc72f 30 IR_DATA_GET_CONTEXT_REF,
bff988fa 31 IR_DATA_EXPRESSION,
953192ba
MD
32};
33
2463b787
JR
34static inline
35const 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
953192ba
MD
57enum 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
2463b787
JR
66static inline
67const 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
953192ba
MD
87/* left or right child */
88enum ir_side {
89 IR_SIDE_UNKNOWN = 0,
90 IR_LEFT,
91 IR_RIGHT,
92};
93
9f449915
PP
94enum 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
953192ba
MD
105struct ir_op_root {
106 struct ir_op *child;
107};
108
bff988fa
MD
109enum 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
2463b787
JR
118static inline
119const 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
bff988fa
MD
139struct 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
148struct ir_load_expression {
149 struct ir_load_expression_op *child;
150};
151
953192ba
MD
152struct ir_op_load {
153 union {
9f449915
PP
154 struct {
155 enum ir_load_string_type type;
156 char *value;
157 } string;
953192ba 158 int64_t num;
e90d8561 159 double flt;
953192ba 160 char *ref;
bff988fa 161 struct ir_load_expression *expression;
953192ba
MD
162 } u;
163};
164
165struct ir_op_unary {
166 enum unary_op_type type;
167 struct ir_op *child;
168};
169
170struct ir_op_binary {
171 enum op_type type;
172 struct ir_op *left;
173 struct ir_op *right;
174};
175
176struct ir_op_logical {
177 enum op_type type;
178 struct ir_op *left;
179 struct ir_op *right;
180};
181
182struct 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.107501 seconds and 5 git commands to generate.