mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-18 05:05:45 +00:00
Merge upstream changes
This commit is contained in:
commit
a43de44f9d
18 changed files with 343 additions and 180 deletions
|
|
@ -516,12 +516,11 @@ class dict {
|
|||
return do_lookup_internal(key, hash);
|
||||
}
|
||||
|
||||
int do_insert(const K &key, Hasher::hash_t &hash)
|
||||
int do_insert(const K &key, const Hasher::hash_t &hash)
|
||||
{
|
||||
if (hashtable.empty()) {
|
||||
entries.emplace_back(std::pair<K, T>(key, T()), -1);
|
||||
do_rehash();
|
||||
hash = do_hash(key);
|
||||
} else {
|
||||
entries.emplace_back(std::pair<K, T>(key, T()), hashtable[hash]);
|
||||
hashtable[hash] = entries.size() - 1;
|
||||
|
|
@ -529,12 +528,11 @@ class dict {
|
|||
return entries.size() - 1;
|
||||
}
|
||||
|
||||
int do_insert(const std::pair<K, T> &value, Hasher::hash_t &hash)
|
||||
int do_insert(const std::pair<K, T> &value, const Hasher::hash_t &hash)
|
||||
{
|
||||
if (hashtable.empty()) {
|
||||
entries.emplace_back(value, -1);
|
||||
do_rehash();
|
||||
hash = do_hash(value.first);
|
||||
} else {
|
||||
entries.emplace_back(value, hashtable[hash]);
|
||||
hashtable[hash] = entries.size() - 1;
|
||||
|
|
@ -542,13 +540,11 @@ class dict {
|
|||
return entries.size() - 1;
|
||||
}
|
||||
|
||||
int do_insert(std::pair<K, T> &&rvalue, Hasher::hash_t &hash)
|
||||
int do_insert(std::pair<K, T> &&rvalue, const Hasher::hash_t &hash)
|
||||
{
|
||||
if (hashtable.empty()) {
|
||||
auto key = rvalue.first;
|
||||
entries.emplace_back(std::forward<std::pair<K, T>>(rvalue), -1);
|
||||
do_rehash();
|
||||
hash = do_hash(key);
|
||||
} else {
|
||||
entries.emplace_back(std::forward<std::pair<K, T>>(rvalue), hashtable[hash]);
|
||||
hashtable[hash] = entries.size() - 1;
|
||||
|
|
|
|||
|
|
@ -437,6 +437,7 @@ public:
|
|||
{
|
||||
return format_emit_toplevel(fmt, has_escapes, specs, args...);
|
||||
}
|
||||
std::string_view format_string() const { return fmt; }
|
||||
private:
|
||||
std::string_view fmt;
|
||||
bool has_escapes = false;
|
||||
|
|
|
|||
165
kernel/log.cc
165
kernel/log.cc
|
|
@ -102,17 +102,16 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
|
|||
}
|
||||
#endif
|
||||
|
||||
void logv(const char *format, va_list ap)
|
||||
{
|
||||
while (format[0] == '\n' && format[1] != 0) {
|
||||
log("\n");
|
||||
format++;
|
||||
static void logv_string(std::string_view format, std::string str) {
|
||||
size_t remove_leading = 0;
|
||||
while (format.size() > 1 && format[0] == '\n') {
|
||||
logv_string("\n", "\n");
|
||||
format = format.substr(1);
|
||||
++remove_leading;
|
||||
}
|
||||
if (remove_leading > 0) {
|
||||
str = str.substr(remove_leading);
|
||||
}
|
||||
|
||||
if (log_make_debug && !ys_debug(1))
|
||||
return;
|
||||
|
||||
std::string str = vstringf(format, ap);
|
||||
|
||||
if (str.empty())
|
||||
return;
|
||||
|
|
@ -145,13 +144,13 @@ void logv(const char *format, va_list ap)
|
|||
time_str += stringf("[%05d.%06d] ", int(tv.tv_sec), int(tv.tv_usec));
|
||||
}
|
||||
|
||||
if (format[0] && format[strlen(format)-1] == '\n')
|
||||
if (!format.empty() && format[format.size() - 1] == '\n')
|
||||
next_print_log = true;
|
||||
|
||||
// Special case to detect newlines in Python log output, since
|
||||
// the binding always calls `log("%s", payload)` and the newline
|
||||
// is then in the first formatted argument
|
||||
if (!strcmp(format, "%s") && str.back() == '\n')
|
||||
if (format == "%s" && str.back() == '\n')
|
||||
next_print_log = true;
|
||||
|
||||
for (auto f : log_files)
|
||||
|
|
@ -204,7 +203,14 @@ void logv(const char *format, va_list ap)
|
|||
}
|
||||
}
|
||||
|
||||
void logv_header(RTLIL::Design *design, const char *format, va_list ap)
|
||||
void log_formatted_string(std::string_view format, std::string str)
|
||||
{
|
||||
if (log_make_debug && !ys_debug(1))
|
||||
return;
|
||||
logv_string(format, std::move(str));
|
||||
}
|
||||
|
||||
void log_formatted_header(RTLIL::Design *design, std::string_view format, std::string str)
|
||||
{
|
||||
bool pop_errfile = false;
|
||||
|
||||
|
|
@ -223,7 +229,7 @@ void logv_header(RTLIL::Design *design, const char *format, va_list ap)
|
|||
header_id += stringf("%s%d", header_id.empty() ? "" : ".", c);
|
||||
|
||||
log("%s. ", header_id.c_str());
|
||||
logv(format, ap);
|
||||
log_formatted_string(format, std::move(str));
|
||||
log_flush();
|
||||
|
||||
if (log_hdump_all)
|
||||
|
|
@ -243,10 +249,8 @@ void logv_header(RTLIL::Design *design, const char *format, va_list ap)
|
|||
log_files.pop_back();
|
||||
}
|
||||
|
||||
static void logv_warning_with_prefix(const char *prefix,
|
||||
const char *format, va_list ap)
|
||||
void log_formatted_warning(std::string_view prefix, std::string message)
|
||||
{
|
||||
std::string message = vstringf(format, ap);
|
||||
bool suppressed = false;
|
||||
|
||||
for (auto &re : log_nowarn_regexes)
|
||||
|
|
@ -255,7 +259,7 @@ static void logv_warning_with_prefix(const char *prefix,
|
|||
|
||||
if (suppressed)
|
||||
{
|
||||
log("Suppressed %s%s", prefix, message.c_str());
|
||||
log("Suppressed %s%s", prefix, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -264,7 +268,7 @@ static void logv_warning_with_prefix(const char *prefix,
|
|||
|
||||
for (auto &re : log_werror_regexes)
|
||||
if (std::regex_search(message, re))
|
||||
log_error("%s", message.c_str());
|
||||
log_error("%s", message);
|
||||
|
||||
bool warning_match = false;
|
||||
for (auto &[_, item] : log_expect_warning)
|
||||
|
|
@ -281,7 +285,7 @@ static void logv_warning_with_prefix(const char *prefix,
|
|||
|
||||
if (log_warnings.count(message))
|
||||
{
|
||||
log("%s%s", prefix, message.c_str());
|
||||
log("%s%s", prefix, message);
|
||||
log_flush();
|
||||
}
|
||||
else
|
||||
|
|
@ -289,7 +293,7 @@ static void logv_warning_with_prefix(const char *prefix,
|
|||
if (log_errfile != NULL && !log_quiet_warnings)
|
||||
log_files.push_back(log_errfile);
|
||||
|
||||
log("%s%s", prefix, message.c_str());
|
||||
log("%s%s", prefix, message);
|
||||
log_flush();
|
||||
|
||||
if (log_errfile != NULL && !log_quiet_warnings)
|
||||
|
|
@ -305,41 +309,19 @@ static void logv_warning_with_prefix(const char *prefix,
|
|||
}
|
||||
}
|
||||
|
||||
void logv_warning(const char *format, va_list ap)
|
||||
void log_formatted_file_warning(std::string_view filename, int lineno, std::string str)
|
||||
{
|
||||
logv_warning_with_prefix("Warning: ", format, ap);
|
||||
std::string prefix = stringf("%s:%d: Warning: ", filename, lineno);
|
||||
log_formatted_warning(prefix, std::move(str));
|
||||
}
|
||||
|
||||
void logv_warning_noprefix(const char *format, va_list ap)
|
||||
void log_formatted_file_info(std::string_view filename, int lineno, std::string str)
|
||||
{
|
||||
logv_warning_with_prefix("", format, ap);
|
||||
}
|
||||
|
||||
void log_file_warning(const std::string &filename, int lineno,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string prefix = stringf("%s:%d: Warning: ",
|
||||
filename.c_str(), lineno);
|
||||
logv_warning_with_prefix(prefix.c_str(), format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void log_file_info(const std::string &filename, int lineno,
|
||||
const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string fmt = stringf("%s:%d: Info: %s",
|
||||
filename.c_str(), lineno, format);
|
||||
logv(fmt.c_str(), ap);
|
||||
va_end(ap);
|
||||
log("%s:%d: Info: %s", filename, lineno, str);
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
static void logv_error_with_prefix(const char *prefix,
|
||||
const char *format, va_list ap)
|
||||
static void log_error_with_prefix(std::string_view prefix, std::string str)
|
||||
{
|
||||
#ifdef EMSCRIPTEN
|
||||
auto backup_log_files = log_files;
|
||||
|
|
@ -356,8 +338,8 @@ static void logv_error_with_prefix(const char *prefix,
|
|||
if (f == stdout)
|
||||
f = stderr;
|
||||
|
||||
log_last_error = vstringf(format, ap);
|
||||
log("%s%s", prefix, log_last_error.c_str());
|
||||
log_last_error = std::move(str);
|
||||
log("%s%s", prefix, log_last_error);
|
||||
log_flush();
|
||||
|
||||
log_make_debug = bak_log_make_debug;
|
||||
|
|
@ -390,86 +372,45 @@ static void logv_error_with_prefix(const char *prefix,
|
|||
#endif
|
||||
}
|
||||
|
||||
void logv_error(const char *format, va_list ap)
|
||||
void log_formatted_file_error(std::string_view filename, int lineno, std::string str)
|
||||
{
|
||||
logv_error_with_prefix("ERROR: ", format, ap);
|
||||
std::string prefix = stringf("%s:%d: ERROR: ", filename, lineno);
|
||||
log_error_with_prefix(prefix, str);
|
||||
}
|
||||
|
||||
void logv_file_error(const string &filename, int lineno,
|
||||
const char *format, va_list ap)
|
||||
{
|
||||
std::string prefix = stringf("%s:%d: ERROR: ",
|
||||
filename.c_str(), lineno);
|
||||
logv_error_with_prefix(prefix.c_str(), format, ap);
|
||||
log_formatted_file_error(filename, lineno, vstringf(format, ap));
|
||||
}
|
||||
|
||||
void log_file_error(const string &filename, int lineno,
|
||||
const char *format, ...)
|
||||
void log_experimental(const std::string &str)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
logv_file_error(filename, lineno, format, ap);
|
||||
}
|
||||
|
||||
void log(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
logv(format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void log_header(RTLIL::Design *design, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
logv_header(design, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void log_warning(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
logv_warning(format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void log_experimental(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
string s = vstringf(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (log_experimentals_ignored.count(s) == 0 && log_experimentals.count(s) == 0) {
|
||||
log_warning("Feature '%s' is experimental.\n", s.c_str());
|
||||
log_experimentals.insert(s);
|
||||
if (log_experimentals_ignored.count(str) == 0 && log_experimentals.count(str) == 0) {
|
||||
log_warning("Feature '%s' is experimental.\n", str);
|
||||
log_experimentals.insert(str);
|
||||
}
|
||||
}
|
||||
|
||||
void log_warning_noprefix(const char *format, ...)
|
||||
void log_formatted_error(std::string str)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
logv_warning_noprefix(format, ap);
|
||||
va_end(ap);
|
||||
log_error_with_prefix("ERROR: ", std::move(str));
|
||||
}
|
||||
|
||||
void log_error(const char *format, ...)
|
||||
void log_assert_failure(const char *expr, const char *file, int line)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
logv_error(format, ap);
|
||||
log_error("Assert `%s' failed in %s:%d.\n", expr, file, line);
|
||||
}
|
||||
|
||||
void log_cmd_error(const char *format, ...)
|
||||
void log_abort_internal(const char *file, int line)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
log_error("Abort in %s:%d.\n", file, line);
|
||||
}
|
||||
|
||||
void log_formatted_cmd_error(std::string str)
|
||||
{
|
||||
if (log_cmd_error_throw) {
|
||||
log_last_error = vstringf(format, ap);
|
||||
log_last_error = str;
|
||||
|
||||
// Make sure the error message gets through any selective silencing
|
||||
// of log output
|
||||
|
|
@ -479,7 +420,7 @@ void log_cmd_error(const char *format, ...)
|
|||
pop_errfile = true;
|
||||
}
|
||||
|
||||
log("ERROR: %s", log_last_error.c_str());
|
||||
log("ERROR: %s", log_last_error);
|
||||
log_flush();
|
||||
|
||||
if (pop_errfile)
|
||||
|
|
@ -488,7 +429,7 @@ void log_cmd_error(const char *format, ...)
|
|||
throw log_cmd_error_exception();
|
||||
}
|
||||
|
||||
logv_error(format, ap);
|
||||
log_formatted_error(str);
|
||||
}
|
||||
|
||||
void log_spacer()
|
||||
|
|
|
|||
120
kernel/log.h
120
kernel/log.h
|
|
@ -119,30 +119,11 @@ extern int log_make_debug;
|
|||
extern int log_force_debug;
|
||||
extern int log_debug_suppressed;
|
||||
|
||||
void logv(const char *format, va_list ap);
|
||||
void logv_header(RTLIL::Design *design, const char *format, va_list ap);
|
||||
void logv_warning(const char *format, va_list ap);
|
||||
void logv_warning_noprefix(const char *format, va_list ap);
|
||||
[[noreturn]] void logv_error(const char *format, va_list ap);
|
||||
[[noreturn]] void logv_file_error(const string &filename, int lineno, const char *format, va_list ap);
|
||||
|
||||
void log(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||
void log_header(RTLIL::Design *design, const char *format, ...) YS_ATTRIBUTE(format(printf, 2, 3));
|
||||
void log_warning(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||
void log_experimental(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||
|
||||
void set_verific_logging(void (*cb)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg));
|
||||
extern void (*log_verific_callback)(int msg_type, const char *message_id, const char* file_path, unsigned int left_line, unsigned int left_col, unsigned int right_line, unsigned int right_col, const char *msg);
|
||||
|
||||
// Log with filename to report a problem in a source file.
|
||||
void log_file_warning(const std::string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4));
|
||||
void log_file_info(const std::string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4));
|
||||
|
||||
void log_warning_noprefix(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||
[[noreturn]] void log_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||
[[noreturn]] void log_file_error(const string &filename, int lineno, const char *format, ...) YS_ATTRIBUTE(format(printf, 3, 4));
|
||||
[[noreturn]] void log_cmd_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
|
||||
|
||||
#ifndef NDEBUG
|
||||
static inline bool ys_debug(int n = 0) { if (log_force_debug) return true; log_debug_suppressed += n; return false; }
|
||||
#else
|
||||
|
|
@ -150,6 +131,74 @@ static inline bool ys_debug(int = 0) { return false; }
|
|||
#endif
|
||||
# define log_debug(...) do { if (ys_debug(1)) log(__VA_ARGS__); } while (0)
|
||||
|
||||
void log_formatted_string(std::string_view format, std::string str);
|
||||
template <typename... Args>
|
||||
inline void log(FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
if (log_make_debug && !ys_debug(1))
|
||||
return;
|
||||
log_formatted_string(fmt.format_string(), fmt.format(args...));
|
||||
}
|
||||
|
||||
void log_formatted_header(RTLIL::Design *design, std::string_view format, std::string str);
|
||||
template <typename... Args>
|
||||
inline void log_header(RTLIL::Design *design, FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
log_formatted_header(design, fmt.format_string(), fmt.format(args...));
|
||||
}
|
||||
|
||||
void log_formatted_warning(std::string_view prefix, std::string str);
|
||||
template <typename... Args>
|
||||
inline void log_warning(FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
log_formatted_warning("Warning: ", fmt.format(args...));
|
||||
}
|
||||
template <typename... Args>
|
||||
inline void log_warning_noprefix(FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
log_formatted_warning("", fmt.format(args...));
|
||||
}
|
||||
|
||||
void log_experimental(const std::string &str);
|
||||
|
||||
// Log with filename to report a problem in a source file.
|
||||
void log_formatted_file_warning(std::string_view filename, int lineno, std::string str);
|
||||
template <typename... Args>
|
||||
void log_file_warning(std::string_view filename, int lineno, FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
log_formatted_file_warning(filename, lineno, fmt.format(args...));
|
||||
}
|
||||
|
||||
void log_formatted_file_info(std::string_view filename, int lineno, std::string str);
|
||||
template <typename... Args>
|
||||
void log_file_info(std::string_view filename, int lineno, FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
if (log_make_debug && !ys_debug(1))
|
||||
return;
|
||||
log_formatted_file_info(filename, lineno, fmt.format(args...));
|
||||
}
|
||||
|
||||
[[noreturn]] void log_formatted_error(std::string str);
|
||||
template <typename... Args>
|
||||
[[noreturn]] void log_error(FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
log_formatted_error(fmt.format(args...));
|
||||
}
|
||||
|
||||
[[noreturn]] void log_formatted_file_error(std::string_view filename, int lineno, std::string str);
|
||||
template <typename... Args>
|
||||
[[noreturn]] void log_file_error(std::string_view filename, int lineno, FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
log_formatted_file_error(filename, lineno, fmt.format(args...));
|
||||
}
|
||||
|
||||
[[noreturn]] void log_formatted_cmd_error(std::string str);
|
||||
template <typename... Args>
|
||||
[[noreturn]] void log_cmd_error(FmtString<TypeIdentity<Args>...> fmt, const Args &... args)
|
||||
{
|
||||
log_formatted_cmd_error(fmt.format(args...));
|
||||
}
|
||||
|
||||
static inline void log_suppressed() {
|
||||
if (log_debug_suppressed && !log_make_debug) {
|
||||
log("<suppressed ~%d debug messages>\n", log_debug_suppressed);
|
||||
|
|
@ -220,11 +269,12 @@ void log_module(RTLIL::Module *module, std::string indent = "");
|
|||
void log_cell(RTLIL::Cell *cell, std::string indent = "");
|
||||
void log_wire(RTLIL::Wire *wire, std::string indent = "");
|
||||
|
||||
[[noreturn]]
|
||||
void log_assert_failure(const char *expr, const char *file, int line);
|
||||
static inline void log_assert_worker(bool cond, const char *expr, const char *file, int line) {
|
||||
if (!cond) {
|
||||
log("ERROR: Assert `%s' failed in %s:%d.\n", expr, file, line);
|
||||
log_assert_failure(expr, file, line);
|
||||
log_flush();
|
||||
printf("ERROR: Assert `%s' failed in %s:%d.\n", expr, file, line);
|
||||
raise(SIGABRT);
|
||||
}
|
||||
}
|
||||
|
|
@ -234,7 +284,9 @@ static inline void log_assert_worker(bool cond, const char *expr, const char *fi
|
|||
# define log_assert(_assert_expr_) do { if (0) { (void)(_assert_expr_); } } while(0)
|
||||
#endif
|
||||
|
||||
#define log_abort() YOSYS_NAMESPACE_PREFIX log_error("Abort in %s:%d.\n", __FILE__, __LINE__)
|
||||
[[noreturn]]
|
||||
void log_abort_internal(const char *file, int line);
|
||||
#define log_abort() YOSYS_NAMESPACE_PREFIX log_abort_internal(__FILE__, __LINE__)
|
||||
#define log_ping() YOSYS_NAMESPACE_PREFIX log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__)
|
||||
|
||||
|
||||
|
|
@ -356,8 +408,22 @@ static inline void log_dump_val_worker(unsigned long int v) { log("%lu", v); }
|
|||
static inline void log_dump_val_worker(long long int v) { log("%lld", v); }
|
||||
static inline void log_dump_val_worker(unsigned long long int v) { log("%lld", v); }
|
||||
#endif
|
||||
static inline void log_dump_val_worker(char c) { log(c >= 32 && c < 127 ? "'%c'" : "'\\x%02x'", c); }
|
||||
static inline void log_dump_val_worker(unsigned char c) { log(c >= 32 && c < 127 ? "'%c'" : "'\\x%02x'", c); }
|
||||
static inline void log_dump_val_worker(char c)
|
||||
{
|
||||
if (c >= 32 && c < 127) {
|
||||
log("'%c'", c);
|
||||
} else {
|
||||
log("'\\x%02x'", c);
|
||||
}
|
||||
}
|
||||
static inline void log_dump_val_worker(unsigned char c)
|
||||
{
|
||||
if (c >= 32 && c < 127) {
|
||||
log("'%c'", c);
|
||||
} else {
|
||||
log("'\\x%02x'", c);
|
||||
}
|
||||
}
|
||||
static inline void log_dump_val_worker(bool v) { log("%s", v ? "true" : "false"); }
|
||||
static inline void log_dump_val_worker(double v) { log("%f", v); }
|
||||
static inline void log_dump_val_worker(char *v) { log("%s", v); }
|
||||
|
|
@ -379,7 +445,7 @@ static inline void log_dump_val_worker(dict<K, T> &v) {
|
|||
log("{");
|
||||
bool first = true;
|
||||
for (auto &it : v) {
|
||||
log(first ? " " : ", ");
|
||||
log("%s ", first ? "" : ",");
|
||||
log_dump_val_worker(it.first);
|
||||
log(": ");
|
||||
log_dump_val_worker(it.second);
|
||||
|
|
@ -393,7 +459,7 @@ static inline void log_dump_val_worker(pool<K> &v) {
|
|||
log("{");
|
||||
bool first = true;
|
||||
for (auto &it : v) {
|
||||
log(first ? " " : ", ");
|
||||
log("%s ", first ? "" : ",");
|
||||
log_dump_val_worker(it);
|
||||
first = false;
|
||||
}
|
||||
|
|
@ -405,7 +471,7 @@ static inline void log_dump_val_worker(std::vector<K> &v) {
|
|||
log("{");
|
||||
bool first = true;
|
||||
for (auto &it : v) {
|
||||
log(first ? " " : ", ");
|
||||
log("%s ", first ? "" : ",");
|
||||
log_dump_val_worker(it);
|
||||
first = false;
|
||||
}
|
||||
|
|
|
|||
86
kernel/log_compat.cc
Normal file
86
kernel/log_compat.cc
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* yosys -- Yosys Open SYnthesis Suite
|
||||
*
|
||||
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "kernel/log.h"
|
||||
|
||||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
// ABI compatibility for the YosysHQ Verific Extensions
|
||||
|
||||
// The YosysHQ Verific Extensions are compiled separately using their own
|
||||
// stripped-down version of the Yosys headers. To maintain ABI compatibility
|
||||
// with older extension builds post C++-ification of Yosys's logging APIs,
|
||||
// which are backwards compatible on the API but not ABI level, this file
|
||||
// provides ABI compatible versions of a subset of the old logging API used by
|
||||
// the extensions.
|
||||
|
||||
void log_cmd_error(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string formatted = vstringf(format, ap);
|
||||
va_end(ap);
|
||||
log_formatted_cmd_error(formatted);
|
||||
}
|
||||
|
||||
void log_warning(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string formatted = vstringf(format, ap);
|
||||
va_end(ap);
|
||||
log_formatted_warning("Warning: ", formatted);
|
||||
}
|
||||
|
||||
void log_warning_noprefix(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string formatted = vstringf(format, ap);
|
||||
va_end(ap);
|
||||
log_formatted_warning("", formatted);
|
||||
}
|
||||
|
||||
void log_error(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string formatted = vstringf(format, ap);
|
||||
va_end(ap);
|
||||
log_formatted_error(formatted);
|
||||
}
|
||||
|
||||
static inline void log_formatted(std::string const &str)
|
||||
{
|
||||
// We use this inline wrapper as the following becomes ambiguous as soon as
|
||||
// the `log` function below is declared.
|
||||
return log("%s", str);
|
||||
}
|
||||
|
||||
void log(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string formatted = vstringf(format, ap);
|
||||
va_end(ap);
|
||||
log_formatted(formatted);
|
||||
}
|
||||
|
||||
YOSYS_NAMESPACE_END
|
||||
|
|
@ -265,7 +265,7 @@ void Pass::call(RTLIL::Design *design, std::vector<std::string> args)
|
|||
log_cmd_error("No such command: %s (type 'help' for a command overview)\n", args[0].c_str());
|
||||
|
||||
if (pass_register[args[0]]->experimental_flag)
|
||||
log_experimental("%s", args[0].c_str());
|
||||
log_experimental(args[0]);
|
||||
|
||||
size_t orig_sel_stack_pos = design->selection_stack.size();
|
||||
auto state = pass_register[args[0]]->pre_execute();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue