P4C
The P4 Compiler
Loading...
Searching...
No Matches
ir/annotations.h
1/*
2SPDX-FileCopyrightText: 2026 The P4 Language Consortium
3
4SPDX-License-Identifier: Apache-2.0
5
6Licensed under the Apache License, Version 2.0 (the "License");
7you may not use this file except in compliance with the License.
8You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing, software
13distributed under the License is distributed on an "AS IS" BASIS,
14WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15See the License for the specific language governing permissions and
16limitations under the License.
17*/
18
19#ifndef IR_ANNOTATIONS_H_
20#define IR_ANNOTATIONS_H_
21
22#include <initializer_list>
23
24#include "ir/vector.h"
25#include "lib/cstring.h"
26
27namespace P4::IR {
28class Expression;
29
30namespace Annotations {
32[[nodiscard]] Vector<Annotation> maybeAddNameAnnotation(const Vector<Annotation> &annos,
33 cstring name);
35[[nodiscard]] Vector<Annotation> setNameAnnotation(const Vector<Annotation> &annos, cstring name);
36[[nodiscard]] Vector<Annotation> withoutNameAnnotation(const Vector<Annotation> &annos);
37
38void addIfNew(Vector<Annotation> &annotations, cstring name, const Expression *expr,
39 bool structured = false);
41void addIfNew(Vector<Annotation> &annotations, cstring name,
42 std::initializer_list<const Expression *> exprs, bool structured = false);
43void addIfNew(Vector<Annotation> &annotations, const IR::Annotation *ann);
44void addOrReplace(Vector<Annotation> &annotations, cstring name, const Expression *expr,
45 bool structured = false);
46void addOrReplace(Vector<Annotation> &annotations, cstring name,
47 std::initializer_list<const Expression *> exprs, bool structured = false);
48void addOrReplace(Vector<Annotation> &annotations, const IR::Annotation *ann);
49} // namespace Annotations
50
51} // namespace P4::IR
52
53#endif // IR_ANNOTATIONS_H_
Definition constantParsing.h:13