Skip to content

Structured source locations #1131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
whitequark opened this issue Feb 13, 2024 · 0 comments
Open

Structured source locations #1131

whitequark opened this issue Feb 13, 2024 · 0 comments

Comments

@whitequark
Copy link
Member

whitequark commented Feb 13, 2024

Right now source locations are collected in an unspecified format that has an ad-hoc serialization to Yosys RTLIL and is also used in ad-hoc ways in other places. We should define a structured format which provides the following capabilities:

  • Storing filename, start line, start column, end line, end column (unclear if 0-based or 1-based is preferable; will have to be adjusted for RTLIL output anyway).
  • Combining several locations into an ordered sequence where the first one is "most specific" and the last one is "least specific". The definitions of these is intentionally ambiguous; editors will show the "most specific" location on the primary go-to-source (i.e. click or double click), but show all of the locations in order.

An example of where source locations would form an ordered sequence:

  • Elaboration, where each next Elaboratable returned by an elaborate method adds another source location. Currently, all of this information is lost (see Attach src attributes to emitted modules and cells #1130).
  • lib.wiring, where an In(1) could be created via Signature({"ready": In(1)}) which itself is created via stream: Signature({"ready": In(1)}) in a Component, which itself is created elsewhere. Currently, almost all of that information (except for the location of the In(1), which can be quite uninformative) is lost.

An alternative option is to provide a more complex data structure (dict? dict of lists?) for the list of source location, but this seems excessive, poorly defined, and would likely have to be flattened for Yosys anyways.


This issue is not about stabilizing the source location format. The actual Amaranth objects representing them remain unstable.

@whitequark whitequark added this to the 0.5 milestone Feb 13, 2024
@whitequark whitequark mentioned this issue Mar 22, 2024
77 tasks
@whitequark whitequark modified the milestones: 0.5, 0.6 Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant