Skip to content

Source-location tracking and diagnostics through the pipeline #74

Description

@tetsuo-cpp

Summary

Preserve Forth source locations on MLIR ops through translation and conversion so compile failures and debug dumps point at the offending word/line, not only opaque lowered IR.

Motivation

The parser has SMLoc / emitErrorAt for many syntax and control-flow errors. After lowering, pipeline failures and miscompiles are harder to attribute: stack/MemRef ops often lack useful FusedLoc / file-line mapping back to the .forth line.

For a stack language, “which word under/overflowed or lowered wrong?” is essential DX.

Proposed work

  1. Attach FileLineColLoc (or equivalent) to every emitted forth.* op at parse time
  2. Ensure conversion patterns propagate locations to new arith/memref/gpu ops (rewriter uses op.getLoc() consistently — audit and fix gaps)
  3. warpforthc dumps: --debug-ir-after=convert-forth-to-memref style using standard MLIR pass instrumentation
  4. Optional: print caret diagnostics for pipeline failures when locations remain

Acceptance criteria

  • Audit: major Forth ops carry source locs out of the parser
  • Sample conversion patterns preserve locs (LIT can check loc( in dump if stable)
  • warpforthc supports IR dumping at stage boundaries (pass manager cl options wired or documented)
  • At least one intentional lowering error demonstrates a Forth line in the diagnostic

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions