Merge pull request #1718 from boqwxp/precise_locations
authorClaire Wolf <clifford@clifford.at>
Tue, 3 Mar 2020 16:38:32 +0000 (08:38 -0800)
committerGitHub <noreply@github.com>
Tue, 3 Mar 2020 16:38:32 +0000 (08:38 -0800)
Closes #1717. Add more precise Verilog source location information to AST and RTLIL nodes.

1  2 
frontends/ast/ast.cc
frontends/ast/ast.h
frontends/ast/genrtlil.cc
frontends/ast/simplify.cc

Simple merge
Simple merge
Simple merge
index 9a8150ebf3457e05f2d1c30083e18659104dec9c,2c61f65f48f5a3952bd02f7ff1211ab5299b9cb3..04c02d893c9289ba796eb6da2c9e09942e0af544
@@@ -1322,25 -1320,19 +1320,25 @@@ bool AstNode::simplify(bool const_fold
                }
  
                if (varbuf->type != AST_CONSTANT)
-                       log_file_error(filename, linenum, "Right hand side of 1st expression of generate for-loop is not constant!\n");
+                       log_file_error(filename, location.first_line, "Right hand side of 1st expression of generate for-loop is not constant!\n");
  
 -              varbuf = new AstNode(AST_LOCALPARAM, varbuf);
 -              varbuf->str = init_ast->children[0]->str;
 -
                auto resolved = current_scope.at(init_ast->children[0]->str);
                if (resolved->range_valid) {
 -                      varbuf->range_left = resolved->range_left;
 -                      varbuf->range_right = resolved->range_right;
 -                      varbuf->range_swapped = resolved->range_swapped;
 -                      varbuf->range_valid = resolved->range_valid;
 +                      int const_size = varbuf->range_left - varbuf->range_right;
 +                      int resolved_size = resolved->range_left - resolved->range_right;
 +                      if (const_size < resolved_size) {
 +                              for (int i = const_size; i < resolved_size; i++)
 +                                      varbuf->bits.push_back(resolved->is_signed ? varbuf->bits.back() : State::S0);
 +                              varbuf->range_left = resolved->range_left;
 +                              varbuf->range_right = resolved->range_right;
 +                              varbuf->range_swapped = resolved->range_swapped;
 +                              varbuf->range_valid = resolved->range_valid;
 +                      }
                }
  
 +              varbuf = new AstNode(AST_LOCALPARAM, varbuf);
 +              varbuf->str = init_ast->children[0]->str;
 +
                AstNode *backup_scope_varbuf = current_scope[varbuf->str];
                current_scope[varbuf->str] = varbuf;