From b07dd622faa57f6d3427644b183729dcd69a31aa Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 22 Nov 2008 17:37:20 -0500 Subject: [PATCH] Commentary: Debugging and some astgen code cleanup. No functional change. --- Changes | 2 +- src/0CodeNotes.pod | 10 ++++++++++ src/Makefile_obj.in | 2 +- src/V3Ast.h | 6 +++--- src/V3Const.cpp | 15 ++++++++++++--- src/V3Graph.cpp | 2 +- src/astgen | 5 +++-- 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index 58a437c5f..491b184a6 100644 --- a/Changes +++ b/Changes @@ -3,7 +3,7 @@ Revision history for Verilator The contributors that suggested a given feature are shown in []. [by ...] indicates the contributor was also the author of the fix; Thanks! -* Verilator 3.68*** +* Verilator 3.700*** *** Optimize two-level shift and and/or trees, +23% on one test. diff --git a/src/0CodeNotes.pod b/src/0CodeNotes.pod index 91be3500f..c66d24fa8 100644 --- a/src/0CodeNotes.pod +++ b/src/0CodeNotes.pod @@ -53,6 +53,16 @@ more messy than the above and is deprecated. (V3Width was nearly the first module written. Someday this scheme may be removed, as it slows the program down to have to pass vup everywhere.) +=head1 DEBUGGING WITH GDB + +The test_regress/driver.pl script accepts --gdb to start Verilator under +gdb. + +To break at a specific edit number which changed a node (presumably to find +what made a line in the tree dumps): + + watch AstNode::s_editCntGbl==#### + =head1 DISTRIBUTION Copyright 2008-2008 by Wilson Snyder. This program is free software; you diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index 5288b5295..bdd4e15cc 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -226,7 +226,7 @@ V3Number_test: V3Number_test.o #### Modules -%__gen.cpp: %.cpp $(ASTGEN) +%__gen.cpp: %.cpp $(ASTGEN) V3Ast.h V3AstNodes.h $(PERL) $(ASTGEN) -I$(srcdir) $*.cpp %.o: %.cpp diff --git a/src/V3Ast.h b/src/V3Ast.h index 170c1315b..279088c5e 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -732,7 +732,7 @@ public: static void user5ClearTree() { AstUser5InUse::clear(); } vluint64_t editCount() const { return m_editCount; } - void editCountInc() { m_editCount = s_editCntGbl++; } + void editCountInc() { m_editCount = ++s_editCntGbl; } static vluint64_t editCountLast() { return s_editCntLast; } static vluint64_t editCountGbl() { return s_editCntGbl; } static void editCountSetLast() { s_editCntLast = editCountGbl(); } @@ -1027,7 +1027,7 @@ struct AstNodeCase : public AstNodeStmt { }; struct AstNodeSenItem : public AstNode { - // A AstSenItem under + // An AstSenItem or AstSenGate AstNodeSenItem(FileLine* fl) : AstNode(fl) {} ASTNODE_BASE_FUNCS(NodeSenItem) virtual bool isClocked() const = 0; @@ -1038,7 +1038,7 @@ struct AstNodeSenItem : public AstNode { }; class AstNodeVarRef : public AstNodeMath { - // A AstVarRef or AstVarXRef + // An AstVarRef or AstVarXRef private: bool m_lvalue; // Left hand side assignment AstVar* m_varp; // [AfterLink] Pointer to variable itself diff --git a/src/V3Const.cpp b/src/V3Const.cpp index f97ba3911..efa226637 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1255,9 +1255,18 @@ private: // $accessor_name, ... // # ,, gets replaced with a , rather than && // }" # bracket not paren - // ,"function to call" - // or ,"AstREPLACEMENT_TYPE{ $accessor }" - // or ,"! # Print line number when matches, so can see operations + // ,"what to call" + // + // Where "what_to_call" is: + // "function to call" + // "AstREPLACEMENT_TYPE{ $accessor }" + // "! # Print line number when matches, so can see operations + // "NEVER" # Print error message + // "DONE" # Process of matching did the transform already + + // In the future maybe support more complicated match & replace: + // ("AstOr {%a, AstAnd{AstNot{%b}, %c}} if %a.width1 if %a==%b", "AstOr{%a,%c}; %b.delete"); + // Lhs/rhs would be implied; for non math operations you'd need $lhsp etc. // Lint Checks // v--- *1* These ops are always first, as we warn before replacing diff --git a/src/V3Graph.cpp b/src/V3Graph.cpp index 147c7d566..5e4aad97d 100644 --- a/src/V3Graph.cpp +++ b/src/V3Graph.cpp @@ -276,7 +276,7 @@ void V3Graph::dumpDotFile(const string& filename, bool colorAsSubgraph) { // Header *logp<<"digraph v3graph {\n"; *logp<<"\trankdir="<$1()/g; - $out .= $outl; + $out .= $outl.";"; } elsif ($func =~ /^\s*Ast([a-zA-Z0-9]+) \s*\{\s* (.*) \s* \}$/x) { @@ -433,6 +433,7 @@ sub treeop_exec_func { #print "FF $out\n" if $Debug; } elsif ($func eq "NEVER") { $out .= "nodep->v3fatalSrc(\"Executing transform that was NEVERed\");"; + } elsif ($func eq "DONE") { } else { $self->error("Unknown execution function format: $func\n"); } @@ -450,7 +451,7 @@ sub tree_match { "\t// $typefunc->{comment}\n",); $self->print( "\tif ($typefunc->{match_if}) {\n"); $self->print( "\t UINFO($typefunc->{uinfo_level},(void*)(nodep)<<\" $typefunc->{uinfo}\\n\");\n"); - $self->print( "\t $typefunc->{exec_func};\n"); + $self->print( "\t $typefunc->{exec_func}\n"); $self->print( "\t return true;\n"); $self->print( "\t}\n"); $self->print( "\treturn false;\n");