Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ExportVerilog] Make ExprEmitter sensitive to assignment-like context (…
…#6329) Make the `ExprEmitter` track whether the current expressions is being emitted into an assignment-like context. Fix the emission of struct and array aggregates to only use `'{...}` assignment patterns when the expression is in such an assignment-like context. These patterns cannot be used otherwise. For packed arrays and structs, pick `'{...}` assignment patterns or `{...}` concatenation based on whether they are printed in an assignment-like context or not. For unpacked arrays (and later unpacked structs), properly emit an error if they are being printed outside an assignment-like context. Unpacked values cannot be created inline arbitrarily. Instead, the `PrepareForEmission` pass has to spill them into a separate variable to artificially construct an assignment-like context (the initializer of or assignment to the spill declaration). We currently seem to do the right thing for unpacked arrays already, such that `PrepareForEmission` does not have to do any additional spilling. Basically, by virtue of spilling arrays and structs to declarations anyway such that they can be accessed into, we are already working around the assignment-like context problem. However, as we build out more support for unpacked data types, we need to update `PrepareForEmission` to make it check if an expression requires an assignment-like context, and if it does, spill the declaration for that reason. Fixes #6275.
- Loading branch information