Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge]: replace typeMap->constants with IR-based constants #526

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions frontends/common/constantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ const IR::Node* DoConstantFolding::postorder(IR::Member* e) {
result = list->components.at(index)->clone();
}
typeMap->setType(result, origtype);
typeMap->setCompileTimeConstant(result);
setConstant(e, result);
return result;
}
Expand Down Expand Up @@ -670,7 +669,6 @@ const IR::Node *DoConstantFolding::postorder(IR::Cast *e) {
auto result = expr->clone();
auto origtype = typeMap->getType(getOriginal());
typeMap->setType(result, origtype);
typeMap->setCompileTimeConstant(result);
setConstant(e, result);
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions frontends/p4/evaluator/evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ void Evaluator::popBlock(IR::Block* block) {
blockStack.pop_back();
}

void Evaluator::setValue(const IR::Node* node, const IR::CompileTimeValue* constant) {
void Evaluator::setValue(const IR::Node* node, const IR::ICompileTimeValue* constant) {
CHECK_NULL(node);
CHECK_NULL(constant);
auto block = currentBlock();
LOG2("Set " << node << " to " << constant << " in " << block);
block->setValue(node, constant);
}

const IR::CompileTimeValue* Evaluator::getValue(const IR::Node* node) const {
const IR::ICompileTimeValue* Evaluator::getValue(const IR::Node* node) const {
CHECK_NULL(node);
auto block = currentBlock();
auto result = block->getValue(node);
Expand Down Expand Up @@ -92,10 +92,10 @@ bool Evaluator::preorder(const IR::Declaration_Constant* decl) {
return false;
}

std::vector<const IR::CompileTimeValue*>*
std::vector<const IR::ICompileTimeValue*>*
Evaluator::evaluateArguments(const IR::Vector<IR::Expression>* arguments, IR::Block* context) {
P4::DoConstantFolding cf(refMap, nullptr);
auto values = new std::vector<const IR::CompileTimeValue*>();
auto values = new std::vector<const IR::ICompileTimeValue*>();
pushBlock(context);
for (auto e : *arguments) {
auto folded = e->apply(cf); // constant fold argument
Expand Down
6 changes: 3 additions & 3 deletions frontends/p4/evaluator/evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class Evaluator final : public Inspector, public IHasBlock {
IR::ToplevelBlock* getToplevelBlock() override { return toplevelBlock; }

IR::Block* currentBlock() const;
void setValue(const IR::Node* node, const IR::CompileTimeValue* constant);
const IR::CompileTimeValue* getValue(const IR::Node* node) const;
void setValue(const IR::Node* node, const IR::ICompileTimeValue* constant);
const IR::ICompileTimeValue* getValue(const IR::Node* node) const;

std::vector<const IR::CompileTimeValue*>*
std::vector<const IR::ICompileTimeValue*>*
evaluateArguments(const IR::Vector<IR::Expression>* arguments,
IR::Block* context);

Expand Down
2 changes: 0 additions & 2 deletions frontends/p4/sideEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ class DismantleExpression : public Transform {
typeMap->setType(expression, type);
if (typeMap->isLeftValue(orig))
typeMap->setLeftValue(expression);
if (typeMap->isCompileTimeConstant(orig))
typeMap->setCompileTimeConstant(expression);
result->final = expression;
return result->final;
}
Expand Down
Loading