Skip to content

Commit 8c87ea2

Browse files
committed
8346478: RISC-V: Refactor add/sub assembler routines
Reviewed-by: fjiang, rehn, gcao
1 parent 765b9e6 commit 8c87ea2

21 files changed

+413
-405
lines changed

src/hotspot/cpu/riscv/assembler_riscv.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,10 +2015,10 @@ enum Nf {
20152015
}
20162016

20172017
INSN(add_uw, 0b0111011, 0b000, 0b0000100);
2018-
INSN(rol, 0b0110011, 0b001, 0b0110000);
2019-
INSN(rolw, 0b0111011, 0b001, 0b0110000);
2020-
INSN(ror, 0b0110011, 0b101, 0b0110000);
2021-
INSN(rorw, 0b0111011, 0b101, 0b0110000);
2018+
INSN(rolr, 0b0110011, 0b001, 0b0110000);
2019+
INSN(rolrw, 0b0111011, 0b001, 0b0110000);
2020+
INSN(rorr, 0b0110011, 0b101, 0b0110000);
2021+
INSN(rorrw, 0b0111011, 0b101, 0b0110000);
20222022
INSN(sh1add, 0b0110011, 0b010, 0b0010000);
20232023
INSN(sh2add, 0b0110011, 0b100, 0b0010000);
20242024
INSN(sh3add, 0b0110011, 0b110, 0b0010000);

src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void LIR_Assembler::arraycopy_type_check(Register src, Register src_pos, Registe
211211
Label cont, slow;
212212

213213
#define PUSH(r1, r2) \
214-
__ addi(sp, sp, -2 * wordSize); \
214+
__ subi(sp, sp, 2 * wordSize); \
215215
__ sd(r1, Address(sp, 1 * wordSize)); \
216216
__ sd(r2, Address(sp, 0));
217217

@@ -337,10 +337,10 @@ void LIR_Assembler::arraycopy_prepare_params(Register src, Register src_pos, Reg
337337
Register dst, Register dst_pos, BasicType basic_type) {
338338
int scale = array_element_size(basic_type);
339339
__ shadd(c_rarg0, src_pos, src, t0, scale);
340-
__ add(c_rarg0, c_rarg0, arrayOopDesc::base_offset_in_bytes(basic_type));
340+
__ addi(c_rarg0, c_rarg0, arrayOopDesc::base_offset_in_bytes(basic_type));
341341
assert_different_registers(c_rarg0, dst, dst_pos, length);
342342
__ shadd(c_rarg1, dst_pos, dst, t0, scale);
343-
__ add(c_rarg1, c_rarg1, arrayOopDesc::base_offset_in_bytes(basic_type));
343+
__ addi(c_rarg1, c_rarg1, arrayOopDesc::base_offset_in_bytes(basic_type));
344344
assert_different_registers(c_rarg1, dst, length);
345345
__ mv(c_rarg2, length);
346346
assert_different_registers(c_rarg2, dst);

src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ void LIR_Assembler::typecheck_helper_slowcheck(ciKlass *k, Register obj, Registe
10841084
// check for self
10851085
__ beq(klass_RInfo, k_RInfo, *success_target);
10861086

1087-
__ addi(sp, sp, -2 * wordSize); // 2: store k_RInfo and klass_RInfo
1087+
__ subi(sp, sp, 2 * wordSize); // 2: store k_RInfo and klass_RInfo
10881088
__ sd(k_RInfo, Address(sp, 0)); // sub klass
10891089
__ sd(klass_RInfo, Address(sp, wordSize)); // super klass
10901090
__ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id)));
@@ -1099,7 +1099,7 @@ void LIR_Assembler::typecheck_helper_slowcheck(ciKlass *k, Register obj, Registe
10991099
// perform the fast part of the checking logic
11001100
__ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, nullptr);
11011101
// call out-of-line instance of __ check_klass_subtytpe_slow_path(...)
1102-
__ addi(sp, sp, -2 * wordSize); // 2: store k_RInfo and klass_RInfo
1102+
__ subi(sp, sp, 2 * wordSize); // 2: store k_RInfo and klass_RInfo
11031103
__ sd(klass_RInfo, Address(sp, wordSize)); // sub klass
11041104
__ sd(k_RInfo, Address(sp, 0)); // super klass
11051105
__ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id)));
@@ -2139,7 +2139,7 @@ void LIR_Assembler::lir_store_slowcheck(Register k_RInfo, Register klass_RInfo,
21392139
// perform the fast part of the checking logic
21402140
__ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, success_target, failure_target, nullptr);
21412141
// call out-of-line instance of __ check_klass_subtype_slow_path(...)
2142-
__ addi(sp, sp, -2 * wordSize); // 2: store k_RInfo and klass_RInfo
2142+
__ subi(sp, sp, 2 * wordSize); // 2: store k_RInfo and klass_RInfo
21432143
__ sd(klass_RInfo, Address(sp, wordSize)); // sub klass
21442144
__ sd(k_RInfo, Address(sp, 0)); // super klass
21452145
__ far_call(RuntimeAddress(Runtime1::entry_for(C1StubId::slow_subtype_check_id)));

