[core] code format
This commit is contained in:
parent
11de8965a8
commit
edb0e687f1
|
@ -369,15 +369,17 @@ int rename_modules_template(T& openfpga_ctx, const Command& cmd,
|
|||
}
|
||||
|
||||
/* Apply renaming on the user version */
|
||||
status = partial_rename_fabric_modules(openfpga_ctx.mutable_module_graph(),
|
||||
user_module_name_map,
|
||||
cmd_context.option_enable(cmd, opt_verbose));
|
||||
status = partial_rename_fabric_modules(
|
||||
openfpga_ctx.mutable_module_graph(), user_module_name_map,
|
||||
cmd_context.option_enable(cmd, opt_verbose));
|
||||
if (status != CMD_EXEC_SUCCESS) {
|
||||
return CMD_EXEC_FATAL_ERROR;
|
||||
}
|
||||
|
||||
/* Update the internal version of module name map based on users' version */
|
||||
return update_module_name_map_with_user_version(openfpga_ctx.mutable_module_name_map(), user_module_name_map, cmd_context.option_enable(cmd, opt_verbose));
|
||||
return update_module_name_map_with_user_version(
|
||||
openfpga_ctx.mutable_module_name_map(), user_module_name_map,
|
||||
cmd_context.option_enable(cmd, opt_verbose));
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
|
|
|
@ -92,7 +92,8 @@ int update_module_map_name_with_indexing_names(ModuleNameMap& module_name_map,
|
|||
return CMD_EXEC_SUCCESS;
|
||||
}
|
||||
|
||||
/** @brief Apply module renaming for all the modules. Require the module name map cover all the modules */
|
||||
/** @brief Apply module renaming for all the modules. Require the module name
|
||||
* map cover all the modules */
|
||||
int rename_fabric_modules(ModuleManager& module_manager,
|
||||
const ModuleNameMap& module_name_map,
|
||||
const bool& verbose) {
|
||||
|
@ -102,15 +103,15 @@ int rename_fabric_modules(ModuleManager& module_manager,
|
|||
std::string curr_module_name = module_manager.module_name(curr_module);
|
||||
/* Error out if the new name does not exist ! */
|
||||
if (!module_name_map.name_exist(curr_module_name)) {
|
||||
VTR_LOG_ERROR("The built-in module name '%s' does not exist! Abort renaming...\n", curr_module_name.c_str());
|
||||
VTR_LOG_ERROR(
|
||||
"The built-in module name '%s' does not exist! Abort renaming...\n",
|
||||
curr_module_name.c_str());
|
||||
return CMD_EXEC_FATAL_ERROR;
|
||||
}
|
||||
std::string new_name =
|
||||
module_name_map.name(curr_module_name);
|
||||
std::string new_name = module_name_map.name(curr_module_name);
|
||||
if (new_name != curr_module_name) {
|
||||
VTR_LOGV(verbose, "Rename module '%s' to its new name '%s'\n",
|
||||
curr_module_name.c_str(),
|
||||
new_name.c_str());
|
||||
curr_module_name.c_str(), new_name.c_str());
|
||||
module_manager.set_module_name(curr_module, new_name);
|
||||
}
|
||||
cnt++;
|
||||
|
@ -119,24 +120,26 @@ int rename_fabric_modules(ModuleManager& module_manager,
|
|||
return status;
|
||||
}
|
||||
|
||||
/** @brief Apply module renaming based on the pairs given by module name map only. So not all the modules are renamed. So the module name map just cover a subset of modules */
|
||||
/** @brief Apply module renaming based on the pairs given by module name map
|
||||
* only. So not all the modules are renamed. So the module name map just cover a
|
||||
* subset of modules */
|
||||
int partial_rename_fabric_modules(ModuleManager& module_manager,
|
||||
const ModuleNameMap& module_name_map,
|
||||
const bool& verbose) {
|
||||
const ModuleNameMap& module_name_map,
|
||||
const bool& verbose) {
|
||||
int status = CMD_EXEC_SUCCESS;
|
||||
size_t cnt = 0;
|
||||
for (std::string built_in_name : module_name_map.tags()) {
|
||||
ModuleId curr_module = module_manager.find_module(built_in_name);
|
||||
if (!module_manager.valid_module_id(curr_module)) {
|
||||
VTR_LOG_ERROR("The built-in module name '%s' does not exist! Abort renaming...\n", built_in_name.c_str());
|
||||
VTR_LOG_ERROR(
|
||||
"The built-in module name '%s' does not exist! Abort renaming...\n",
|
||||
built_in_name.c_str());
|
||||
return CMD_EXEC_FATAL_ERROR;
|
||||
}
|
||||
std::string new_name =
|
||||
module_name_map.name(built_in_name);
|
||||
std::string new_name = module_name_map.name(built_in_name);
|
||||
if (new_name != built_in_name) {
|
||||
VTR_LOGV(verbose, "Rename module '%s' to its new name '%s'\n",
|
||||
built_in_name.c_str(),
|
||||
new_name.c_str());
|
||||
built_in_name.c_str(), new_name.c_str());
|
||||
module_manager.set_module_name(curr_module, new_name);
|
||||
}
|
||||
cnt++;
|
||||
|
@ -145,30 +148,37 @@ int partial_rename_fabric_modules(ModuleManager& module_manager,
|
|||
return status;
|
||||
}
|
||||
|
||||
|
||||
/** @brief The module name map kept in openfpga context always has a built-in name with coordinates.
|
||||
* while users apply renaming or other internal renaming is applied, e.g., through option '--name_module_using_index', the module name in the module graph can be changed. So in the user's version, the built-in name may become index or anything else.
|
||||
* We have to keep the built-in name consistent (use coordinates, otherwise other engines may not work, which rely on this convention) while the given name should follow the users' definition. So we need an update here
|
||||
* For example:
|
||||
* the current module name map is 'tile_1__1_' -> 'tile_4_'
|
||||
* the user's module name map is 'tile_4_' -> 'tile_big'
|
||||
* The resulting module name map is 'tile_1__1_' -> 'tile_big'
|
||||
/** @brief The module name map kept in openfpga context always has a built-in
|
||||
* name with coordinates. while users apply renaming or other internal renaming
|
||||
* is applied, e.g., through option '--name_module_using_index', the module name
|
||||
* in the module graph can be changed. So in the user's version, the built-in
|
||||
* name may become index or anything else. We have to keep the built-in name
|
||||
* consistent (use coordinates, otherwise other engines may not work, which rely
|
||||
* on this convention) while the given name should follow the users' definition.
|
||||
* So we need an update here For example: the current module name map is
|
||||
* 'tile_1__1_' -> 'tile_4_' the user's module name map is 'tile_4_' ->
|
||||
* 'tile_big' The resulting module name map is 'tile_1__1_' -> 'tile_big'
|
||||
*/
|
||||
int update_module_name_map_with_user_version(ModuleNameMap& curr_module_name_map,
|
||||
const ModuleNameMap& user_module_name_map,
|
||||
const bool& verbose) {
|
||||
int update_module_name_map_with_user_version(
|
||||
ModuleNameMap& curr_module_name_map,
|
||||
const ModuleNameMap& user_module_name_map, const bool& verbose) {
|
||||
int status = CMD_EXEC_SUCCESS;
|
||||
size_t cnt = 0;
|
||||
for (std::string user_tag : user_module_name_map.tags()) {
|
||||
if (!curr_module_name_map.tag_exist(user_tag)) {
|
||||
VTR_LOG_ERROR("The built-in module name '%s' given by user does not exist in current module name map! Abort updating...\n", user_tag.c_str());
|
||||
VTR_LOG_ERROR(
|
||||
"The built-in module name '%s' given by user does not exist in current "
|
||||
"module name map! Abort updating...\n",
|
||||
user_tag.c_str());
|
||||
return CMD_EXEC_FATAL_ERROR;
|
||||
}
|
||||
std::string built_in_tag = curr_module_name_map.tag(user_tag);
|
||||
curr_module_name_map.set_tag_to_name_pair(built_in_tag, user_module_name_map.name(user_tag));
|
||||
VTR_LOGV(verbose, "Now module built-in name '%s' is pointed to its new name '%s' (old name '%s' is deleted)\n",
|
||||
built_in_tag.c_str(),
|
||||
user_module_name_map.name(user_tag).c_str(),
|
||||
curr_module_name_map.set_tag_to_name_pair(
|
||||
built_in_tag, user_module_name_map.name(user_tag));
|
||||
VTR_LOGV(verbose,
|
||||
"Now module built-in name '%s' is pointed to its new name '%s' "
|
||||
"(old name '%s' is deleted)\n",
|
||||
built_in_tag.c_str(), user_module_name_map.name(user_tag).c_str(),
|
||||
user_tag.c_str());
|
||||
cnt++;
|
||||
}
|
||||
|
|
|
@ -30,12 +30,12 @@ int rename_fabric_modules(ModuleManager& module_manager,
|
|||
const bool& verbose);
|
||||
|
||||
int partial_rename_fabric_modules(ModuleManager& module_manager,
|
||||
const ModuleNameMap& module_name_map,
|
||||
const bool& verbose);
|
||||
const ModuleNameMap& module_name_map,
|
||||
const bool& verbose);
|
||||
|
||||
int update_module_name_map_with_user_version(ModuleNameMap& curr_module_name_map,
|
||||
const ModuleNameMap& user_module_name_map,
|
||||
const bool& verbose);
|
||||
int update_module_name_map_with_user_version(
|
||||
ModuleNameMap& curr_module_name_map,
|
||||
const ModuleNameMap& user_module_name_map, const bool& verbose);
|
||||
|
||||
} /* end namespace openfpga */
|
||||
|
||||
|
|
Loading…
Reference in New Issue