Skip to content

Commit

Permalink
Do not insert Type_SpecializedCanonical in the IR tree
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <[email protected]>
  • Loading branch information
Mihai Budiu committed Nov 19, 2022
1 parent d097e62 commit 992b473
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
14 changes: 7 additions & 7 deletions frontends/p4/typeChecking/typeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,7 @@ const IR::Node* TypeInference::postorder(IR::P4ListExpression* expression) {
}

if (changed)
expression = new IR::P4ListExpression(expression->srcInfo, *vec, elementType);
expression = new IR::P4ListExpression(expression->srcInfo, *vec, elementType->getP4Type());
auto type = new IR::Type_P4List(expression->srcInfo, elementType);
setType(getOriginal(), type);
setType(expression, type);
Expand Down Expand Up @@ -2713,22 +2713,22 @@ const IR::Node* TypeInference::postorder(IR::Cast* expression) {
}
}
}
if (auto vt = concreteType->to<IR::Type_P4List>()) {
auto vecElementType = vt->elementType;
if (auto lt = concreteType->to<IR::Type_P4List>()) {
auto listElementType = lt->elementType;
if (auto le = expression->expr->to<IR::ListExpression>()) {
IR::Vector<IR::Expression> vec;
bool isConstant = true;
for (size_t i = 0; i < le->size(); i++) {
auto compI = le->components.at(i);
auto src = assignment(expression, vecElementType, compI);
auto src = assignment(expression, listElementType, compI);
if (!isCompileTimeConstant(src))
isConstant = false;
vec.push_back(src);
}
auto vecType = castType->getP4Type();
setType(vecType, new IR::Type_Type(vt));
auto result = new IR::P4ListExpression(le->srcInfo, vec, vecElementType);
setType(result, vt);
setType(vecType, new IR::Type_Type(lt));
auto result = new IR::P4ListExpression(le->srcInfo, vec, listElementType->getP4Type());
setType(result, lt);
if (isConstant) {
setCompileTimeConstant(result);
setCompileTimeConstant(getOriginal<IR::Expression>());
Expand Down
8 changes: 6 additions & 2 deletions midend/eliminateTuples.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ class DoReplaceTuples final : public Transform {
// We want to keep these as tuples.
return skip(set);
}
const IR::Node* preorder(IR::Type_P4List* list) override
{ return skip(list); }
const IR::Node* preorder(IR::P4ListExpression* expression) override {
return skip(expression);
}
const IR::Node* preorder(IR::Type_P4List* list) override {
return skip(list);
}
};

class EliminateTuples final : public PassManager {
Expand Down

0 comments on commit 992b473

Please sign in to comment.