-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Winch: implement rmw add ops #9990
Winch: implement rmw add ops #9990
Conversation
Subscribe to Label Action
This issue or pull request has been labeled: "winch"
Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
I can take this review. |
028a95e
to
a5e07de
Compare
winch/codegen/src/visitor.rs
Outdated
&arg, | ||
RmwOp::Add, | ||
OperandSize::S16, | ||
Some(ExtendKind::I32Extend16S), |
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.
The extension kinds used in this case are signed, however the spec states zero extension instead. I believe we need to augment ExtendKind
to account for the missing unsigned extensions.
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.
that's because https://github.com/bytecodealliance/wasmtime/blob/main/winch/codegen/src/isa/x64/asm.rs#L395-L401 takes ExtendKind
, even though movzx
zero-extend. I can do that in a followup, if that's ok? i'll add variants for unsigned conversions, and update any affected code.
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've extended ExtendKind
here #10012 to include unsigned extends.
winch/codegen/src/codegen/mod.rs
Outdated
@@ -1295,6 +1295,31 @@ where | |||
|
|||
Ok(()) | |||
} | |||
|
|||
pub(crate) fn atomic_rmw( |
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.
pub(crate) fn atomic_rmw( | |
pub(crate) fn emit_atomic_rmw( |
a5556ed
to
6507f0c
Compare
winch/codegen/src/codegen/mod.rs
Outdated
extend: Option<ExtendKind>, | ||
) -> Result<()> { | ||
let operand = self.context.pop_to_reg(self.masm, None).unwrap(); | ||
if let Some(addr) = self.emit_compute_heap_address(arg, size)? { |
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.
Just a note that this will require a rebase once #9987 lands and use emit_compute_heap_address_align_checked
@saulecabrera I'll do all the rebases once #9987 is in |
6507f0c
to
794a14c
Compare
ea19990
to
53d2d25
Compare
@saulecabrera rebase is done. I have also added a check to ensure that only valid extends are passed to |
winch/codegen/src/isa/x64/masm.rs
Outdated
// It is only necessary to zero-extend when the operand is less than 32bits. | ||
// x64 automatically zero-extend 32bits to 64bit. | ||
Some( | ||
extend @ (ExtendKind::I32Extend8S | ||
| ExtendKind::I64Extend8S | ||
| ExtendKind::I64Extend16S | ||
| ExtendKind::I32Extend16S), | ||
) => { |
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 believe the check here needs updating? The code is emitting a zero extend but matching against a signed extend? Also I believe that to: (i) reduce duplication and (ii) avoid affecting compile time performance, we can entirely remove this check, since Cranelift's emission layer already takes care of it https://github.com/bytecodealliance/wasmtime/blob/main/cranelift/codegen/src/isa/x64/inst/emit.rs#L973.
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.
good catch i'll remove it
5ef91f7
to
402d54b
Compare
impl read-modify-write add for winch:
i32.atomic.rmw8.add_u
i32.atomic.rmw16.add_u
i32.atomic.rmw.add
i64.atomic.rmw8.add_u
i64.atomic.rmw16.add_u
i64.atomic.rmw32.add_u
i64.atomic.rmw.add
#9734