P4C
The P4 Compiler
Loading...
Searching...
No Matches
simplifySwitch.h
1/*
2 * Copyright 2021 VMware, Inc.
3 * SPDX-FileCopyrightText: 2021 VMware, Inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef FRONTENDS_P4_SIMPLIFYSWITCH_H_
9#define FRONTENDS_P4_SIMPLIFYSWITCH_H_
10
11#include "frontends/common/resolveReferences/resolveReferences.h"
12#include "frontends/p4/typeChecking/typeChecker.h"
13#include "ir/ir.h"
14
15namespace P4 {
16
19class DoSimplifySwitch : public Transform {
20 TypeMap *typeMap;
21
22 bool matches(const IR::Expression *left, const IR::Expression *right) const;
23
24 public:
25 explicit DoSimplifySwitch(TypeMap *typeMap) : typeMap(typeMap) {
26 setName("DoSimplifySwitch");
27 CHECK_NULL(typeMap);
28 }
29
30 const IR::Node *postorder(IR::SwitchStatement *stat) override;
31};
32
33class SimplifySwitch : public PassManager {
34 public:
35 explicit SimplifySwitch(TypeMap *typeMap) {
36 passes.push_back(new TypeChecking(nullptr, typeMap));
37 passes.push_back(new DoSimplifySwitch(typeMap));
38 setName("SimplifySwitch");
39 }
40};
41
42} // namespace P4
43
44#endif /* FRONTENDS_P4_SIMPLIFYSWITCH_H_ */
Simplify select and switch statements that have constant arguments.
Definition simplifySwitch.h:19
Definition node.h:53
Definition visitor.h:442
Definition typeChecker.h:55
Definition typeMap.h:32
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13