Skip to content

Single Body Instances #505

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

Merged
merged 15 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/stable-mir-json
Submodule stable-mir-json updated 28 files
+28 −0 LICENSE
+6 −28 src/mk_graph.rs
+22 −36 src/printer.rs
+2,603 −2,629 tests/integration/programs/assert_eq.smir.json.expected
+7,178 −7,198 tests/integration/programs/binop.smir.json.expected
+1,303 −1,321 tests/integration/programs/char-trivial.smir.json.expected
+1,543 −1,563 tests/integration/programs/closure-args.smir.json.expected
+1,398 −1,418 tests/integration/programs/closure-no-args.smir.json.expected
+1,522 −1,542 tests/integration/programs/const-arithm-simple.smir.json.expected
+1,601 −1,619 tests/integration/programs/div.smir.json.expected
+1,418 −1,436 tests/integration/programs/double-ref-deref.smir.json.expected
+1,202 −1,220 tests/integration/programs/enum.smir.json.expected
+1,836 −1,856 tests/integration/programs/fibonacci.smir.json.expected
+1,768 −1,786 tests/integration/programs/float.smir.json.expected
+1,589 −1,607 tests/integration/programs/modulo.smir.json.expected
+1,786 −1,808 tests/integration/programs/mutual_recursion.smir.json.expected
+1,478 −1,498 tests/integration/programs/option-construction.smir.json.expected
+1,467 −1,485 tests/integration/programs/primitive-type-bounds.smir.json.expected
+1,638 −1,658 tests/integration/programs/recursion-simple-match.smir.json.expected
+1,639 −1,659 tests/integration/programs/recursion-simple.smir.json.expected
+1,365 −1,383 tests/integration/programs/ref-deref.smir.json.expected
+2,491 −2,509 tests/integration/programs/shl_min.smir.json.expected
+3,763 −3,914 tests/integration/programs/slice.smir.json.expected
+1,424 −1,442 tests/integration/programs/strange-ref-deref.smir.json.expected
+1,495 −1,513 tests/integration/programs/struct.smir.json.expected
+2,021 −2,043 tests/integration/programs/sum-to-n.smir.json.expected
+1,980 −2,121 tests/integration/programs/tuple-eq.smir.json.expected
+1,412 −1,430 tests/integration/programs/tuples-simple.smir.json.expected
2 changes: 1 addition & 1 deletion kmir/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kmir"
version = "0.3.103"
version = "0.3.104"
description = ""
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion kmir/src/kmir/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from typing import Final

VERSION: Final = '0.3.103'
VERSION: Final = '0.3.104'
6 changes: 3 additions & 3 deletions kmir/src/kmir/kdist/mir-semantics/body.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requires "ty.md"
module BODY-SORTS

