Skip to content

Commit 43e191d

Browse files
committed
8293524: RISC-V: Use macro-assembler functions as appropriate
Reviewed-by: shade, fjiang
1 parent 14eb5ad commit 43e191d

13 files changed

+78
-78
lines changed

src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ void LIR_Assembler::arraycopy_simple_check(Register src, Register src_pos, Regis
9595
if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) {
9696
__ load_klass(tmp, dst);
9797
__ lw(t0, Address(tmp, in_bytes(Klass::layout_helper_offset())));
98-
__ li(t1, Klass::_lh_neutral_value);
98+
__ mv(t1, Klass::_lh_neutral_value);
9999
__ bge(t0, t1, *stub->entry(), /* is_far */ true);
100100
}
101101

102102
if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) {
103103
__ load_klass(tmp, src);
104104
__ lw(t0, Address(tmp, in_bytes(Klass::layout_helper_offset())));
105-
__ li(t1, Klass::_lh_neutral_value);
105+
__ mv(t1, Klass::_lh_neutral_value);
106106
__ bge(t0, t1, *stub->entry(), /* is_far */ true);
107107
}
108108
}

src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ void LIR_Assembler::type_profile_helper(Register mdo, ciMethodData *md, ciProfil
10691069
__ ld(t1, recv_addr);
10701070
__ bnez(t1, next_test);
10711071
__ sd(recv, recv_addr);
1072-
__ li(t1, DataLayout::counter_increment);
1072+
__ mv(t1, DataLayout::counter_increment);
10731073
__ sd(t1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))));
10741074
__ j(*update_done);
10751075
__ bind(next_test);
@@ -1634,7 +1634,7 @@ void LIR_Assembler::check_conflict(ciKlass* exact_klass, intptr_t current_klass,
16341634

16351635
if (TypeEntries::is_type_none(current_klass)) {
16361636
__ beqz(t1, none);
1637-
__ li(t0, (u1)TypeEntries::null_seen);
1637+
__ mv(t0, (u1)TypeEntries::null_seen);
16381638
__ beq(t0, t1, none);
16391639
// There is a chance that the checks above (re-reading profiling
16401640
// data from memory) fail if another thread has just set the
@@ -1684,7 +1684,7 @@ void LIR_Assembler::check_no_conflict(ciKlass* exact_klass, intptr_t current_kla
16841684
Label ok;
16851685
__ ld(t0, mdo_addr);
16861686
__ beqz(t0, ok);
1687-
__ li(t1, (u1)TypeEntries::null_seen);
1687+
__ mv(t1, (u1)TypeEntries::null_seen);
16881688
__ beq(t0, t1, ok);
16891689
// may have been set by another thread
16901690
__ membar(MacroAssembler::LoadLoad);
@@ -2250,7 +2250,7 @@ void LIR_Assembler::store_parameter(jint c, int offset_from_rsp_in_words) {
22502250
assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp");
22512251
int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord;
22522252
assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset");
2253-
__ li(t0, c);
2253+
__ mv(t0, c);
22542254
__ sd(t0, Address(sp, offset_from_rsp_in_bytes));
22552255
}
22562256

src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
9797
// assuming both the stack pointer and page_size have their least
9898
// significant 2 bits cleared and page_size is a power of 2
9999
sub(hdr, hdr, sp);
100-
li(t0, aligned_mask - os::vm_page_size());
100+
mv(t0, aligned_mask - os::vm_page_size());
101101
andr(hdr, hdr, t0);
102102
// for recursive locking, the result is zero => save it in the displaced header
103103
// location (NULL in the displaced hdr location indicates recursive locking)

src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
861861
__ check_klass_subtype_slow_path(x14, x10, x12, x15, NULL, &miss);
862862

863863
// fallthrough on success:
864-
__ li(t0, 1);
864+
__ mv(t0, 1);
865865
__ sd(t0, Address(sp, (result_off) * VMRegImpl::stack_slot_size)); // result
866866
__ pop_reg(RegSet::of(x10, x12, x14, x15), sp);
867867
__ ret();
@@ -1051,7 +1051,7 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
10511051
default:
10521052
{
10531053
StubFrame f(sasm, "unimplemented entry", dont_gc_arguments, does_not_return);
1054-
__ li(x10, (int) id);
1054+
__ mv(x10, (int)id);
10551055
__ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), x10);
10561056
__ should_not_reach_here();
10571057
}

src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2,
845845
bind(L);
846846

847847
// A very short string
848-
li(t0, minCharsInWord);
848+
mv(t0, minCharsInWord);
849849
ble(cnt2, t0, SHORT_STRING);
850850

851851
// Compare longwords
@@ -856,7 +856,7 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2,
856856
ld(tmp1, Address(str1));
857857
beq(str1, str2, DONE);
858858
ld(tmp2, Address(str2));
859-
li(t0, STUB_THRESHOLD);
859+
mv(t0, STUB_THRESHOLD);
860860
bge(cnt2, t0, STUB);
861861
sub(cnt2, cnt2, minCharsInWord);
862862
beqz(cnt2, TAIL_CHECK);
@@ -870,7 +870,7 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2,
870870
} else if (isLU) { // LU case
871871
lwu(tmp1, Address(str1));
872872
ld(tmp2, Address(str2));
873-
li(t0, STUB_THRESHOLD);
873+
mv(t0, STUB_THRESHOLD);
874874
bge(cnt2, t0, STUB);
875875
addi(cnt2, cnt2, -4);
876876
add(str1, str1, cnt2);
@@ -884,7 +884,7 @@ void C2_MacroAssembler::string_compare(Register str1, Register str2,
884884
} else { // UL case
885885
ld(tmp1, Address(str1));
886886
lwu(tmp2, Address(str2));
887-
li(t0, STUB_THRESHOLD);
887+
mv(t0, STUB_THRESHOLD);
888888
bge(cnt2, t0, STUB);
889889
addi(cnt2, cnt2, -4);
890890
slli(t0, cnt2, 1);
@@ -1060,7 +1060,7 @@ void C2_MacroAssembler::arrays_equals(Register a1, Register a2, Register tmp3,
10601060

10611061
assert(elem_size == 1 || elem_size == 2, "must be char or byte");
10621062
assert_different_registers(a1, a2, result, cnt1, t0, t1, tmp3, tmp4, tmp5, tmp6);
1063-
li(elem_per_word, wordSize / elem_size);
1063+
mv(elem_per_word, wordSize / elem_size);
10641064

10651065
BLOCK_COMMENT("arrays_equals {");
10661066

src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ void ShenandoahBarrierSetAssembler::cmpxchg_oop(MacroAssembler* masm,
522522
if (is_cae) {
523523
__ mv(result, expected);
524524
} else {
525-
__ addi(result, zr, 1);
525+
__ mv(result, 1);
526526
}
527527
__ j(done);
528528

src/hotspot/cpu/riscv/interp_masm_riscv.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ void InterpreterMacroAssembler::dispatch_base(TosState state,
524524
bnez(t1, safepoint);
525525
}
526526
if (table == Interpreter::dispatch_table(state)) {
527-
li(t1, Interpreter::distance_from_dispatch_table(state));
527+
mv(t1, Interpreter::distance_from_dispatch_table(state));
528528
add(t1, Rs, t1);
529529
shadd(t1, t1, xdispatch, t1, 3);
530530
} else {
@@ -828,7 +828,7 @@ void InterpreterMacroAssembler::lock_object(Register lock_reg)
828828
// least significant 3 bits clear.
829829
// NOTE: the oopMark is in swap_reg x10 as the result of cmpxchg
830830
sub(swap_reg, swap_reg, sp);
831-
li(t0, (int64_t)(7 - os::vm_page_size()));
831+
mv(t0, (int64_t)(7 - os::vm_page_size()));
832832
andr(swap_reg, swap_reg, t0);
833833

834834
// Save the test result, for recursive case, the result is zero
@@ -1666,7 +1666,7 @@ void InterpreterMacroAssembler::profile_obj_type(Register obj, const Address& md
16661666

16671667
ld(t0, mdo_addr);
16681668
beqz(t0, none);
1669-
li(tmp, (u1)TypeEntries::null_seen);
1669+
mv(tmp, (u1)TypeEntries::null_seen);
16701670
beq(t0, tmp, none);
16711671
// There is a chance that the checks above (re-reading profiling
16721672
// data from memory) fail if another thread has just set the
@@ -1701,10 +1701,10 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca
17011701

17021702
lbu(t0, Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start));
17031703
if (is_virtual) {
1704-
li(tmp, (u1)DataLayout::virtual_call_type_data_tag);
1704+
mv(tmp, (u1)DataLayout::virtual_call_type_data_tag);
17051705
bne(t0, tmp, profile_continue);
17061706
} else {
1707-
li(tmp, (u1)DataLayout::call_type_data_tag);
1707+
mv(tmp, (u1)DataLayout::call_type_data_tag);
17081708
bne(t0, tmp, profile_continue);
17091709
}
17101710

@@ -1734,15 +1734,15 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca
17341734
mv(index, zr); // index < TypeProfileArgsLimit
17351735
bind(loop);
17361736
bgtz(index, profileReturnType);
1737-
li(t0, (int)MethodData::profile_return());
1737+
mv(t0, (int)MethodData::profile_return());
17381738
beqz(t0, profileArgument); // (index > 0 || MethodData::profile_return()) == false
17391739
bind(profileReturnType);
17401740
// If return value type is profiled we may have no argument to profile
17411741
ld(tmp, Address(mdp, in_bytes(TypeEntriesAtCall::cell_count_offset())));
17421742
mv(t1, - TypeStackSlotEntries::per_arg_count());
17431743
mul(t1, index, t1);
17441744
add(tmp, tmp, t1);
1745-
li(t1, TypeStackSlotEntries::per_arg_count());
1745+
mv(t1, TypeStackSlotEntries::per_arg_count());
17461746
add(t0, mdp, off_to_args);
17471747
blt(tmp, t1, done);
17481748

@@ -1753,8 +1753,8 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca
17531753
// stack offset o (zero based) from the start of the argument
17541754
// list, for n arguments translates into offset n - o - 1 from
17551755
// the end of the argument list
1756-
li(t0, stack_slot_offset0);
1757-
li(t1, slot_step);
1756+
mv(t0, stack_slot_offset0);
1757+
mv(t1, slot_step);
17581758
mul(t1, index, t1);
17591759
add(t0, t0, t1);
17601760
add(t0, mdp, t0);
@@ -1764,8 +1764,8 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca
17641764
Address arg_addr = argument_address(tmp);
17651765
ld(tmp, arg_addr);
17661766

1767-
li(t0, argument_type_offset0);
1768-
li(t1, type_step);
1767+
mv(t0, argument_type_offset0);
1768+
mv(t1, type_step);
17691769
mul(t1, index, t1);
17701770
add(t0, t0, t1);
17711771
add(mdo_addr, mdp, t0);
@@ -1777,7 +1777,7 @@ void InterpreterMacroAssembler::profile_arguments_type(Register mdp, Register ca
17771777

17781778
// increment index by 1
17791779
addi(index, index, 1);
1780-
li(t1, TypeProfileArgsLimit);
1780+
mv(t1, TypeProfileArgsLimit);
17811781
blt(index, t1, loop);
17821782
bind(loopEnd);
17831783

@@ -1832,13 +1832,13 @@ void InterpreterMacroAssembler::profile_return_type(Register mdp, Register ret,
18321832
// length
18331833
Label do_profile;
18341834
lbu(t0, Address(xbcp, 0));
1835-
li(tmp, (u1)Bytecodes::_invokedynamic);
1835+
mv(tmp, (u1)Bytecodes::_invokedynamic);
18361836
beq(t0, tmp, do_profile);
1837-
li(tmp, (u1)Bytecodes::_invokehandle);
1837+
mv(tmp, (u1)Bytecodes::_invokehandle);
18381838
beq(t0, tmp, do_profile);
18391839
get_method(tmp);
18401840
lhu(t0, Address(tmp, Method::intrinsic_id_offset_in_bytes()));
1841-
li(t1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
1841+
mv(t1, static_cast<int>(vmIntrinsics::_compiledLambdaForm));
18421842
bne(t0, t1, profile_continue);
18431843
bind(do_profile);
18441844
}

0 commit comments

Comments
 (0)