Commit Graph

481 Commits

Author SHA1 Message Date
Geza Lore 603f4c615a
Improve Loop unrolling (#6480) (#6493)
This patch implements #6480. All loop statements are represented using
AstLoop and AstLoopTest.

This necessitates rework of the loop unroller to handle loops of
arbitrary form. To enable this, I have split the old unroller used for
'generate for' statements and moved it into V3Param, and subsequently
rewrote V3Unroll to handle the new representation. V3Unroll can now
unroll more complex loops, including with loop conditions containing
multiple variable references or inlined functions.

Handling the more generic code also requires some restrictions. If a
loop contains any of the following, it cannot be unrolled:
- A timing control that might suspend the loop
- A non-inlined call to a non-pure function

These constructs can change the values of variables in the loop, so are
generally not safe to unroll if they are present. (We could still unroll
if all the variables needed for unrolling are automatic, however we
don't do that right now.)

These restrictions seem ok in the benchmark suite, where the new
unroller can generally unroll many more loops than before.
2025-09-29 15:25:25 +01:00
Wilson Snyder bdae48f6ae
Optimize duplicate 'if' and '?:' conditions (#3807) (#6495) 2025-09-29 08:18:54 -04:00
Wilson Snyder 3b623dc12e Internals: Refactor to create VCMethod (#3715). No functional change intended. 2025-09-27 08:22:17 -04:00
Geza Lore 40ca0527db
Internal: Refactor AstAssignAlias (#6280) (#6473)
Rename AstAssignAlias to AstAlias and make it derive from AstNode
instead of AstNodeStmt.

Replace AstAlias with AstAssignW in V3LinkDot::linkDotScope, which is
the last place we need to be aware of the alias construct. Using
AstAssignW dowstream enables further optimization while preserving the
same functionality.
2025-09-22 16:30:26 -04:00
Wilson Snyder 9af8e76e87 Fix assertion on streaming from queues 2025-09-20 20:52:46 -04:00
Wilson Snyder a4db488b02 Internals: Fix some object-less asserts 2025-09-20 17:40:50 -04:00
Wilson Snyder 46e56ca6fc Fix elaboration displays with some `%p` (#6451). 2025-09-18 08:35:07 -04:00
Geza Lore ed6687359b
Fix memory leak in V3Const::ifMergeAdjacent (#6449) 2025-09-18 00:45:28 +02:00
Geza Lore 4866cfa09f
Fix deep shift pattern performance (#6379) (#6420) 2025-09-11 11:10:14 -04:00
Geza Lore f1396fbced
Fix memory leaks - batch 2 (#6417) 2025-09-10 22:42:45 +01:00
Wilson Snyder 712ff95a48 Internals: Remove unneeded return, cleanup param test. No functional change 2025-08-30 07:42:41 -04:00
Wilson Snyder 457fcc267b Support elaboration-time printing of unpacked array with `%p` (#4732). 2025-08-21 21:44:31 -04:00
Geza Lore 67da797816
Internals: Cleanup cppcheck warnings (#6317)
`make cppcheck-4` is now clean.
2025-08-20 18:21:24 +01:00
Geza Lore a0edd4e907
Internals: Improve cppcheck flow and fix up issues (#6311)
Added cppcheck-suppressions.txt in the repo root. You can add new
patterns in there instead of having to parse the XML output.

Also configure to add the -D__GNUC__ preprocessor macro, which makes it
understand UASSERT (it understands the 'noreturn' function attribute).

Added some case by case specific suppressions and fixed up other code,
especially in V3Ast*h and V3Dfg*.h, including code generated by astgen
that had some no-ops that irks cppcheck.

One thing it does not seem to like is `const` class members with default
initializers in the class. It will assume that's always the value, even
if overridden in the constructor. We had few so removed them.

With that a lot of files in `src/` are now clean or only have a handful
of issues. Therefore, I have also deleted cppcheck_filtered, and made it
produce human readable output straight to the terminal.

Regarding cleaning up the reported nits, I kind of got bored after
V3[A-E] so pausing here. Apologies for the merge conflicts.

Tested with cppcheck 2.13.0
2025-08-19 22:02:10 +01:00
Wilson Snyder 36c4a24661 Internals: constifyParamsEdit return value was unused. No functional change. 2025-08-16 21:03:12 -04:00
Wilson Snyder 49ca1cfdd7 Commentary 2025-08-16 18:32:40 -04:00
Geza Lore 6f69c990fd
Internals: Remove AstCondBound and AstNodeCond (#6293) (#6294)
Fixes #6293
2025-08-15 15:49:06 -07:00
Wilson Snyder 3ca1c9b6dd Internals: Fix and enforce brace new constructors. No functional change intended. 2025-08-08 18:21:12 -04:00
Wilson Snyder d1f851e1e1 Internals: Optimize empty 'if' into StmtExpr 2025-08-08 05:10:40 -04:00
github action dc049fdd74 Apply 'make format' 2025-08-06 21:30:37 +00:00
Michael Bedford Taylor 218659f4e8
Support parameter resolution of 1D unpacked array slices (#6257) (#6268) 2025-08-06 17:29:40 -04:00
Wilson Snyder dca504c706 Internals: Use UINFOTREE istead of dumpTree 2025-08-02 13:44:40 -04:00
Paul Swirhun bd2cb989d1 Support bit queue streaming (#5830) (#6103). 2025-07-27 15:29:56 -04:00
Wilson Snyder 470f99694e Revert d8dbb08a: Support bit queue streaming (#5830) (#6103) 2025-07-26 17:59:52 -04:00
Paul Swirhun d8dbb08a95
Support bit queue streaming (#5830) (#6103) 2025-07-26 16:53:51 -04:00
Geza Lore 7c5d462564
Remove AstJumpLabel (#6221)
Remove AstJumpLabel

AstJumpGo now references one if its enclosing AstJumpBlocks, and
branches straight after the referenced block.

That is:

```
JumpBlock a {
   ...
   JumpGo(a);
   ...
}
// <--- the JumpGo(a) goes here
```

This is sufficient for all use cases and makes control flow much easier to
reason about. As a result, V3Const can optimize a bit more aggressively.

Second half of, and fixes #6216
2025-07-23 17:51:16 +01:00
Geza Lore 763183f067
Internals: Remove AstWhile::precondsp() (#6219). No functional change intended. 2025-07-23 08:50:39 -04:00
Max Wipfli a50ea2a1a6
Optimize 2 ** X to 1 << X if base is signed (#6203) 2025-07-20 09:56:34 -04:00
Todd Strader 08fef668cd
Fix more wide ternary + coverage cases (#6155) 2025-07-03 18:00:39 -04:00
Todd Strader ae0f29ed37
Fix wide non-blocking assignment mis-optimization (#6150) (#6152) 2025-07-02 18:43:10 -04:00
Geza Lore 916d473eff
Internals: Replace unnecessary AstSel::widthp() child node with const in node (#6117) 2025-06-24 11:59:09 -04:00
Todd Strader 47f5a6a52b
Fix unpacked to packed parameter assignment (#6088) (#6081) 2025-06-12 12:47:58 -04:00
Wilson Snyder 46c7b69c64 Internals: UINFO now includes newline itself. No functional change. 2025-05-22 20:29:32 -04:00
Yutetsu TAKATSUKASA b26658fd96
Fix wrong optimization result of shifted out variable (#6016) (#6019) 2025-05-18 07:18:37 -04:00
Wilson Snyder 1bcd5ee0c1 Fix spelling 2025-05-16 19:02:19 -04:00
Ryszard Rozak 91c52a4972
Support for assignments to concatenations with impure RHS (#6002) 2025-05-12 19:19:38 -04:00
Yutetsu TAKATSUKASA 100e3d7702
Fix const-bit-op-tree with single-bit masks (#5993) (#5998) 2025-05-10 06:01:15 -04:00
Ryszard Rozak 2358f5c2a2
Fix AstAssignW conversion (#5991) (#5992) 2025-05-07 05:54:18 -04:00
Wilson Snyder 69eb76ad66 Fix constant propagation of post-expand stages (#5983). 2025-05-05 07:04:20 -04:00
Wilson Snyder a3662cc3f5 Internals: Refactor to create replaceWithKeepDType. No functional change. 2025-05-05 06:31:06 -04:00
Wilson Snyder 66e105b444 Fix constant propagation of post-expand stages (#5963) (#5972). 2025-05-04 21:41:14 -04:00
Wilson Snyder 27ad648c16 Commentary: Indicate V3Number width() criticality. 2025-05-04 16:24:36 -04:00
Wilson Snyder 4e667fabb7 Internals: Add V3Number width-and-opAssign. No functional change. 2025-04-30 08:08:44 -04:00
Wilson Snyder 3658e5f0f1 Internals: Rename widthToFit, no functional change. 2025-04-28 21:54:58 -04:00
Ryszard Rozak 6bb57e4630
Fix assignments with stream expressions and unpacked arrays (#5915) 2025-04-09 06:37:52 -04:00
Wilson Snyder f5312b83b9 Fix %% on elaboration severity tasks (#5922). 2025-04-07 08:38:05 -04:00
Wilson Snyder 45add07205 Internals: Minor V3Param cleanups. No functional change. 2025-03-12 07:58:26 -04:00
Geza Lore fc302a5207
Fix sorting of wide SenItems (#5816)
This used to throw Error: Value too wide for 64-bits expected in this context
2025-03-01 22:11:43 +00:00
Wilson Snyder 05c7a3b90b Optimize labels as final `if` block statements (#5744). 2025-01-25 10:29:35 -05:00
Wilson Snyder d8080008b4 Commentary 2025-01-24 07:47:32 -05:00