Skip to content

Commit 0be355d

Browse files
[Scatter-Gather] Add inline to enum-string maps
Using inline variables make sure the data in the map is not duplicated when including the header file in multiple headers. This C++17 feature was explicitly added to facilitate this usecase (defining const variables in header files.)
1 parent 44d1078 commit 0be355d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

libs/libarchfpga/src/scatter_gather_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ enum class e_scatter_gather_type {
1919
*
2020
*/
2121
struct t_sg_location {
22-
e_sb_location type; ///< Type of locations that the pattern is instantiated at.
23-
int num; ///< Number of scatter-gather pattern instantiations per location.
22+
e_sb_location type; ///< Type of locations that the pattern is instantiated at.
23+
int num; ///< Number of scatter-gather pattern instantiations per location.
2424
std::string sg_link_name; ///< Name of scatter-gather link to be used.
2525
};
2626

libs/libarchfpga/src/switchblock_types.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum e_side : unsigned char {
3131
NUM_3D_SIDES = 6,
3232
};
3333

34-
const std::unordered_map<char, e_side> CHAR_SIDE_MAP = {
34+
inline const std::unordered_map<char, e_side> CHAR_SIDE_MAP = {
3535
{'T', TOP},
3636
{'t', TOP},
3737
{'R', RIGHT},
@@ -64,12 +64,12 @@ enum class e_sb_location {
6464
E_XY_SPECIFIED
6565
};
6666

67-
const std::unordered_map<std::string, e_sb_location> SB_LOCATION_STRING_MAP = {{"EVERYWHERE", e_sb_location::E_EVERYWHERE},
68-
{"PERIMETER", e_sb_location::E_PERIMETER},
69-
{"CORE", e_sb_location::E_CORE},
70-
{"CORNER", e_sb_location::E_CORNER},
71-
{"FRINGE", e_sb_location::E_FRINGE},
72-
{"XY_SPECIFIED", e_sb_location::E_XY_SPECIFIED}};
67+
inline const std::unordered_map<std::string, e_sb_location> SB_LOCATION_STRING_MAP = {{"EVERYWHERE", e_sb_location::E_EVERYWHERE},
68+
{"PERIMETER", e_sb_location::E_PERIMETER},
69+
{"CORE", e_sb_location::E_CORE},
70+
{"CORNER", e_sb_location::E_CORNER},
71+
{"FRINGE", e_sb_location::E_FRINGE},
72+
{"XY_SPECIFIED", e_sb_location::E_XY_SPECIFIED}};
7373

7474
/**
7575
* @brief Describes regions that a specific switch block specifications should be applied to

0 commit comments

Comments
 (0)