Move filter related code to libfilter under libcommon
[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 enum ir_op_type {
35 IR_OP_UNKNOWN = 0,
36 IR_OP_ROOT,
37 IR_OP_LOAD,
38 IR_OP_UNARY,
39 IR_OP_BINARY,
40 IR_OP_LOGICAL,
41 };
42
43 /* left or right child */
44 enum ir_side {
45 IR_SIDE_UNKNOWN = 0,
46 IR_LEFT,
47 IR_RIGHT,
48 };
49
50 enum ir_load_string_type {
51 /* Plain, no globbing at all: `hello world`. */
52 IR_LOAD_STRING_TYPE_PLAIN = 0,
53
54 /* Star at the end only: `hello *`. */
55 IR_LOAD_STRING_TYPE_GLOB_STAR_END,
56
57 /* At least one star, anywhere, but not at the end only: `he*wor*`. */
58 IR_LOAD_STRING_TYPE_GLOB_STAR,
59 };
60
61 struct ir_op_root {
62 struct ir_op *child;
63 };
64
65 enum ir_load_expression_type {
66 IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT,
67 IR_LOAD_EXPRESSION_GET_APP_CONTEXT_ROOT,
68 IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT,
69 IR_LOAD_EXPRESSION_GET_SYMBOL,
70 IR_LOAD_EXPRESSION_GET_INDEX,
71 IR_LOAD_EXPRESSION_LOAD_FIELD,
72 };
73
74 struct ir_load_expression_op {
75 struct ir_load_expression_op *next;
76 enum ir_load_expression_type type;
77 union {
78 char *symbol;
79 uint64_t index;
80 } u;
81 };
82
83 struct ir_load_expression {
84 struct ir_load_expression_op *child;
85 };
86
87 struct ir_op_load {
88 union {
89 struct {
90 enum ir_load_string_type type;
91 char *value;
92 } string;
93 int64_t num;
94 double flt;
95 char *ref;
96 struct ir_load_expression *expression;
97 } u;
98 };
99
100 struct ir_op_unary {
101 enum unary_op_type type;
102 struct ir_op *child;
103 };
104
105 struct ir_op_binary {
106 enum op_type type;
107 struct ir_op *left;
108 struct ir_op *right;
109 };
110
111 struct ir_op_logical {
112 enum op_type type;
113 struct ir_op *left;
114 struct ir_op *right;
115 };
116
117 struct ir_op {
118 /* common to all ops */
119 enum ir_op_type op;
120 enum ir_data_type data_type;
121 enum ir_op_signedness signedness;
122 enum ir_side side;
123
124 union {
125 struct ir_op_root root;
126 struct ir_op_load load;
127 struct ir_op_unary unary;
128 struct ir_op_binary binary;
129 struct ir_op_logical logical;
130 } u;
131 };
132
133 #endif /* _FILTER_IR_H */
This page took 0.045069 seconds and 4 git commands to generate.