Fixes and cleanups in AST_TECALL handling
authorClifford Wolf <clifford@clifford.at>
Fri, 7 Jun 2019 10:41:09 +0000 (12:41 +0200)
committerClifford Wolf <clifford@clifford.at>
Fri, 7 Jun 2019 10:41:09 +0000 (12:41 +0200)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
frontends/ast/ast.h
frontends/ast/genrtlil.cc
frontends/ast/simplify.cc
kernel/log.cc

index 93997ab86ff5d682cc59880287f103f938182bd4..b8cde060e7d1db2659527333b12ef1e64f6aedf7 100644 (file)
@@ -234,7 +234,6 @@ namespace AST
                bool mem2reg_check(pool<AstNode*> &mem2reg_set);
                void mem2reg_remove(pool<AstNode*> &mem2reg_set, vector<AstNode*> &delnodes);
                void meminfo(int &mem_width, int &mem_size, int &addr_bits);
-               bool check_elab_tasks(void);
 
                // additional functionality for evaluating constant functions
                struct varinfo_t { RTLIL::Const val; int offset; bool is_signed; };
index 60a087282f3deeccb3520744b5f5613423fc49e4..32ed401eb02fe61221ecfbe00633f83a9d41b296 100644 (file)
@@ -858,7 +858,6 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
        case AST_GENVAR:
        case AST_GENFOR:
        case AST_GENBLOCK:
-       case AST_TECALL:
        case AST_GENIF:
        case AST_GENCASE:
        case AST_PACKAGE:
@@ -1576,6 +1575,37 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
                        delete always;
                } break;
 
+       case AST_TECALL: {
+                       int sz = children.size();
+                       if (str == "$info") {
+                               if (sz > 0)
+                                       log_file_info(filename, linenum, "%s.\n", children[0]->str.c_str());
+                               else
+                                       log_file_info(filename, linenum, "\n");
+                       } else if (str == "$warning") {
+                               if (sz > 0)
+                                       log_file_warning(filename, linenum, "%s.\n", children[0]->str.c_str());
+                               else
+                                       log_file_warning(filename, linenum, "\n");
+                       } else if (str == "$error") {
+                               if (sz > 0)
+                                       log_file_error(filename, linenum, "%s.\n", children[0]->str.c_str());
+                               else
+                                       log_file_error(filename, linenum, "\n");
+                       } else if (str == "$fatal") {
+                               // TODO: 1st parameter, if exists, is 0,1 or 2, and passed to $finish()
+                               // if no parameter is given, default value is 1
+                               // dollar_finish(sz ? children[0] : 1);
+                               // perhaps create & use log_file_fatal()
+                               if (sz > 0)
+                                       log_file_error(filename, linenum, "FATAL: %s.\n", children[0]->str.c_str());
+                               else
+                                       log_file_error(filename, linenum, "FATAL.\n");
+                       } else {
+                               log_file_error(filename, linenum, "Unknown elabortoon system task '%s'.\n", str.c_str());
+                       }
+               } break;
+
        case AST_FCALL: {
                        if (str == "\\$anyconst" || str == "\\$anyseq" || str == "\\$allconst" || str == "\\$allseq")
                        {
index 66fd243d3211acd1173575780dccaa0b1be7c846..e947125bfd4712f61916b2261604dadd842193ec 100644 (file)
@@ -1146,8 +1146,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
 
                        if (type == AST_GENFOR) {
                                for (size_t i = 0; i < buf->children.size(); i++) {
-                                       if (!buf->children[i]->check_elab_tasks())
-                                               buf->children[i]->simplify(false, false, false, stage, -1, false, false);
+                                       buf->children[i]->simplify(false, false, false, stage, -1, false, false);
                                        current_ast_mod->children.push_back(buf->children[i]);
                                }
                        } else {
@@ -1260,8 +1259,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
                        }
 
                        for (size_t i = 0; i < buf->children.size(); i++) {
-                               if (!buf->children[i]->check_elab_tasks())
-                                       buf->children[i]->simplify(false, false, false, stage, -1, false, false);
+                               buf->children[i]->simplify(false, false, false, stage, -1, false, false);
                                current_ast_mod->children.push_back(buf->children[i]);
                        }
 
@@ -1340,8 +1338,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
                        }
 
                        for (size_t i = 0; i < buf->children.size(); i++) {
-                               if (!buf->children[i]->check_elab_tasks())
-                                       buf->children[i]->simplify(false, false, false, stage, -1, false, false);
+                               buf->children[i]->simplify(false, false, false, stage, -1, false, false);
                                current_ast_mod->children.push_back(buf->children[i]);
                        }
 
@@ -2971,44 +2968,6 @@ static void mark_memories_assign_lhs_complex(dict<AstNode*, pool<std::string>> &
        }
 }
 
