Merge branch 'koriakin/xc7nocarrymux' into xaig
[yosys.git] / kernel / register.cc
index ebe3055ac4fb5af01afe20b3c5c0743acdda0dcc..26da96b95b6d9e62a217f3577050a25d510c4d38 100644 (file)
@@ -86,6 +86,9 @@ Pass::pre_post_exec_state_t Pass::pre_execute()
 
 void Pass::post_execute(Pass::pre_post_exec_state_t state)
 {
+       IdString::checkpoint();
+       log_suppressed();
+
        int64_t time_ns = PerformanceTimer::query() - state.begin_ns;
        runtime_ns += time_ns;
        current_pass = state.parent_pass;
@@ -165,7 +168,7 @@ void Pass::call(RTLIL::Design *design, std::string command)
                while (!cmd_buf.empty() && (cmd_buf.back() == ' ' || cmd_buf.back() == '\t' ||
                                cmd_buf.back() == '\r' || cmd_buf.back() == '\n'))
                        cmd_buf.resize(cmd_buf.size()-1);
-               log_header("Shell command: %s\n", cmd_buf.c_str());
+               log_header(design, "Shell command: %s\n", cmd_buf.c_str());
                int retCode = run_command(cmd_buf);
                if (retCode != 0)
                        log_cmd_error("Shell command returned error code %d.\n", retCode);
@@ -173,7 +176,7 @@ void Pass::call(RTLIL::Design *design, std::string command)
        }
 
        while (!tok.empty()) {
-               if (tok == "#") {
+               if (tok[0] == '#') {
                        int stop;
                        for (stop = 0; stop < GetSize(cmd_buf); stop++)
                                if (cmd_buf[stop] == '\r' || cmd_buf[stop] == '\n')
@@ -382,7 +385,8 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
        bool called_with_fp = f != NULL;
 
        next_args.clear();
-       for (; argidx < args.size(); argidx++)
+
+       if (argidx < args.size())
        {
                std::string arg = args[argidx];
 
@@ -419,8 +423,15 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
                        f = new std::istringstream(last_here_document);
                } else {
                        rewrite_filename(filename);
+                       vector<string> filenames = glob_filename(filename);
+                       filename = filenames.front();
+                       if (GetSize(filenames) > 1) {
+                               next_args.insert(next_args.end(), args.begin(), args.begin()+argidx);
+                               next_args.insert(next_args.end(), filenames.begin()+1, filenames.end());
+                       }
                        std::ifstream *ff = new std::ifstream;
                        ff->open(filename.c_str());
+                       yosys_input_files.insert(filename);
                        if (ff->fail())
                                delete ff;
                        else
@@ -434,12 +445,13 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector<s
                                cmd_error(args, i, "Found option, expected arguments.");
 
                if (argidx+1 < args.size()) {
-                       next_args.insert(next_args.begin(), args.begin(), args.begin()+argidx);
-                       next_args.insert(next_args.begin()+argidx, args.begin()+argidx+1, args.end());
+                       if (next_args.empty())
+                               next_args.insert(next_args.end(), args.begin(), args.begin()+argidx);
+                       next_args.insert(next_args.end(), args.begin()+argidx+1, args.end());
                        args.erase(args.begin()+argidx+1, args.end());
                }
-               break;
        }
+
        if (f == NULL)
                cmd_error(args, argidx, "No filename given.");
 
@@ -533,8 +545,10 @@ void Backend::extra_args(std::ostream *&f, std::string &filename, std::vector<st
                }
 
                filename = arg;
+               rewrite_filename(filename);
                std::ofstream *ff = new std::ofstream;
                ff->open(filename.c_str(), std::ofstream::trunc);
+               yosys_output_files.insert(filename);
                if (ff->fail()) {
                        delete ff;
                        log_cmd_error("Can't open output file `%s' for writing: %s\n", filename.c_str(), strerror(errno));
@@ -605,7 +619,7 @@ static struct CellHelpMessages {
 
 struct HelpPass : public Pass {
        HelpPass() : Pass("help", "display help messages") { }
-       virtual void help()
+       void help() YS_OVERRIDE
        {
                log("\n");
                log("    help  ................  list all commands\n");
@@ -674,7 +688,7 @@ struct HelpPass : public Pass {
 
                fclose(f);
        }
-       virtual void execute(std::vector<std::string> args, RTLIL::Design*)
+       void execute(std::vector<std::string> args, RTLIL::Design*) YS_OVERRIDE
        {
                if (args.size() == 1) {
                        log("\n");
@@ -758,7 +772,7 @@ struct HelpPass : public Pass {
 
 struct EchoPass : public Pass {
        EchoPass() : Pass("echo", "turning echoing back of commands on and off") { }
-       virtual void help()
+       void help() YS_OVERRIDE
        {
                log("\n");
                log("    echo on\n");
@@ -771,7 +785,7 @@ struct EchoPass : public Pass {
                log("Do not print all commands to log before executing them. (default)\n");
                log("\n");
        }
-       virtual void execute(std::vector<std::string> args, RTLIL::Design*)
+       void execute(std::vector<std::string> args, RTLIL::Design*) YS_OVERRIDE
        {
                if (args.size() > 2)
                        cmd_error(args, 2, "Unexpected argument.");
@@ -796,10 +810,9 @@ struct MinisatSatSolver : public SatSolver {
        MinisatSatSolver() : SatSolver("minisat") {
                yosys_satsolver = this;
        }
-       virtual ezSAT *create() YS_OVERRIDE {
+       ezSAT *create() YS_OVERRIDE {
                return new ezMiniSAT();
        }
 } MinisatSatSolver;
 
 YOSYS_NAMESPACE_END
-