P4C
The P4 Compiler
Loading...
Searching...
No Matches
common/utils.h
1
18
19#ifndef BACKENDS_TOFINO_BF_P4C_COMMON_UTILS_H_
20#define BACKENDS_TOFINO_BF_P4C_COMMON_UTILS_H_
21
22#include <iostream>
23
24#include "ir/ir.h"
25#include "lib/error_catalog.h"
26#include "lib/exceptions.h"
27#include "lib/gc.h"
28
29#if defined(__GNUC__) && __GNUC__ < 7
30#define BFN_FALLTHROUGH /* fall through */
31#define BFN_MAYBE_UNUSED __attribute__((unused))
32#else
33#define BFN_FALLTHROUGH [[fallthrough]]
34#define BFN_MAYBE_UNUSED [[maybe_unused]]
35#endif
36
37using namespace P4;
38
44void end_fatal_error();
45
47template <typename... T>
48inline void fatal_error(const char *format, T... args) {
49 error(format, args...);
50 end_fatal_error();
51}
52
54template <typename... T>
55inline void fatal_error(int kind, const char *format, T... args) {
56 error(kind, format, args...);
57 end_fatal_error();
58}
59
60#ifdef BAREFOOT_INTERNAL
61#define INTERNAL_WARNING(...) warning(ErrorType::WARN_UNSUPPORTED, __VA_ARGS__)
62#else
63#define INTERNAL_WARNING(...) BUG(__VA_ARGS__)
64#endif
65
68bool ghost_only_on_other_pipes(int pipe_id);
69
72std::pair<cstring, cstring> get_key_and_mask(const cstring &input);
73
76std::tuple<bool, cstring, int, int> get_key_slice_info(const cstring &input);
77
78const IR::Vector<IR::Expression> *getListExprComponents(const IR::Node &node);
79
80bool is_starter_pistol_table(const cstring &tableName);
81#endif /* BACKENDS_TOFINO_BF_P4C_COMMON_UTILS_H_ */
Definition node.h:94
Definition ir/vector.h:59
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:58