P4C
The P4 Compiler
Loading...
Searching...
No Matches
optimizeExpressions.h
1#ifndef FRONTENDS_P4_OPTIMIZEEXPRESSIONS_H_
2#define FRONTENDS_P4_OPTIMIZEEXPRESSIONS_H_
3
4#include "frontends/common/constantFolding.h"
5#include "frontends/p4/strengthReduction.h"
6
7namespace P4 {
8
11inline const IR::Expression *optimizeExpression(const IR::Expression *node) {
12 auto pass = PassRepeated({
13 new P4::StrengthReduction(nullptr, nullptr),
14 new P4::ConstantFolding(nullptr, false),
15 });
16 node = node->apply(pass);
17 BUG_CHECK(::P4::errorCount() == 0, "Encountered errors while trying to optimize expressions.");
18 return node;
19}
20
21} // namespace P4
22
23#endif /* FRONTENDS_P4_OPTIMIZEEXPRESSIONS_H_ */
Definition constantFolding.h:186
Definition ir/pass_manager.h:145
Definition strengthReduction.h:119
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
const IR::Expression * optimizeExpression(const IR::Expression *node)
Definition optimizeExpressions.h:11
unsigned errorCount()
Definition lib/error.h:35