forked from p4lang/p4c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheliminateTypedefs.h
36 lines (29 loc) · 1.06 KB
/
eliminateTypedefs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef MIDEND_ELIMINATETYPEDEFS_H_
#define MIDEND_ELIMINATETYPEDEFS_H_
#include "frontends/p4/typeChecking/typeChecker.h"
namespace P4 {
/**
* Replaces typedef by the type it was defined to represent.
* This can be done when all the information required by the
* control-plane has been generated.
*/
class DoReplaceTypedef final : public Transform {
const ReferenceMap *refMap;
public:
explicit DoReplaceTypedef(const ReferenceMap *refMap) : refMap(refMap) {}
const IR::Type *preorder(IR::Type_Name *type) override;
};
class EliminateTypedef final : public PassManager {
public:
EliminateTypedef(ReferenceMap *refMap, TypeMap *typeMap,
TypeChecking *typeChecking = nullptr) {
if (!typeChecking)
typeChecking = new TypeChecking(refMap, typeMap);
passes.push_back(typeChecking);
passes.push_back(new DoReplaceTypedef(refMap));
passes.push_back(new TypeChecking(refMap, typeMap, true));
setName("EliminateTypedefs");
}
};
} // namespace P4
#endif /* MIDEND_ELIMINATETYPEDEFS_H_ */