void replace_ids(const std::string &prefix, const std::map<std::string, std::string> &rules);
void mem2reg_as_needed_pass1(dict<AstNode*, pool<std::string>> &mem2reg_places,
dict<AstNode*, uint32_t> &mem2reg_flags, dict<AstNode*, uint32_t> &proc_flags, uint32_t &status_flags);
- void mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod, AstNode *block);
+ bool mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod, AstNode *block);
bool mem2reg_check(pool<AstNode*> &mem2reg_set);
void meminfo(int &mem_width, int &mem_size, int &addr_bits);
}
}
- mem2reg_as_needed_pass2(mem2reg_set, this, NULL);
+ while (mem2reg_as_needed_pass2(mem2reg_set, this, NULL)) { }
for (size_t i = 0; i < children.size(); i++) {
if (mem2reg_set.count(children[i]) > 0) {
}
// actually replace memories with registers
-void AstNode::mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod, AstNode *block)
+bool AstNode::mem2reg_as_needed_pass2(pool<AstNode*> &mem2reg_set, AstNode *mod, AstNode *block)
{
+ bool did_something = false;
+
if (type == AST_BLOCK)
block = this;
children[0]->id2ast = NULL;
children[0]->str = id_data;
type = AST_ASSIGN_EQ;
+
+ did_something = true;
}
if (mem2reg_check(mem2reg_set))
auto children_list = children;
for (size_t i = 0; i < children_list.size(); i++)
- children_list[i]->mem2reg_as_needed_pass2(mem2reg_set, mod, block);
+ if (children_list[i]->mem2reg_as_needed_pass2(mem2reg_set, mod, block))
+ did_something = true;
+
+ return did_something;
}
// calulate memory dimensions