Commit Graph

452 Commits

Author SHA1 Message Date
Robert O'Callahan 578d658871 Add timing stats for IdString garbage collection 2025-11-12 11:52:04 +01:00
Robert O'Callahan df8444c5e7 Optimize IdString operations to avoid calling c_str() 2025-11-12 11:52:04 +01:00
Robert O'Callahan e95ed7bbab Make NEW_ID create IDs whose string allocation is delayed 2025-11-12 11:52:04 +01:00
Robert O'Callahan 8895757364 Ensure that `new_id(_suffix)()` cannot create collisions with existing `IdString`s. 2025-11-12 11:52:04 +01:00
Robert O'Callahan b3f3f42577 Remove StaticIdString and just use IdString now that we can make it constexpr 2025-11-12 11:52:04 +01:00
Robert O'Callahan b0e2d75dbe Make IdString refcounts a hashtable containing only the nonzero refcounts
This saves space and doesn't cost very much since we hardly ever have nonzero refcounts any more.

It also allows for IdStrings with negative indexes, which we're going to add.
2025-11-12 11:52:04 +01:00
Robert O'Callahan 54bde15329 Implement IdString garbage collection instead of refcounting. 2025-11-12 11:52:04 +01:00
Robert O'Callahan 5133b4bdea Create RTLIL::OwningIdString and use it in a few places 2025-11-12 11:52:04 +01:00
Robert O'Callahan d28f97e9da Remove YOSYS_USE_STICKY_IDS 2025-11-12 11:52:04 +01:00
Robert O'Callahan 0fe79ce01b Make RTLIL::Design::get_all_designs() unconditionally defined 2025-11-12 11:52:04 +01:00
Robert O'Callahan e84bc3c6c5 Remove explicit empty-string check when looking up IdStrings 2025-11-12 11:52:04 +01:00
Robert O'Callahan 20639906e3 Store IdString lengths and use them 2025-11-12 11:52:04 +01:00
Robert O'Callahan 32641bbf93 Make IdString::contains take std::string_view so we avoid a strlen when the parameter is a string constant 2025-11-12 11:52:04 +01:00
Robert O'Callahan 2319d82efb Make IdString::begins_width/ends_with take std::string_view so we avoid a strlen when the parameter is a string constant 2025-11-12 11:52:04 +01:00
KrystalDelusion 529886f7fb
Merge pull request #5473 from YosysHQ/krys/unsized_params
Handle unsized params
2025-11-12 07:14:44 +13:00
Emil J. Tywoniak ee5b8a97b9 rtlil: avoid clang warning 2025-11-10 12:02:36 +01:00
Emil J. Tywoniak 0452955069 rtlil: add explanatory note to SigSpec::Chunks 2025-11-10 12:02:21 +01:00
Robert O'Callahan 1cf3497d15 Repack SigSpecs when possible 2025-11-07 15:54:56 +00:00
Robert O'Callahan 38d1d071a5 Implement SigSpec::updhash() using a relaxed atomic for thread-safety 2025-11-07 15:54:56 +00:00
Robert O'Callahan 745222fa3b Make SigSpec::unpack() non-const 2025-11-07 15:54:56 +00:00
Robert O'Callahan 870ae18a2d Switch the SigSpec packed representation to allow just a single chunk that's inline in the SigSpec.
Single-chunk SigSpecs are very common and this avoids a heap allocation. It also simplifies
some algorithms.
2025-11-07 15:54:56 +00:00
Robert O'Callahan 4939484840 Don't reset the hash when unpacking, instead clear the hash whenever bits are modified 2025-11-07 15:54:56 +00:00
Robert O'Callahan aa4a0fe815 Use size() instead of direct access to width_ in many places 2025-11-07 15:54:56 +00:00
Robert O'Callahan 92ea557979 Build a temporary SigChunk list in the iterator in the cases where that's needed 2025-11-07 15:54:55 +00:00
Robert O'Callahan 7394a2c597 Make SigSpec conversion to vector of SigChunk use chunks iterator 2025-11-07 15:54:55 +00:00
Robert O'Callahan 0281ed1458 Add try_as_const and use the const iterator a bit more 2025-11-07 15:54:55 +00:00
Robert O'Callahan 3f7af10eda Make SigSpec::chunks() return an object that can be iterated over without packing the SigSpec 2025-11-07 15:54:54 +00:00
Robert O'Callahan 8d4f790951 Make Module stop accessing internals of SigSpec 2025-11-07 13:25:38 +00:00
Krystine Sherwin 7302bf9a66
Add CONST_FLAG_UNSIZED
In order to support unsized constants being used as parameters, the `const` struct needs to know if it is unsized (so that the parameter can be used to set the size).
Add unsized flag to param value serialization and rtlil back-/front-end.
Add cell params to `tests/rtlil/everything.v`.
2025-11-07 17:45:07 +13:00
Miodrag Milanović 0751b74e7a
Merge pull request #5441 from donn/pyosys_bugfixes
pyosys: fix a number of regressions from 0.58
2025-11-04 07:36:25 +01:00
Vaibhav Singh 88d101b462 kernel: Fix define ID issue, needs undef first 2025-10-31 14:06:00 +05:30
Mohamed Gaber d6b9158fa3
pyosys: fix regressions from 0.58
- consistently use value semantics for objects passed along FFI boundary
  (not ideal but matches previous behavior)
