Skip to content

Close MLIR parity gaps exposed by flow-idiomatics - #730

Merged
godofecht merged 1 commit into
mainfrom
fix/mlir-or-patterns
Aug 23, 2026
Merged

godofecht merged 1 commit into
mainfrom
fix/mlir-or-patterns

Conversation

@godofecht

@godofecht godofecht commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

flow-idiomatics now treats portable flagship programs as a dual-backend contract: the same source must execute through the C backend and lower to MLIR that is accepted by mlir-opt. Enforcing that contract exposed several real MLIR parity gaps rather than showcase problems.

This PR closes those gaps without simplifying the source programs:

  • expands match or-patterns through the existing MLIR match lowering;
  • lowers span<T> / span<mut T> as {ptr, len} LLVM aggregates, including array borrowing, zero-copy slicing, .len, indexed loads, and mutable stores;
  • implements binding patterns, _ wildcards, guards, and exhaustive-match join termination correctly;
  • adds first-class Flow function types to MLIR as a uniform fat closure {code_ptr, env_ptr};
  • supports higher-order function parameters, function-valued locals/results, non-capturing lambdas, escaping capturing lambdas, and closures whose environments recursively contain other first-class function values;
  • reuses the backend's existing function-pointer conversion/indirect-call machinery rather than adding a second callable ABI;
  • adds focused regressions for or-patterns, spans, guarded/binding matches, exhaustive matches, escaping closures, higher-order parameters, and closure composition.

The integration proof is the flow-idiomatics portable corpus. The original seven flagships already pass both C execution and LLVM 18 mlir-opt verification against this work. The stacked algebraic corpus adds an eighth program, maximal/algebraic_core.flow, which deliberately returns a closure that captures two other closures; that program is also required to pass the same dual-backend gate before this PR is merged.

@godofecht godofecht changed the title Lower match or-patterns on the MLIR backend Close MLIR parity gaps exposed by flow-idiomatics Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Maintenance check (2026-08-23): do not merge yet. Head f5519ea8a489ec1542ccf99483ba6133634059cc is currently non-mergeable against main, and the primary CI workflow run 32618400321 is red after attempt 2. Tier-1 qualification, docs ratchet, wasm32, and bpfel are green, so the remaining gate is narrow: refresh/resolve the branch against current main, then rerun the full CI matrix and require the main CI workflow green before merge. The stacked flow-idiomatics PRs should remain pinned until this lands and is requalified from Flow main.

@godofecht
godofecht force-pushed the fix/mlir-or-patterns branch from 32481e1 to 75faf97 Compare August 23, 2026 10:59
@godofecht
godofecht merged commit 04826da into main Aug 23, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant