google / xls

XLS: Accelerated HW Synthesis
http://google.github.io/xls/
Apache License 2.0
1.18k stars 172 forks source link

DSLX formatter doesn't like unroll_for! #1599

Open mikex-oss opened 1 week ago

mikex-oss commented 1 week ago

Describe the bug The DSLX formatter crashes on unroll_for.

To Reproduce

  1. Take the example at https://github.com/google/xls/blob/b117a11ef67534bba97f8562b024278fb9ba7ee5/xls/dslx/ir_convert/proc_config_ir_converter_test.cc#L271-L314

  2. Run it through the autoformatter.

  3. See error:

Formatting failed: F0911 15:00:34.665527 1066535 ast_fmt.cc:1338] handle unroll for: unroll_for! (i, _): (u32, ()) in u32:0..u32:2 {
    unroll_for! (j, _): (u32, ()) in u32:0..u32:2 {
        spawn B(input_from_a[i][j], output_to_a[i][j]);
    }(())
}(())
*** Check failure stack trace: ***
    @     0x55a69f4b7bcb  absl::log_internal::LogMessage::Flush()
    @     0x55a6a0409f69  absl::log_internal::LogMessageFatal::~LogMessageFatal()
    @     0x55a6a040b386  xls::dslx::(anonymous namespace)::Fmt()
    @     0x55a6a040b30c  xls::dslx::(anonymous namespace)::FmtExprVisitor::HandleUnrollFor()
    @     0x55a6a02438b1  xls::dslx::(anonymous namespace)::FmtExpr()
    @     0x55a6a02488e3  std::__u::__variant_detail::__visitation::__base::__dispatcher<>::__dispatch<>()
    @     0x55a6a0241eb4  xls::dslx::(anonymous namespace)::FmtBlock()
    @     0x55a6a025f716  xls::dslx::Fmt()
    @     0x55a6a02447e8  xls::dslx::Fmt()
    @     0x55a6a02468a1  xls::dslx::AutoFmt()
    @     0x55a69fb...

Expected behavior Autoformatting should work.

mikex-oss commented 1 week ago

@richmckeever not sure if you are still the right one to take a look at this, feel free to reassign.