Skip to content
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

Removing duplicate prose #69

Closed
wants to merge 3 commits into from
Closed

Removing duplicate prose #69

wants to merge 3 commits into from

Conversation

jaehyun1ee
Copy link

As mentioned in #63, there were duplicate prose for:

warning: prose rule `exec/array.new_data` has multiple definitions
warning: prose rule `exec/call_ref` has multiple definitions
warning: prose rule `valid/cvtop` has multiple definitions

There were two reasons:

(1) Manually-written algorithms

Execution algorithms for exec/array.new_data and exec/call_ref are written manually in backend-interpreter/manual.ml, for translating them to AL were quite tricky. The problem was that the failed translation (indicated by YetI) from il2al/translate.ml and the manual algorithms were counted twice. Thus, I've modified exe-watsup/main.ml to nullify the failed translations for manual algorithms.

This resolves the upper-two warnings.

(2) Prefix validation rule names

When translating formal rules to prose, we first group validation rules by their name's prefix. For example, Instr_ok/select-expl and Instr_ok/select-impl are grouped by their prefix select-. The rule names for the validation of cvtop were not properly named with the same prefix, so I re-named them to: cvtop-reinterpret, cvtop-convert-i, and cvtop-convert-f.

This handles the last warning, so all warnings are now gone. Yet, the current validation prose generator cannot handle multiple validation rules per Wasm instruction. select and cvtop are such cases, where the generator only takes the first rule and translates it, ignoring the rest.

let (winstr, t, prems, _tenv) = vrules |> List.hd in

This should be addressed, but will take some time since this requires some discussion with @f52985.

Instr_ok/reinterpret
Instr_ok/convert-*
}
$${rule+: Instr_ok/cvtop-*}
Copy link
Collaborator

@rossberg rossberg Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was supposed to test splices with multiple rule patterns listed, so preferably change it to

Suggested change
$${rule+: Instr_ok/cvtop-*}
$${rule+:
Instr_ok/cvtop-reinterpret
Instr_ok/cvtop-convert-*
}

Comment on lines +197 to +210
let get_name = function
| Al.Ast.RuleA ((id, _), _, _) -> id
| Al.Ast.FuncA (id, _, _) -> id
in
let al_manual = Backend_interpreter.Manual.manual_algos in
let names_manual = List.map get_name al_manual in
let al_translated =
List.filter
(fun algo ->
let name_translated = get_name algo in
not (List.mem name_translated names_manual))
(Il2al.Translate.translate il)
in
al_translated @ al_manual
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workaround shouldn't be in main. Can you move it to the backend somehow? Also, add a comment explaining why this is needed, and that (supposedly?) it's a TODO to get rid of the workaround eventually.

@jaehyun1ee
Copy link
Author

This PR went stale, but will soon revisit on this issue :)

@jaehyun1ee jaehyun1ee closed this Mar 5, 2024
Alan-Liang pushed a commit to Alan-Liang/spectec that referenced this pull request Sep 2, 2024
When looking up a type on the context, expand it (using `~~`) into the
expected composite type instead of using equality (`=`). Also fix some
places where equality should have been used when looking up tags.
Add `func` to expanded function types.
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