syntax Body
syntax Bodies
syntax MaybeBody
syntax DefId
syntax MaybeInt
syntax MIRBool
Expand Down Expand Up @@ -355,10 +355,10 @@ syntax VarDebugInfo ::= varDebugInfo(name: Symbol, sourceInfo: SourceInfo, compo
syntax VarDebugInfos ::= List {VarDebugInfo, ""}
[group(mir-list), symbol(VarDebugInfos::append), terminator-symbol(VarDebugInfos::empty)]

syntax MaybeBody ::= someBody(Body) [group(mir-option)]
| "noBody" [group(mir-option)]
syntax Body ::= body(blocks: BasicBlocks, locals: LocalDecls, argCount: MIRInt, varDebugInfo: VarDebugInfos, spreadArg: MaybeLocal, span: Span)
[group(mir---blocks--locals--arg-count--var-debug-info--spread-arg--span)]
syntax Bodies ::= List {Body, ""}
[group(mir-list), symbol(Bodies::append), terminator-symbol(Bodies::empty)]

endmodule
```
Expand Down
14 changes: 7 additions & 7 deletions kmir/src/kmir/kdist/mir-semantics/kmir.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ be known to populate the `currentFunc` field.
rule <k> #execFunction(
monoItem(
SYMNAME,
monoItemFn(_, _, body((FIRST:BasicBlock _) #as BLOCKS,LOCALS, _, _, _, _) .Bodies)
monoItemFn(_, _, someBody(body((FIRST:BasicBlock _) #as BLOCKS,LOCALS, _, _, _, _)))
),
FUNCTIONNAMES
)
Expand Down Expand Up @@ -450,11 +450,10 @@ NB that a stack height of `0` cannot occur here, because the compiler prevents l
rule #getBlocks(FUNCS, ID) => #getBlocksAux({FUNCS[ID]}:>MonoItemKind)
requires ID in_keys(FUNCS)

// returns blocks from the _first_ body if there are several
// TODO handle cases with several blocks
rule #getBlocksAux(monoItemFn(_, _, .Bodies)) => .List
rule #getBlocksAux(monoItemFn(_, _, body(BLOCKS, _, _, _, _, _) _)) => toKList(BLOCKS)
// other item kinds are not expected or supported
// returns blocks from the body
rule #getBlocksAux(monoItemFn(_, _, noBody)) => .List
rule #getBlocksAux(monoItemFn(_, _, someBody(body(BLOCKS, _, _, _, _, _)))) => toKList(BLOCKS)
// other item kinds are not expected or supported FIXME: Just getting stuck for now
rule #getBlocksAux(monoItemStatic(_, _, _)) => .List // should not occur in calls at all
rule #getBlocksAux(monoItemGlobalAsm(_)) => .List // not supported. FIXME Should error, maybe during #init
```
Expand Down Expand Up @@ -533,7 +532,7 @@ An operand may be a `Reference` (the only way a function could access another fu

// reserve space for local variables and copy/move arguments from old locals into their place
rule <k> #setUpCalleeData(
monoItemFn(_, _, body((FIRST:BasicBlock _) #as BLOCKS, NEWLOCALS, _, _, _, _) _:Bodies),
monoItemFn(_, _, someBody(body((FIRST:BasicBlock _) #as BLOCKS, NEWLOCALS, _, _, _, _))),
ARGS
)
=>
Expand All @@ -551,6 +550,7 @@ An operand may be a `Reference` (the only way a function could access another fu
// assumption: arguments stored as _1 .. _n before actual "local" data
...
</currentFrame>
// TODO: Haven't handled "noBody" case

syntax KItem ::= #setArgsFromStack ( Int, Operands)
| #setArgFromStack ( Int, Operand)
Expand Down
2 changes: 1 addition & 1 deletion kmir/src/kmir/kdist/mir-semantics/mono.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ syntax StaticDef ::= staticDef(Int) [group(mir-int)] // imported from crate
syntax MaybeAllocation ::= someAllocation(Allocation) [group(mir-option)]
| "noAllocation" [group(mir-option)]

syntax MonoItemKind ::= monoItemFn(name: Symbol, id: DefId, body: Bodies)
syntax MonoItemKind ::= monoItemFn(name: Symbol, id: DefId, body: MaybeBody)
[ group(mir-enum---name--id--body)
, symbol(MonoItemKind::MonoItemFn)
]
Expand Down
2 changes: 1 addition & 1 deletion kmir/src/kmir/parse/notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ json: an array of integer values between 0 and 255
syntax Elems ::= List {Elem, ""} [group(mir-list), ...]
```
json: a homogeneous list, e.g. `[e1, e2, e3, ...]`, where all elements correspond to syntactic productions for the sort `Elem`.
As per naming convention, the list sort `Elems` (plural) should contain elements of sort `Elem` (singular). Usual plural formation rules (`Body -> Bodies`, `Branch -> Branches`) are respected.
As per naming convention, the list sort `Elems` (plural) should contain elements of sort `Elem` (singular). Usual plural formation rules (`Branch -> Branches`) are respected.

#### mir-klist-ElementSort
```
Expand Down
2 changes: 1 addition & 1 deletion kmir/src/kmir/parse/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _list_symbols(sort: str) -> tuple[str, str]:
# Given a list Sort, return the element sort.
def _element_sort(sort: KSort) -> KSort:
name = sort.name
if name.endswith('ies'): # Bodies, Entries, ...
if name.endswith('ies'): # Entries, ...
return KSort(name[:-3] + 'y')
elif ( # -es for words ending in 's', 'ch', 'sh', 'ss', 'x' or 'z'
name.endswith('ses')
Expand Down
Loading