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

[MC][AsmParser] Check the list of supported condition codes #440

Closed
atrosinenko opened this issue Mar 18, 2024 · 12 comments · Fixed by #559
Closed

[MC][AsmParser] Check the list of supported condition codes #440

atrosinenko opened this issue Mar 18, 2024 · 12 comments · Fixed by #559

Comments

@atrosinenko
Copy link
Collaborator

At now, a number of conditional code names are supported across the instructions. These are short forms like .eq, .le, .ge as well as the longer forms mentioned in the VM Primer (such as .if_eq, .if_le, .if_ge, .if_gt_or_eq). The mapping of strings to EraVMCC constants is listed in parseExplicitCondition function in EraVMAsmParser.cpp file (permalink at the time of writing).

After redesigning the assembly syntax, only the shorter form is likely to remain, so parseExplicitCondition function should be updated accordingly.

@asl
Copy link
Collaborator

asl commented Mar 18, 2024

@sayon Will you please comment on what should be supported?

@sayon
Copy link

sayon commented Mar 18, 2024

The longer form (like .if_eq) is unnecessary, the short forms are sufficient to us. So,

  • eq
  • lt
  • gt
  • ne
  • ge
  • le

@akiramenai @hedgar2017 do you think we should support something like of as an alias to lt?

@hedgar2017
Copy link
Collaborator

@sayon I dislike unnecessary aliases personally.

@akiramenai
Copy link
Collaborator

akiramenai commented Mar 21, 2024

The issue here is that our lt is not quite lt, it's lt for sub. But it's more ISA issue than asm, we reuse flags for different purposes in different context. Whatever naming we choose, it's misleading for some instructions. Maybe we could rename eq -> z as it works like a conventional zero flag almost everywhere. Maybe, we want to rename lt to some single letter same as gt and make xz, yz suffixes to check 2 flags combinations. An abstract 2nd flag and 3rd flag with no associations with the name might be the best solution in our case.

@asl
Copy link
Collaborator

asl commented Mar 27, 2024

@akiramenai @hedgar2017 @sayon Ok, let me assign this issue to you, so you will decide on the intended functionality :)

@akiramenai
Copy link
Collaborator

I think we can go as @sayon said. of was reverted from the backend, and I'm ok to keep the things as they are.

@akiramenai
Copy link
Collaborator

As no one objects, I think we can close the issue.

@atrosinenko
Copy link
Collaborator Author

As this needs to be actually updated in the code (just a few lines), reopening it and assigning to myself.

@atrosinenko
Copy link
Collaborator Author

@akiramenai Is "gt or lt" predicate still used (see encoding) and which name should it have?

@atrosinenko
Copy link
Collaborator Author

The last remaining question to clarify is: the spec on encoding mentions 8 predicates:

Definition encode_predicate (p:predicate) : BITS 3 :=
  # match p with
    | IfAlways ⇒ 0
    | IfGT ⇒ 1
    | IfLT ⇒ 2
    | IfEQ ⇒ 3
    | IfGE ⇒ 4
    | IfLE ⇒ 5
    | IfNotEQ ⇒ 6
    | IfGTOrLT ⇒ 7
    end
.

The asm parser understands 7 of them: 6 explicit .<code> suffixes and an implicit COND_NONE if neither suffix is specified. Other patches for code emission and disassembler assume 7 possible predicates, too. Is it correct that the last condition code, IfGTOrLT ⇒ 7, is not used anymore?

Reassigning the task - please feel free to close it if IfGTOrLT is actually unused or assign it back to me if this condition code has to be accounted for.

@akiramenai
Copy link
Collaborator

akiramenai commented May 5, 2024

@atrosinenko it looks like we mislead you wrt IfGTOrLT. It's only unused by current code generator, but we plan to keep on VM level. For now we can use gl mnemonic for it (or whatever name the current assembler accepts if it's more convenient), but we plan to rename our flags as it confuses even us internally. We are still discussing the final naming scheme.

@atrosinenko
Copy link
Collaborator Author

Added support of .gtlt predicate in #559.

@atrosinenko atrosinenko linked a pull request May 22, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants