3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-06 17:44:09 +00:00

Introducing YS_OVERRIDE, YS_FINAL, YS_ATTRIBUTE, YS_NORETURN

This commit is contained in:
Clifford Wolf 2014-11-09 10:55:04 +01:00
parent fe829bdbdc
commit a112b10934
5 changed files with 30 additions and 26 deletions

View file

@ -52,13 +52,13 @@ extern int log_verbose_level;
void logv(const char *format, va_list ap); void logv(const char *format, va_list ap);
void logv_header(const char *format, va_list ap); void logv_header(const char *format, va_list ap);
void logv_warning(const char *format, va_list ap); void logv_warning(const char *format, va_list ap);
_NORETURN_ void logv_error(const char *format, va_list ap) __attribute__((noreturn)); YS_NORETURN void logv_error(const char *format, va_list ap) YS_ATTRIBUTE(noreturn);
void log(const char *format, ...) __attribute__((format(printf, 1, 2))); void log(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
void log_header(const char *format, ...) __attribute__((format(printf, 1, 2))); void log_header(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
void log_warning(const char *format, ...) __attribute__((format(printf, 1, 2))); void log_warning(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2));
_NORETURN_ void log_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn)); YS_NORETURN void log_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2), noreturn);
_NORETURN_ void log_cmd_error(const char *format, ...) __attribute__((format(printf, 1, 2))) __attribute__((noreturn)); YS_NORETURN void log_cmd_error(const char *format, ...) YS_ATTRIBUTE(format(printf, 1, 2), noreturn);
void log_spacer(); void log_spacer();
void log_push(); void log_push();
@ -92,14 +92,14 @@ static inline void log_assert_worker(bool cond, const char *expr, const char *fi
#ifdef YOSYS_ENABLE_COVER #ifdef YOSYS_ENABLE_COVER
#define cover(_id) do { \ #define cover(_id) do { \
static CoverData __d __attribute__((section("yosys_cover_list"), aligned(1), used)) = { __FILE__, __FUNCTION__, _id, __LINE__, 0 }; \ static CoverData __d YS_ATTRIBUTE(section("yosys_cover_list"), aligned(1), used) = { __FILE__, __FUNCTION__, _id, __LINE__, 0 }; \
__d.counter++; \ __d.counter++; \
} while (0) } while (0)
struct CoverData { struct CoverData {
const char *file, *func, *id; const char *file, *func, *id;
int line, counter; int line, counter;
} __attribute__ ((packed)); } YS_ATTRIBUTE(packed);
// this two symbols are created by the linker for the "yosys_cover_list" ELF section // this two symbols are created by the linker for the "yosys_cover_list" ELF section
extern "C" struct CoverData __start_yosys_cover_list[]; extern "C" struct CoverData __start_yosys_cover_list[];

View file

@ -102,7 +102,7 @@ struct ModIndex : public RTLIL::Monitor
auto_reload_module = false; auto_reload_module = false;
} }
virtual void notify_connect(RTLIL::Cell *cell, const RTLIL::IdString &port, const RTLIL::SigSpec &old_sig, RTLIL::SigSpec &sig) OVERRIDE virtual void notify_connect(RTLIL::Cell *cell, const RTLIL::IdString &port, const RTLIL::SigSpec &old_sig, RTLIL::SigSpec &sig) YS_OVERRIDE
{ {
if (auto_reload_module) if (auto_reload_module)
reload_module(); reload_module();

View file

@ -73,7 +73,7 @@ struct Frontend : Pass
Frontend(std::string name, std::string short_help = "** document me **"); Frontend(std::string name, std::string short_help = "** document me **");
virtual void run_register(); virtual void run_register();
virtual ~Frontend(); virtual ~Frontend();
virtual void execute(std::vector<std::string> args, RTLIL::Design *design) OVERRIDE FINAL; virtual void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL;
virtual void execute(std::istream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) = 0; virtual void execute(std::istream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) = 0;
static std::vector<std::string> next_args; static std::vector<std::string> next_args;
@ -89,7 +89,7 @@ struct Backend : Pass
Backend(std::string name, std::string short_help = "** document me **"); Backend(std::string name, std::string short_help = "** document me **");
virtual void run_register(); virtual void run_register();
virtual ~Backend(); virtual ~Backend();
virtual void execute(std::vector<std::string> args, RTLIL::Design *design) OVERRIDE FINAL; virtual void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE YS_FINAL;
virtual void execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) = 0; virtual void execute(std::ostream *&f, std::string filename, std::vector<std::string> args, RTLIL::Design *design) = 0;
void extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx); void extra_args(std::ostream *&f, std::string &filename, std::vector<std::string> args, size_t argidx);

