Skip to content

Commit e4d4de1

Browse files
committed
driver: add --no-private-id-locs and NEWER_ID
1 parent 85bcdee commit e4d4de1

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

kernel/driver.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ int main(int argc, char **argv)
292292
cxxopts::value<std::vector<std::string>>(), "<feature>")
293293
("g,debug", "globally enable debug log messages")
294294
("perffile", "write a JSON performance log to <perffile>", cxxopts::value<std::string>(), "<perffile>")
295+
("no-private-id-locs", "turn off putting source file locations into object IDs")
295296
;
296297

297298
options.parse_positional({"infile"});
@@ -436,6 +437,7 @@ int main(int argc, char **argv)
436437
log_experimentals_ignored.insert(ignores.begin(), ignores.end());
437438
}
438439
if (result.count("perffile")) perffile = result["perffile"].as<std::string>();
440+
if (result.count("no-private-id-locs")) yosys_private_id_locs = false;
439441
if (result.count("infile")) {
440442
frontend_files = result["infile"].as<std::vector<std::string>>();
441443
}

kernel/yosys.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ YOSYS_NAMESPACE_BEGIN
8282
int autoidx = 1;
8383
int yosys_xtrace = 0;
8484
bool yosys_write_versions = true;
85+
bool yosys_private_id_locs = true;
8586
const char* yosys_maybe_version() {
8687
if (yosys_write_versions)
8788
return yosys_version_str;
@@ -272,6 +273,16 @@ void yosys_shutdown()
272273
}
273274

274275
RTLIL::IdString new_id(std::string file, int line, std::string func)
276+
{
277+
return newer_id(file, line, func);
278+
}
279+
280+
RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std::string suffix)
281+
{
282+
return newer_id_suffix(file, line, func, suffix);
283+
}
284+
285+
RTLIL::IdString newer_id(std::string file, int line, std::string func)
275286
{
276287
#ifdef _WIN32
277288
size_t pos = file.find_last_of("/\\");
@@ -288,7 +299,7 @@ RTLIL::IdString new_id(std::string file, int line, std::string func)
288299
return stringf("$auto$%s:%d:%s$%d", file, line, func, autoidx++);
289300
}
290301

291-
RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std::string suffix)
302+
RTLIL::IdString newer_id_suffix(std::string file, int line, std::string func, std::string suffix)
292303
{
293304
#ifdef _WIN32
294305
size_t pos = file.find_last_of("/\\");

kernel/yosys_common.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,30 @@ inline int GetSize(RTLIL::Wire *wire);
268268
extern int autoidx;
269269
extern int yosys_xtrace;
270270
extern bool yosys_write_versions;
271+
extern bool yosys_private_id_locs;
271272

273+
RTLIL::IdString newer_id(std::string file, int line, std::string func);
274+
RTLIL::IdString newer_id_suffix(std::string file, int line, std::string func, std::string suffix);
275+
[[deprecated("Use NEWER_ID instead of NEW_ID")]]
272276
RTLIL::IdString new_id(std::string file, int line, std::string func);
277+
[[deprecated("Use NEWER_ID_SUFFIX instead of NEW_ID_SUFFIX")]]
273278
RTLIL::IdString new_id_suffix(std::string file, int line, std::string func, std::string suffix);
274279

275280
#define NEW_ID \
276281
YOSYS_NAMESPACE_PREFIX new_id(__FILE__, __LINE__, __FUNCTION__)
277282
#define NEW_ID_SUFFIX(suffix) \
278283
YOSYS_NAMESPACE_PREFIX new_id_suffix(__FILE__, __LINE__, __FUNCTION__, suffix)
279284

285+
#define NEWER_ID \
286+
(YOSYS_NAMESPACE_PREFIX yosys_private_id_locs ? \
287+
YOSYS_NAMESPACE_PREFIX newer_id(__FILE__, __LINE__, __FUNCTION__) : \
288+
YOSYS_NAMESPACE_PREFIX newer_id("?", 0, "?"))
289+
290+
#define NEWER_ID_SUFFIX(suffix) \
291+
(YOSYS_NAMESPACE_PREFIX yosys_private_id_locs ? \
292+
YOSYS_NAMESPACE_PREFIX newer_id_suffix(__FILE__, __LINE__, __FUNCTION__, suffix) : \
293+
YOSYS_NAMESPACE_PREFIX newer_id_suffix("?", 0, "?", suffix))
294+
280295
namespace ID = RTLIL::ID;
281296

282297

0 commit comments

Comments
 (0)