P4C
The P4 Compiler
Loading...
Searching...
No Matches
common/utils.h
1
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
39struct DumpPipe : public Inspector {
40 const char *heading;
41 DumpPipe() : heading(nullptr) {}
42 explicit DumpPipe(const char *h) : heading(h) {}
43#if BAREFOOT_INTERNAL
44 bool preorder(const IR::Node *pipe) override;
45#endif // BAREFOOT_INTERNAL
46};
47
53void end_fatal_error();
54
56template <typename... T>
57inline void fatal_error(const char *format, T... args) {
58 error(format, args...);
59 end_fatal_error();
60}
61
63template <typename... T>
64inline void fatal_error(int kind, const char *format, T... args) {
65 error(kind, format, args...);
66 end_fatal_error();
67}
68
69#ifdef BAREFOOT_INTERNAL
70#define INTERNAL_WARNING(...) warning(ErrorType::WARN_UNSUPPORTED, __VA_ARGS__)
71#else
72#define INTERNAL_WARNING(...) BUG(__VA_ARGS__)
73#endif
74
77bool ghost_only_on_other_pipes(int pipe_id);
78
81std::pair<cstring, cstring> get_key_and_mask(const cstring &input);
82
85std::tuple<bool, cstring, int, int> get_key_slice_info(const cstring &input);
86
87const IR::Vector<IR::Expression> *getListExprComponents(const IR::Node &node);
88
89bool is_starter_pistol_table(const cstring &tableName);
90#endif /* BACKENDS_TOFINO_BF_P4C_COMMON_UTILS_H_ */
Definition node.h:94
Definition vector.h:59
Definition visitor.h:400
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:51
Definition common/utils.h:39