Skip to content

Structured source locations #1131

Open
Open
@whitequark

Description

@whitequark

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @whitequark

        Issue actions

          Structured source locations · Issue #1131 · amaranth-lang/amaranth