- add new overload of RTLIL::Module: addMemory that does not require a "donor" object
  - the idea is `Module`, `Memory`, `Wire`, `Cell` and `Process` cannot be directly constructed in Python and can only be added to the existing memory hierarchy in `Design` using the `add` methods - `Memory` requiring a donor object was the odd one out here
- fix superclass member wrapping only looking at direct superclass for inheritance instead of recursively checking superclasses
- fix superclass member wrapping not using superclass's denylists
- fix Design's `__str__` function not returning a string
- fix the generator crashing if there's any `std::function` in a header
- misc: add a crude `__repr__` based on `__str__`
2025-10-26 02:21:40 +03:00
Emil J a80462f27f
Merge pull request #5339 from rocallahan/fast-rtlil-parser
Rewrite the RTLIL parser for efficiency
2025-10-08 14:52:37 +02:00
Mohamed Gaber 447a6cb3f0
misc: `WITH_PYTHON` -> `YOSYS_ENABLE_PYTHON`
For consistency.

Also trying a new thing: only rebuilding objects that use the pybind11 library. The idea is these are the only objects that include the Python/pybind headers and thus the only ones that depend on the Python ABI in any capacity, so other objects can be reused across wheel builds. This has the potential to cut down build times.
2025-10-03 11:54:44 +03:00
Robert O'Callahan d45223976a Optimize `IdString::empty()`
I actually saw this take 0.6% of the time in an `opt_clean` pass (under Module::check()).
Trivial issue, but the fix is also trivial and simple.
2025-10-01 02:49:03 +00:00
Robert O'Callahan 86d8dd6224 Add a moving assignment operator for IdString to avoid refcount churn 2025-09-30 21:39:18 +00:00
Robert O'Callahan 39c6e06e3d Add an IdString(std::string_view) constructor for efficiency when we already know the string length 2025-09-30 21:39:18 +00:00
Robert O'Callahan 6b43fca8df Make the Const string constructor take the string by value and move it into the const 2025-09-30 21:39:18 +00:00
Akash Levy 4b6b254e31 pyosys cannot parse header with omitted function args 2025-09-28 01:37:30 -07:00
Robert O'Callahan 1c73011e7e Swap SigSpecs using std::swap with moves 2025-09-25 03:04:17 +00:00
Robert O'Callahan effc52fedc Make `ID::` constants be `StaticIdString`s for better optimization.
Their internal indexes will be known at compile time, like we already support for the `ID()` macro.
2025-09-23 03:25:16 +00:00
Jannis Harder d88d6fce87 kernel: Rewrite bufNormalize
This is a complete rewrite of the RTLIL-kernel-side bufnorm code. This
is done to support inout ports and undirected connections as well as to
allow removal of cells while in bufnorm mode.

This doesn't yet update the (experimental) `bufnorm` pass, so to
manually test the new kernel functionality, it is important to only use
`bufnorm -update` and `bufnorm -reset` which rely entirely on the kernel
functionality. Other modes of the `bufnorm` pass may still fail in the
presence of inout ports or undirected connections.
2025-09-17 13:56:46 +02:00
Jannis Harder c4f435569f kernel: Add known_driver method to Wire/SigSpec 2025-09-17 13:56:46 +02:00
Jannis Harder 22423b97c1 kernel: Add RTLIL::PortDir for a combined input and output flag 2025-09-17 13:56:46 +02:00
Robert O'Callahan d24488d3a5 Instead of using builtin_ff_cell_types() directly, go through a method Cell::is_builtin_ff() 2025-09-17 03:24:19 +00:00
Robert O'Callahan fee2b8992c Stop using `mutable` in `Const`.
Now that we only call `bitvectorize()` in non-const methods, we can move the casting-away-const to only happen
in `bitvectorize()`, which is deprecated so only some plugins (maybe) are using it.

This means `const` `Const` methods don't change the underlying data, which means
they'll be safe to use from multiple threads if/when we want to do that.
2025-09-16 03:17:24 +00:00
Robert O'Callahan 67a274ed1f Optimize Const::hash_into to hash packed bits efficiently 2025-09-16 03:17:24 +00:00
Robert O'Callahan 1a367b907c Use fast path for 32-bit Const integer constructor in more places 2025-09-16 03:17:24 +00:00
Robert O'Callahan b06085ab6c Make Const::Const(long long) constructor use packed bits internally if possible 2025-09-16 03:17:24 +00:00
Robert O'Callahan 61caa5e042 Deprecate Const::bitvectorize() 2025-09-16 03:17:23 +00:00