-// handle $info(), $warning(), $error(), $fatal()
-// we don't do that in simplify() because we don't know 
-bool AstNode::check_elab_tasks(void)
-{
-       if (type == AST_TECALL) {
-               int sz = children.size();
-               if (str == "$info") {
-                       if (sz > 0)
-                               log_file_info(filename, linenum, "%s.\n", children[0]->str.c_str());
-                       else
-                               log_file_info(filename, linenum, "\n");
-               } else if (str == "$warning") {
-                       if (sz > 0)
-                               log_file_warning(filename, linenum, "%s.\n", children[0]->str.c_str());
-                       else
-                               log_file_warning(filename, linenum, "\n");
-               } else if (str == "$error") {
-                       if (sz > 0)
-                               log_file_error(filename, linenum, "%s.\n", children[0]->str.c_str());
-                       else
-                               log_file_error(filename, linenum, "\n");
-               } else if (str == "$fatal") {
-                       // TODO: 1st parameter, if exists, is 0,1 or 2, and passed to $finish()
-                       // if no parameter is given, default value is 1
-                       // dollar_finish(sz ? children[0] : 1);
-                       // perhaps create & use log_file_fatal()
-                       if (sz > 0)
-                               log_file_error(filename, linenum, "FATAL: %s.\n", children[0]->str.c_str());
-                       else
-                               log_file_error(filename, linenum, "FATAL.\n");
-               } else {
-                       log_file_error(filename, linenum, "Unknown elabortoon system task '%s'.\n", str.c_str());
-               }
-               return true;
-       }
-       return false;
-
-}
 // find memories that should be replaced by registers
 void AstNode::mem2reg_as_needed_pass1(dict<AstNode*, pool<std::string>> &mem2reg_places,
                dict<AstNode*, uint32_t> &mem2reg_candidates, dict<AstNode*, uint32_t> &proc_flags, uint32_t &flags)
index 9ce952caea8885776cdb3fead5bb5574cfd410f6..a7820950c9dcdc3f4ea45b240931af5c3d7b02b6 100644 (file)
@@ -277,7 +277,7 @@ void log_file_warning(const std::string &filename, int lineno,
        va_list ap;
        va_start(ap, format);
        std::string prefix = stringf("%s:%d: Warning: ",
-                                    filename.c_str(), lineno);
+                       filename.c_str(), lineno);
        logv_warning_with_prefix(prefix.c_str(), format, ap);
        va_end(ap);
 }
@@ -287,9 +287,9 @@ void log_file_info(const std::string &filename, int lineno,
 {
        va_list ap;
        va_start(ap, format);
-       std::string prefix = stringf("%s:%d: Info: ",
-                                    filename.c_str(), lineno);
-       logv_warning_with_prefix(prefix.c_str(), format, ap);
+       std::string fmt = stringf("%s:%d: Info: %s",
+                       filename.c_str(), lineno, format);
+       logv(fmt.c_str(), ap);
        va_end(ap);
 }