Skip to content

Commit

Permalink
8318953: RISC-V: Small refactoring for MacroAssembler::test_bit
Browse files Browse the repository at this point in the history
Reviewed-by: fyang
Backport-of: 988e1dfe6ec9b5e77d2e8a78eb792a127c6fe907
  • Loading branch information
zifeihan authored and RealFYang committed Nov 2, 2023
1 parent 594e5d7 commit 348a703
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/hotspot/cpu/riscv/macroAssembler_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4518,11 +4518,17 @@ void MacroAssembler::cmp_l2i(Register dst, Register src1, Register src2, Registe
bind(done);
}

void MacroAssembler::test_bit(Register Rd, Register Rs, uint32_t bit_pos, Register tmp) {
void MacroAssembler::test_bit(Register Rd, Register Rs, uint32_t bit_pos) {
assert(bit_pos < 64, "invalid bit range");
if (UseZbs) {
bexti(Rd, Rs, bit_pos);
return;
}
andi(Rd, Rs, 1UL << bit_pos, tmp);
int64_t imm = (int64_t)(1UL << bit_pos);
if (is_simm12(imm)) {
and_imm12(Rd, Rs, imm);
} else {
srli(Rd, Rs, bit_pos);
and_imm12(Rd, Rd, 1);
}
}
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/macroAssembler_riscv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ class MacroAssembler: public Assembler {
void shadd(Register Rd, Register Rs1, Register Rs2, Register tmp, int shamt);

// test single bit in Rs, result is set to Rd
void test_bit(Register Rd, Register Rs, uint32_t bit_pos, Register tmp = t0);
void test_bit(Register Rd, Register Rs, uint32_t bit_pos);

// Here the float instructions with safe deal with some exceptions.
// e.g. convert from NaN, +Inf, -Inf to int, float, double
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,7 @@ encode %{
if (DiagnoseSyncOnValueBasedClasses != 0) {
__ load_klass(flag, oop);
__ lwu(flag, Address(flag, Klass::access_flags_offset()));
__ test_bit(flag, flag, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS), tmp /* tmp */);
__ test_bit(flag, flag, exact_log2(JVM_ACC_IS_VALUE_BASED_CLASS));
__ bnez(flag, cont, true /* is_far */);
}

Expand Down

1 comment on commit 348a703

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.