Add log_experimental() and experimental() API and "yosys -x"
authorClaire Wolf <clifford@clifford.at>
Mon, 27 Jan 2020 17:27:47 +0000 (18:27 +0100)
committerClaire Wolf <clifford@clifford.at>
Mon, 27 Jan 2020 17:27:47 +0000 (18:27 +0100)
Signed-off-by: Claire Wolf <clifford@clifford.at>
kernel/driver.cc
kernel/log.cc
kernel/log.h
kernel/register.cc
kernel/register.h
techlibs/intel/synth_intel.cc

index 7fc81f589241bc4f0052e60ce50428d62c528c31..acbf6b55d5d344d0142db93ed18347de6ce81a80 100644 (file)
@@ -295,6 +295,9 @@ int main(int argc, char **argv)
                printf("    -E <depsfile>\n");
                printf("        write a Makefile dependencies file with in- and output file names\n");
                printf("\n");
+               printf("    -x <feature>\n");
+               printf("        do not print warnings for the specified experimental feature\n");
+               printf("\n");
                printf("    -g\n");
                printf("        globally enable debug log messages\n");
                printf("\n");
@@ -324,7 +327,7 @@ int main(int argc, char **argv)
        }
 
        int opt;
-       while ((opt = getopt(argc, argv, "MXAQTVSgm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:e:D:P:E:")) != -1)
+       while ((opt = getopt(argc, argv, "MXAQTVSgm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:e:D:P:E:x:")) != -1)
        {
                switch (opt)
                {
@@ -455,6 +458,9 @@ int main(int argc, char **argv)
                case 'E':
                        depsfile = optarg;
                        break;
+               case 'x':
+                       log_experimentals.insert(optarg);
+                       break;
                default:
                        fprintf(stderr, "Run '%s -h' for help.\n", argv[0]);
                        exit(1);
index c5ba0d10d8dee003c50cb0ae949c045be8581bf3..0ecf59c3300a8c13e389ce9f55c52a2918cfc789 100644 (file)
@@ -42,7 +42,7 @@ std::vector<FILE*> log_files;
 std::vector<std::ostream*> log_streams;
 std::map<std::string, std::set<std::string>> log_hdump;
 std::vector<std::regex> log_warn_regexes, log_nowarn_regexes, log_werror_regexes;
-std::set<std::string> log_warnings;
+std::set<std::string> log_warnings, log_experimentals;
 int log_warnings_count = 0;
 bool log_hdump_all = false;
 FILE *log_errfile = NULL;
@@ -377,6 +377,19 @@ void log_warning(const char *format, ...)
        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.count(s) == 0) {
+               log_warning("Feature '%s' is experimental.\n", s.c_str());
+               log_experimentals.insert(s);
+       }
+}
+
 void log_warning_noprefix(const char *format, ...)
 {
        va_list ap;
index 1f15f3459bc67f336ce3053eb8cd2f97de14af4e..be70f4d9da98f143c0670c499a4abf74f3b1e265 100644 (file)
@@ -50,7 +50,7 @@ extern std::vector<FILE*> log_files;
 extern std::vector<std::ostream*> log_streams;
 extern std::map<std::string, std::set<std::string>> log_hdump;
 extern std::vector<std::regex> log_warn_regexes, log_nowarn_regexes, log_werror_regexes;
-extern std::set<std::string> log_warnings;
+extern std::set<std::string> log_warnings, log_experimentals;
 extern int log_warnings_count;
 extern bool log_hdump_all;
 extern FILE *log_errfile;
@@ -77,6 +77,7 @@ YS_NORETURN void logv_error(const char *format, va_list ap) YS_ATTRIBUTE(noretur
 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));
 
 // 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));
index 5d0fb3c8c22ae7508c5031b04bc0d30685a58fe6..e59d59654b101c691039f8b8cb3c704eff856c09 100644 (file)
@@ -304,6 +304,9 @@ void Pass::call(RTLIL::Design *design, std::vector<std::string> args)
        if (pass_register.count(args[0]) == 0)
                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());
+
        size_t orig_sel_stack_pos = design->selection_stack.size();
        auto state = pass_register[args[0]]->pre_execute();
        pass_register[args[0]]->execute(args, design);
@@ -824,6 +827,11 @@ struct HelpPass : public Pass {
                                                log("=");
                                        log("\n");
                                        it.second->help();
+                                       if (it.second->experimental_flag) {
+                                               log("\n");
+                                               log("WARNING: THE '%s' COMMAND IS EXPERIMENTAL.\n", it.first.c_str());
+                                               log("\n");
+                                       }
                                }
                        }
                        else if (args[1] == "-cells") {
@@ -846,6 +854,11 @@ struct HelpPass : public Pass {
                                        std::ostringstream buf;
                                        log_streams.push_back(&buf);
                                        it.second->help();
+                                       if (it.second->experimental_flag) {
+                                               log("\n");
+                                               log("WARNING: THE '%s' COMMAND IS EXPERIMENTAL.\n", it.first.c_str());
+                                               log("\n");
+                                       }
                                        log_streams.pop_back();
                                        write_tex(f, it.first, it.second->short_help, buf.str());
                                }
@@ -858,6 +871,11 @@ struct HelpPass : public Pass {
                                        std::ostringstream buf;
                                        log_streams.push_back(&buf);
                                        it.second->help();
+                                       if (it.second->experimental_flag) {
+                                               log("\n");
+                                               log("WARNING: THE '%s' COMMAND IS EXPERIMENTAL.\n", it.first.c_str());
+                                               log("\n");
+                                       }
                                        log_streams.pop_back();
                                        write_html(f, it.first, it.second->short_help, buf.str());
                                }
@@ -865,6 +883,11 @@ struct HelpPass : public Pass {
                        }
                        else if (pass_register.count(args[1])) {
                                pass_register.at(args[1])->help();
+                               if (pass_register.at(args[1])->experimental_flag) {
+                                       log("\n");
+                                       log("WARNING: THE '%s' COMMAND IS EXPERIMENTAL.\n", args[1].c_str());
+                                       log("\n");
+                               }
                        }
                        else if (cell_help_messages.cell_help.count(args[1])) {
                                log("%s", cell_help_messages.cell_help.at(args[1]).c_str());
index 821faff3eed4366748abd75a4cf9b0ed86fae39d..4622845b6d24d0cf8019efd2b1a85bbb9e204fbd 100644 (file)
@@ -36,6 +36,11 @@ struct Pass
 
        int call_counter;
        int64_t runtime_ns;
+       bool experimental_flag = false;
+
+       void experimental() {
+               experimental_flag = true;
+       }
 
        struct pre_post_exec_state_t {
                Pass *parent_pass;
index 2ebb8bf50401d1a593d1b6660d16dd4b59b65bb8..3689df70e921c8bcf90def168cbba648e0910b06 100644 (file)
@@ -26,7 +26,7 @@ USING_YOSYS_NAMESPACE
 PRIVATE_NAMESPACE_BEGIN
 
 struct SynthIntelPass : public ScriptPass {
-       SynthIntelPass() : ScriptPass("synth_intel", "synthesis for Intel (Altera) FPGAs.") {}
+       SynthIntelPass() : ScriptPass("synth_intel", "synthesis for Intel (Altera) FPGAs.") { experimental(); }
 
        void help() YS_OVERRIDE
        {