-
Notifications
You must be signed in to change notification settings - Fork 1.2k
WASM: Implement new Sign Extend operators #3741
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
Conversation
Changed -WasmSignExtend2 to -WasmSignExtends
Fixed the cse case and added tests, ready to review |
lib/Backend/IRBuilderAsmJs.cpp
Outdated
case Js::OpCodeAsmJs::I32Extend16_s: signExtendFromType = TyInt16; goto make_sign_extend; | ||
make_sign_extend: | ||
// Src2 is a dummy source, used only to carry the type to cast from | ||
instr = IR::Instr::New(Js::OpCode::Conv_Prim, dstOpnd, srcOpnd, IR::IntConstOpnd::New(signExtendFromType, signExtendFromType, m_func), m_func); |
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.
this really needs a comment for why the int value is the type
lib/Backend/amd64/LowererMDArch.cpp
Outdated
} | ||
|
||
IR::RegOpnd * tempReg = IR::RegOpnd::New(fromType, this->m_func); | ||
instr->InsertBefore(IR::Instr::New(Js::OpCode::MOV_TRUNC, tempReg, src1, m_func)); |
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.
why do you need this?
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.
Initially, I thought we needed to explicitly zero out the upper bits of the register, but MOVSX, takes care of setting the bits, so it is not actually needed.
lib/Backend/i386/LowererMDArch.cpp
Outdated
Js::OpCode op = Js::OpCode::MOVSX; | ||
if (src2->GetSize() == 2) | ||
{ | ||
op = Js::OpCode::MOVSXW; |
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.
should assert else size == 1 (I guess you can't do that directly since it could be size == 4 and op isn't used, but something along those lines should be included)
const tests = [ | ||
makeCSETest("i32", "extend8_s" , null, [0xFF, 1, 0x1FF]), | ||
makeCSETest("i32", "extend16_s", null, [0xFF, 1, 0xFFFF, 0x1FFFF]), | ||
makeCSETest("i64", "extend8_s" , null, [0xFF, 1, 0x1FF]), |
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.
nice. very exhaustive :)
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.
32c49a6
to
3d0ad02
Compare
Merge pull request #3741 from Cellule:wasm/signextend2 Implement new operators as describe in https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#new-sign-extending-operators
Implement new operators as describe in
https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#new-sign-extending-operators
This change is