1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:37:45 +00:00

LibJS/JIT: Add a builtin for Math.abs

This commit is contained in:
Simon Wanner 2023-11-17 11:56:40 +01:00 committed by Andreas Kling
parent 86b85aa68b
commit 6c8ab1ca0d
4 changed files with 58 additions and 3 deletions

View file

@ -582,6 +582,15 @@ struct X86_64Assembler {
emit_modrm_slash(0, dst);
}
void mov_if(Condition condition, Operand dst, Operand src)
{
VERIFY(dst.type == Operand::Type::Reg && src.type == Operand::Type::Reg);
emit_rex_for_rm(dst, src, REX_W::Yes);
emit8(0x0f);
emit8(0x40 | to_underlying(condition));
emit_modrm_rm(dst, src);
}
void sign_extend_32_to_64_bits(Reg reg)
{
mov32(Operand::Register(reg), Operand::Register(reg), Extension::SignExtend);
@ -989,6 +998,14 @@ struct X86_64Assembler {
}
}
void neg32(Operand reg)
{
VERIFY(reg.type == Operand::Type::Reg);
emit_rex_for_slash(reg, REX_W::No);
emit8(0xf7);
emit_modrm_slash(3, reg);
}
void convert_i32_to_double(Operand dst, Operand src)
{
VERIFY(dst.type == Operand::Type::FReg);