Commit 0ca7f580 authored by Lu Yahan's avatar Lu Yahan Committed by V8 LUCI CQ

[riscv64] Use shift register when shift amount is too large

Change-Id: Ib68766bf88624bfdad272680ce9e1180d241adf0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3556927Reviewed-by: 's avatarji qiu <qiuji@iscas.ac.cn>
Commit-Queue: Yahan Lu <yahan@iscas.ac.cn>
Auto-Submit: Yahan Lu <yahan@iscas.ac.cn>
Cr-Commit-Position: refs/heads/main@{#79664}
parent 4fbe8408
...@@ -1300,23 +1300,41 @@ I64_BINOP_I(xor, Xor) ...@@ -1300,23 +1300,41 @@ I64_BINOP_I(xor, Xor)
LiftoffRegister dst, LiftoffRegister src, Register amount) { \ LiftoffRegister dst, LiftoffRegister src, Register amount) { \
instruction(dst.gp(), src.gp(), amount); \ instruction(dst.gp(), src.gp(), amount); \
} }
#define I64_SHIFTOP_I(name, instruction) \
void LiftoffAssembler::emit_i64_##name##i(LiftoffRegister dst, \
LiftoffRegister src, int amount) { \
DCHECK(is_uint6(amount)); \
instruction(dst.gp(), src.gp(), amount); \
}
I64_SHIFTOP(shl, sll) I64_SHIFTOP(shl, sll)
I64_SHIFTOP(sar, sra) I64_SHIFTOP(sar, sra)
I64_SHIFTOP(shr, srl) I64_SHIFTOP(shr, srl)
#undef I64_SHIFTOP
I64_SHIFTOP_I(shl, slli) void LiftoffAssembler::emit_i64_shli(LiftoffRegister dst, LiftoffRegister src,
I64_SHIFTOP_I(sar, srai) int amount) {
I64_SHIFTOP_I(shr, srli) if (is_uint6(amount)) {
slli(dst.gp(), src.gp(), amount);
} else {
li(kScratchReg, amount);
sll(dst.gp(), src.gp(), kScratchReg);
}
}
#undef I64_SHIFTOP void LiftoffAssembler::emit_i64_sari(LiftoffRegister dst, LiftoffRegister src,
#undef I64_SHIFTOP_I int amount) {
if (is_uint6(amount)) {
srai(dst.gp(), src.gp(), amount);
} else {
li(kScratchReg, amount);
sra(dst.gp(), src.gp(), kScratchReg);
}
}
void LiftoffAssembler::emit_i64_shri(LiftoffRegister dst, LiftoffRegister src,
int amount) {
if (is_uint6(amount)) {
srli(dst.gp(), src.gp(), amount);
} else {
li(kScratchReg, amount);
srl(dst.gp(), src.gp(), kScratchReg);
}
}
void LiftoffAssembler::emit_i64_addi(LiftoffRegister dst, LiftoffRegister lhs, void LiftoffAssembler::emit_i64_addi(LiftoffRegister dst, LiftoffRegister lhs,
int64_t imm) { int64_t imm) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment