Skip to content

Type and verify the wtc ops against what they lower to - #5

Closed
ZweZeya wants to merge 1 commit into
feat/queue-kind-in-irfrom
feat/dialect-verification
Closed

ZweZeya wants to merge 1 commit into
feat/queue-kind-in-irfrom
feat/dialect-verification

Conversation

@ZweZeya

@ZweZeya ZweZeya commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #4 (feat/queue-kind-in-ir).

What this changes

The mechanical part of "the dialect carries no semantics":

  • lock/unlock take a !wtc.mutex instead of any type.
  • Push checks that its value refers to the queue's element type; pop does the same for a pointer result, and delivers its value exactly one way (result or result_slot).
  • Every op checks that fallback_impl names a cir.func implementing the same operation (the shim's annotation, or a substitute's wtc_impl_<name>_<operation>) with the arity lowering will pass.
  • Every op declares that it reads and writes memory.

What the ops promise about ordering and progress is a design question, so decisions/0003-concurrency-semantics-of-the-wtc-ops.md proposes an answer for discussion; nothing in it is implemented. Your view on it is the main thing I'd like from this PR.

How it was checked

27 of 27 pass, no warnings. The seven cases in test/Dialect/invalid.mlir are all accepted silently by the parent. The prototype's example, lifted for both targets, verifies under the new rules.

Checklist

  • CI is green
  • New behaviour has a test; a fixed bug has a test that failed before
  • No file moves or renames mixed in with substantive changes
  • The pinned LLVM revision is untouched, or this PR does nothing else

🤖 Generated with Claude Code

lock and unlock accepted an operand of any type, and nothing checked an
op against the call it stands for: a wrong fallback_impl surfaced only
when the lowered call failed to verify or link, if it did at all.

Now lock and unlock take a !wtc.mutex. Push checks that the value it
passes refers to the queue's element type; pop does the same for a
pointer result, and delivers its value exactly one way, as its result or
through result_slot. Each op checks that fallback_impl names a cir.func
implementing the same operation -- the shim's annotation, or a
substitute's wtc_impl_<name>_<operation> -- that takes the arguments
lowering will pass. Each op declares that it reads and writes memory.

That is the mechanical part. What the ops promise about ordering and
progress is a design question, so decisions/0003 proposes an answer for
discussion rather than implementing one.

Verified: 17 of 17 pass, no warnings. The seven invalid cases are all
accepted silently by the parent commit. The prototype's example, lifted
for AArch64 and for x86-64, verifies under the new rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ZweZeya
ZweZeya force-pushed the feat/dialect-verification branch from 99d62be to ad2187d Compare October 18, 2026 05:20
@ZweZeya
ZweZeya force-pushed the feat/queue-kind-in-ir branch from b98246d to 9d20b82 Compare October 18, 2026 05:20
@apaznikov

Copy link
Copy Markdown
Collaborator

Closing because the substance of this PR is in #10, under your authorship: mlir: Check each wtc op against the call it lowers to ports the WTC_ObjectOp base with its memory effects and the fallback_impl verifier (annotation and arity) and keeps your tests' cases. One part was not taken: the check that a pushed value points to the element type, because on that branch the queue type's parameter is the queue object's type. Decision 0003 is ported as you wrote it (decisions: Propose what a wtc operation promises, also under your name), with only the name of the substitution pass changed, and is marked taken as option 2: the contract now sits in each operation's description, and a progress table (decision 0004) builds on it. The open question at its end stays open.

@apaznikov apaznikov closed this Oct 19, 2026
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.

2 participants