-
Notifications
You must be signed in to change notification settings - Fork 69
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
Implement atomic instructions(A Standard Extension) #329
Conversation
CHECK_WRITE(RS1, TEMP1d, 4) | ||
movslq CKB_VM_ASM_ASM_CORE_MACHINE_OFFSET_MEMORY(MACHINE, RS1), TEMP1 | ||
WRITE_RD(TEMP1) | ||
add TEMP1, RS2r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a line in RISC-V's spec:
For RV64, 32-bit AMOs always sign-extend the value placed in rd, and ignore the upper 32 bits of the original value of rs2
Does this mean we need to clear the upper 32 bits of rs2
here for all AMO*.W
operations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After add TEMP1, RS2r
, we write the result to memory using the following statement:
mov RS2rd, CKB_VM_ASM_ASM_CORE_MACHINE_OFFSET_MEMORY(MACHINE, RS1)
It has no affects the final result whether or not the upper 32 bits of rs2 are cleared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 things:
- The spec requires
rd
to be sign-extended, which meansmov RS2rd
might not be correct here? - For
add
you are correct, this might end up in the same result, but what aboutMIN
/MAX
? Ignoring upper 32 bits or sign-extending can lead to different result, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mov RS2rd, CKB_VM_ASM_ASM_CORE_MACHINE_OFFSET_MEMORY(MACHINE, RS1)
moves RS2rd to memory, notrd
, and rd = sign_ext(memory[rs1])- Good question, I need to take a closer look.
One more thing: it seems the new issues we found here are not covered by |
Yes, I'm going to create some PRs to riscv-tests, but before that I will add tests for ckb-vm. |
ckb_vm::run
andexamples/ckb-vm-runner
adds ISA_A by default