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

Add V extension pseudoinstructions #111

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AFOliveira
Copy link

@AFOliveira AFOliveira commented Oct 25, 2024

Closes #110 .

Preview: riscv-asm.pdf

Copy link
Collaborator

@cmuellner cmuellner left a comment

Choose a reason for hiding this comment

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

This list is incomplete (e.g. vl1r.v/vl2r.v/vl4r/vl8r.v are missing).

To catch them all, either search for "Pseudoinstruction" in the specification or grep for INSN_ALIAS in Binutils.

Signed-off-by: Afonso Oliveira <[email protected]>
@AFOliveira
Copy link
Author

@cmuellner I added the ones you mentioned, but I couldn't really find many more.
I described them as "Equal to vl..." since any other description seemed like to long, but I can also change that if needed.

@AFOliveira
Copy link
Author

@cmuellner just a quick ping, is there anything else I should enhance in the PR?

@AFOliveira
Copy link
Author

👀 :)

|vmsgeu.vi vd, va, i, vm | vmsgtu.vi vd, va, i-1, vm | Vector >= Immediate, unsigned|
|vmsge.vv vd, va, vb, vm | vmsle.vv vd, vb, va, vm | Vector >= Vector|
|vmsgeu.vv vd, va, vb, vm | vmsleu.vv vd, vb, va, vm | Vector >= Vector, unsigned |
|vmsge.vx vd, va, x, vm | vmsle.vx vd, x, va, vm | Vector >= scalar|
Copy link
Contributor

@topperc topperc Nov 21, 2024

Choose a reason for hiding this comment

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

This is the not the correct expansion for vmsge.vx

From the spec.

Sequences to synthesize `vmsge{u}.vx` instruction
va >= x,  x > minimum
    addi t0, x, -1; vmsgt{u}.vx vd, va, t0, vm

unmasked va >= x
    pseudoinstruction: vmsge{u}.vx vd, va, x
    expansion: vmslt{u}.vx vd, va, x; vmnand.mm vd, vd, vd

masked va >= x, vd != v0
    pseudoinstruction: vmsge{u}.vx vd, va, x, v0.t
    expansion: vmslt{u}.vx vd, va, x, v0.t; vmxor.mm vd, vd, v0

masked va >= x, vd == v0
    pseudoinstruction: vmsge{u}.vx vd, va, x, v0.t, vt
    expansion: vmslt{u}.vx vt, va, x;  vmandn.mm vd, vd, vt

masked va >= x, any vd
  pseudoinstruction: vmsge{u}.vx vd, va, x, v0.t, vt
    expansion: vmslt{u}.vx vt, va, x;  vmandn.mm vt, v0, vt;  vmandn.mm vd, vd,
  v0;  vmor.mm vd, vt, vd
    The vt argument to the pseudoinstruction must name a temporary vector
  register that is
not same as vd and which will be clobbered by the pseudoinstruction

Copy link
Author

Choose a reason for hiding this comment

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

I'll fix it ASAP, thanks.

Copy link
Author

Choose a reason for hiding this comment

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

@topperc How can I define this different implementations and follow manual style? Shall I just do a * like in li?

Copy link
Contributor

Choose a reason for hiding this comment

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

There are 3 different pseudoinstructions there that should each have their own row

vmsge{u}.vx vd, va, x
vmsge{u}.vx vd, va, x, v0.t // add a note in the last column that vd can't be v0
vmsge{u}.vx vd, va, x, v0.t, vt // you can write the 4 instruction expansion and a note that 2 instructions aren't needed if vd==v0.

Copy link
Author

Choose a reason for hiding this comment

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

@topperc In the last commit I kept it exactly as described in the ISA Manual because I feel the 1:1 mapping is easier to understand, is this ok?

Signed-off-by: Afonso Oliveira <[email protected]>
|vl4r.v v4,x0 | vl4re8.v v4, x0 | Equal to vl4re8.v |
|vl8r.v v8,x0 | vl8re8.v v8, x0 | Equal to vl8re8.v |

|vmsge{u}.vx vd, va, x|
Copy link
Contributor

Choose a reason for hiding this comment

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

This form isn't implemented in the assembler because it's impossible to know if x>minimum without doing more analysis than an assembler is capable of.

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.

Missing pseudo-instructions?
3 participants