src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,16 @@ void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int
199199
Label done;
200200

201201
// len_in_bytes is positive and ptr sized
202-
sub(len_in_bytes, len_in_bytes, hdr_size_in_bytes);
202+
subi(len_in_bytes, len_in_bytes, hdr_size_in_bytes);
203203
beqz(len_in_bytes, done);
204204

205205
// Preserve obj
206206
if (hdr_size_in_bytes) {
207-
add(obj, obj, hdr_size_in_bytes);
207+
addi(obj, obj, hdr_size_in_bytes);
208208
}
209209
zero_memory(obj, len_in_bytes, tmp);
210210
if (hdr_size_in_bytes) {
211-
sub(obj, obj, hdr_size_in_bytes);
211+
subi(obj, obj, hdr_size_in_bytes);
212212
}
213213

214214
bind(done);
@@ -262,7 +262,7 @@ void C1_MacroAssembler::initialize_object(Register obj, Register klass, Register
262262
j(entry_point);
263263

264264
bind(loop);
265-
sub(index, index, 1);
265+
subi(index, index, 1);
266266
for (int i = -unroll; i < 0; i++) {
267267
if (-i == remainder) {
268268
bind(entry_point);
@@ -272,7 +272,7 @@ void C1_MacroAssembler::initialize_object(Register obj, Register klass, Register
272272
if (remainder == 0) {
273273
bind(entry_point);
274274
}
275-
add(t0, t0, unroll * wordSize);
275+
addi(t0, t0, unroll * wordSize);
276276
bnez(index, loop);
277277
}
278278
}

src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ int StubAssembler::call_RT(Register oop_result, Register metadata_result, addres
147147
const int arg1_sp_offset = 0;
148148
const int arg2_sp_offset = 1;
149149
const int arg3_sp_offset = 2;
150-
addi(sp, sp, -(arg_num + 1) * wordSize);
150+
subi(sp, sp, (arg_num + 1) * wordSize);
151151
sd(arg1, Address(sp, arg1_sp_offset * wordSize));
152152
sd(arg2, Address(sp, arg2_sp_offset * wordSize));
153153
sd(arg3, Address(sp, arg3_sp_offset * wordSize));
@@ -301,14 +301,14 @@ static OopMap* save_live_registers(StubAssembler* sasm,
301301

302302
if (save_fpu_registers) {
303303
// float registers
304-
__ addi(sp, sp, -(FrameMap::nof_fpu_regs * wordSize));
304+
__ subi(sp, sp, FrameMap::nof_fpu_regs * wordSize);
305305
for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
306306
__ fsd(as_FloatRegister(i), Address(sp, i * wordSize));
307307
}
308308
} else {
309309
// we define reg_save_layout = 62 as the fixed frame size,
310310
// we should also sub 32 * wordSize to sp when save_fpu_registers == false
311-
__ addi(sp, sp, -32 * wordSize);
311+
__ subi(sp, sp, 32 * wordSize);
312312
}
313313

314314
return generate_oop_map(sasm, save_fpu_registers);
@@ -543,7 +543,7 @@ void Runtime1::generate_unwind_exception(StubAssembler *sasm) {
543543
// Save our return address because
544544
// exception_handler_for_return_address will destroy it. We also
545545
// save exception_oop
546-
__ addi(sp, sp, -2 * wordSize);
546+
__ subi(sp, sp, 2 * wordSize);
547547
__ sd(exception_oop, Address(sp, wordSize));
548548
__ sd(ra, Address(sp));
549549

0 commit comments

Comments
 (0)