diff --git a/Changes b/Changes index 8775fbe6e..c16748deb 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,11 @@ 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.881 devel + +**** Internal Verilation-time performance enhancements, bug1021. [Johan Bjork] + + * Verilator 3.880 2015-12-19 *** Support display %u, %v, %p, %z, bug989. [Johan Bjork] diff --git a/src/astgen b/src/astgen index 33bfcca3f..8aba5b352 100755 --- a/src/astgen +++ b/src/astgen @@ -248,8 +248,15 @@ sub write_impl { my $fh = open_file(@_); foreach my $type (sort (keys %Classes)) { next if $type eq "Node"; # Special, just a return (this); - printf $fh "inline Ast%-16s AstNode::cast${type}() { return (dynamic_cast(this)); }\n" - ,$type."*"; + # For performance, prefer static_cast where we can + if (children_of($type)) { + printf $fh "inline Ast%-16s AstNode::cast${type}() { return (dynamic_cast(this)); }\n" + ,$type."*"; + } else { + my $ucType = uc $type; + printf $fh "inline Ast%-16s AstNode::cast${type}() { return (this && this->type() == AstType::at${ucType}) ? static_cast(this) : NULL; }\n" + ,$type."*"; + } } $fh->close(); }