Skip to content

Commit

Permalink
clang-format
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 992b473 commit f574efc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
1 change: 1 addition & 0 deletions backends/p4test/midend.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace P4Test {

class MidEnd : public PassManager {
std::vector<DebugHook> hooks;

public:
P4::ReferenceMap refMap;
P4::TypeMap typeMap;
Expand Down
4 changes: 2 additions & 2 deletions frontends/p4/evaluator/evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ bool Evaluator::preorder(const IR::ListExpression* list) {
return false;
}

bool Evaluator::preorder(const IR::P4ListExpression *list) {
bool Evaluator::preorder(const IR::P4ListExpression* list) {
LOG2("Evaluating " << list);
visit(list->components);
IR::Vector<IR::Node> comp;
Expand All @@ -322,7 +322,7 @@ bool Evaluator::preorder(const IR::P4ListExpression *list) {
return false;
}

bool Evaluator::preorder(const IR::StructExpression *se) {
bool Evaluator::preorder(const IR::StructExpression* se) {
LOG2("Evaluating " << se);
visit(se->components);
IR::Vector<IR::Node> comp;
Expand Down
17 changes: 6 additions & 11 deletions frontends/p4/typeChecking/typeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ const IR::Type* TypeInference::canonicalize(const IR::Type* type) {
return canon;
} else if (auto vec = type->to<IR::Type_P4List>()) {
auto et = canonicalize(vec->elementType);
if (et == nullptr)
return nullptr;
if (et == nullptr) return nullptr;
const IR::Type* canon;
if (et == vec->elementType)
canon = type;
Expand Down Expand Up @@ -2069,16 +2068,13 @@ const IR::Node* TypeInference::postorder(IR::P4ListExpression* expression) {
auto vec = new IR::Vector<IR::Expression>();
bool changed = false;
for (auto c : expression->components) {
if (!isCompileTimeConstant(c))
constant = false;
if (!isCompileTimeConstant(c)) constant = false;
auto type = getType(c);
if (type == nullptr)
return expression;
if (type == nullptr) return expression;
auto tvs = unify(expression, elementType, type,
"Vector element type '%1%' does not match expected type '%2%'",
{ type, elementType });
if (tvs == nullptr)
return expression;
{type, elementType});
if (tvs == nullptr) return expression;
if (!tvs->isIdentity()) {
ConstantTypeSubstitution cts(tvs, refMap, typeMap, this);
auto converted = cts.convert(c);
Expand Down Expand Up @@ -2721,8 +2717,7 @@ const IR::Node* TypeInference::postorder(IR::Cast* expression) {
for (size_t i = 0; i < le->size(); i++) {
auto compI = le->components.at(i);
auto src = assignment(expression, listElementType, compI);
if (!isCompileTimeConstant(src))
isConstant = false;
if (!isCompileTimeConstant(src)) isConstant = false;
vec.push_back(src);
}
auto vecType = castType->getP4Type();
Expand Down
13 changes: 6 additions & 7 deletions midend/eliminateTuples.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ class DoReplaceTuples final : public Transform {
: repl(new ReplacementMap(refMap, typeMap)) {
setName("DoReplaceTuples");
}
const IR::Node* skip(const IR::Node* node) { prune(); return node; }
const IR::Node* skip(const IR::Node* node) {
prune();
return node;
}
const IR::Node* postorder(IR::Type_BaseList* type) override;
const IR::Node* insertReplacements(const IR::Node* before);
const IR::Node* postorder(IR::Type_Struct* type) override { return insertReplacements(type); }
Expand All @@ -104,12 +107,8 @@ class DoReplaceTuples final : public Transform {
// We want to keep these as tuples.
return skip(set);
}
const IR::Node* preorder(IR::P4ListExpression* expression) override {
return skip(expression);
}
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 f574efc

Please sign in to comment.