32class TypeMap final :
public ProgramMap {
35 std::vector<const IR::Type *> canonicalTuples;
36 std::vector<const IR::Type *> canonicalStacks;
37 std::vector<const IR::Type *> canonicalP4lists;
38 std::vector<const IR::Type *> canonicalLists;
41 absl::flat_hash_map<const IR::Node *, const IR::Type *, Util::Hash> typeMap;
43 absl::flat_hash_set<const IR::Expression *, Util::Hash> leftValues;
47 absl::flat_hash_set<const IR::Expression *, Util::Hash> constants;
53 void checkPrecondition(
const IR::Node *element,
const IR::Type *type)
const;
56 TypeMap() : ProgramMap(
"TypeMap"),
strictStruct(
false) {}
61 void setStrictStruct(
bool value) {
strictStruct = value; }
62 bool contains(
const IR::Node *element) {
return typeMap.count(element) != 0; }
63 void setType(
const IR::Node *element,
const IR::Type *type);
64 const IR::Type *getType(
const IR::Node *element,
bool notNull =
false)
const;
66 const IR::Type *getTypeType(
const IR::Node *element,
bool notNull)
const;
67 void dbprint(std::ostream &out)
const override;
69 bool isLeftValue(
const IR::Expression *expression)
const {
70 return leftValues.count(expression) > 0;
72 bool isCompileTimeConstant(
const IR::Expression *expression)
const;
73 size_t size()
const {
return typeMap.size(); }
75 void setLeftValue(
const IR::Expression *expression);
76 void cloneExpressionProperties(
const IR::Expression *to,
const IR::Expression *from);
77 void setCompileTimeConstant(
const IR::Expression *expression);
78 void addSubstitutions(
const TypeVariableSubstitution *tvs);
79 const IR::Type *getSubstitution(
const IR::ITypeVar *var) {
80 return allTypeVariables.lookup(var);
82 const TypeVariableSubstitution *getSubstitutions()
const {
return &allTypeVariables; }
87 bool equivalent(
const IR::Type *left,
const IR::Type *right,
bool strict =
false)
const;
94 const IR::Type *getCanonical(
const IR::Type *type);
98 int widthBits(
const IR::Type *type,
const IR::Node *errorPosition,
bool max)
const;
bool equivalent(const IR::Type *left, const IR::Type *right, bool strict=false) const
Definition typeMap.cpp:130
int widthBits(const IR::Type *type, const IR::Node *errorPosition, bool max) const
Definition typeMap.cpp:346
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13