Commit Graph

488 Commits

Author SHA1 Message Date
Geza Lore d066504bb9
Optimize away calls to empty functions (#6626) 2025-11-02 16:11:02 -05:00
Igor Zaworski 28dd90e92d
Fix side effects for improved function/task/process purity (#6559) 2025-10-29 14:27:31 -04:00
Wilson Snyder b652009235 Internals: Fix name of some static and thread variables. No functional change. 2025-10-27 20:49:41 -04:00
Wilson Snyder f9adc3461d Tests: Fix coverage holes from t_dist_docs_options 2025-10-27 19:16:53 -04:00
Geza Lore eb53bca6fd
Internals: Make AstAssignW a procedural statement (#6280) (#6556)
Initial idea was to remodel AssignW as Assign under Alway. Trying that
uncovered some issues, the most difficult of them was that a delay
attached to a continuous assignment behaves differently from a delay
attached to a blocking assignment statement, so we need to keep the
knowledge of which flavour an assignment was until V3Timing.

So instead of removing AstAssignW, we always wrap it in an AstAlways,
with a special `keyword()` type. This makes it into a proper procedural
statement, which is almost equivalent to AstAssign, except for the case
when they contain a delay. We still gain the benefits of #6280 and can
simplify some code. Every AstNodeStmt should now be under an
AstNodeProcedure - which we should rename to AstProcess, or an
AstNodeFTask). As a result, V3Table can now handle AssignW for free.
Also uncovered and fixed a bug in handling intra-assignment delays if
a function is present on the RHS of an AssignW.

There is more work to be done towards #6280, and potentially simplifying
AssignW handing, but this is the minimal change required to tick it off
the TODO list for #6280.
2025-10-14 09:05:19 +01:00
Geza Lore aaa49273cf Internals: Fix coverage exclusion markers 2025-10-01 21:22:16 +01:00
Geza Lore e04f51ebd2
Internals: Change AstAssignVarScope into AstAliasScope (#6280) (#6512)
Rename and make it derive from AstNode instead of AstNodeAssign.

Small step towards #6280. No functional change.
2025-09-30 06:40:17 +01:00
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