View file

@ -102,18 +102,22 @@
#define USING_YOSYS_NAMESPACE using namespace Yosys; #define USING_YOSYS_NAMESPACE using namespace Yosys;
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
# define OVERRIDE override # define YS_OVERRIDE override
# define FINAL final # define YS_FINAL final
#else #else
# define OVERRIDE # define YS_OVERRIDE
# define FINAL # define YS_FINAL
#endif #endif
#if !defined(__GNUC__) && !defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
# define __attribute__(...) # define YS_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
# define _NORETURN_ __declspec(noreturn) # define YS_NORETURN
#elif defined(_MSC_VER)
# define YS_ATTRIBUTE(...)
# define YS_NORETURN __declspec(noreturn)
#else #else
# define _NORETURN_ # define YS_ATTRIBUTE(...)
# define YS_NORETURN
#endif #endif
YOSYS_NAMESPACE_BEGIN YOSYS_NAMESPACE_BEGIN
@ -125,7 +129,7 @@ namespace RTLIL {
struct Cell; struct Cell;
} }
std::string stringf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); std::string stringf(const char *fmt, ...) YS_ATTRIBUTE(format(printf, 1, 2));
std::string vstringf(const char *fmt, va_list ap); std::string vstringf(const char *fmt, va_list ap);
int readsome(std::istream &f, char *s, int n); int readsome(std::istream &f, char *s, int n);
std::string next_token(std::string &text, const char *sep); std::string next_token(std::string &text, const char *sep);

View file

@ -25,34 +25,34 @@ PRIVATE_NAMESPACE_BEGIN
struct TraceMonitor : public RTLIL::Monitor struct TraceMonitor : public RTLIL::Monitor
{ {
virtual void notify_module_add(RTLIL::Module *module) OVERRIDE virtual void notify_module_add(RTLIL::Module *module) YS_OVERRIDE
{ {
log("#TRACE# Module add: %s\n", log_id(module)); log("#TRACE# Module add: %s\n", log_id(module));
} }
virtual void notify_module_del(RTLIL::Module *module) OVERRIDE virtual void notify_module_del(RTLIL::Module *module) YS_OVERRIDE
{ {
log("#TRACE# Module delete: %s\n", log_id(module)); log("#TRACE# Module delete: %s\n", log_id(module));
} }
virtual void notify_connect(RTLIL::Cell *cell, const RTLIL::IdString &port, const RTLIL::SigSpec &old_sig, RTLIL::SigSpec &sig) OVERRIDE virtual void notify_connect(RTLIL::Cell *cell, const RTLIL::IdString &port, const RTLIL::SigSpec &old_sig, RTLIL::SigSpec &sig) YS_OVERRIDE
{ {
log("#TRACE# Cell connect: %s.%s.%s = %s (was: %s)\n", log_id(cell->module), log_id(cell), log_id(port), log_signal(sig), log_signal(old_sig)); log("#TRACE# Cell connect: %s.%s.%s = %s (was: %s)\n", log_id(cell->module), log_id(cell), log_id(port), log_signal(sig), log_signal(old_sig));
} }
virtual void notify_connect(RTLIL::Module *module, const RTLIL::SigSig &sigsig) OVERRIDE virtual void notify_connect(RTLIL::Module *module, const RTLIL::SigSig &sigsig) YS_OVERRIDE
{ {
log("#TRACE# Connection in module %s: %s = %s\n", log_id(module), log_signal(sigsig.first), log_signal(sigsig.second)); log("#TRACE# Connection in module %s: %s = %s\n", log_id(module), log_signal(sigsig.first), log_signal(sigsig.second));
} }
virtual void notify_connect(RTLIL::Module *module, const std::vector<RTLIL::SigSig> &sigsig_vec) OVERRIDE virtual void notify_connect(RTLIL::Module *module, const std::vector<RTLIL::SigSig> &sigsig_vec) YS_OVERRIDE
{ {
log("#TRACE# New connections in module %s:\n", log_id(module)); log("#TRACE# New connections in module %s:\n", log_id(module));
for (auto &sigsig : sigsig_vec) for (auto &sigsig : sigsig_vec)
log("## %s = %s\n", log_signal(sigsig.first), log_signal(sigsig.second)); log("## %s = %s\n", log_signal(sigsig.first), log_signal(sigsig.second));
} }
virtual void notify_blackout(RTLIL::Module *module) OVERRIDE virtual void notify_blackout(RTLIL::Module *module) YS_OVERRIDE
{ {
log("#TRACE# Blackout in module %s:\n", log_id(module)); log("#TRACE# Blackout in module %s:\n", log_id(module));
} }