11/*
22 * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
33 * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
4- * Copyright (c) 2020, 2021 , Huawei Technologies Co., Ltd. All rights reserved.
4+ * Copyright (c) 2020, 2022 , Huawei Technologies Co., Ltd. All rights reserved.
55 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
66 *
77 * This code is free software; you can redistribute it and/or modify it
@@ -3121,11 +3121,16 @@ void MacroAssembler::cadc(Register dst, Register src1, Register src2, Register c
31213121}
31223122
31233123// rotate right with shift bits
3124- void MacroAssembler::ror (Register dst, Register src, uint32_t shift, Register tmp)
3124+ void MacroAssembler::ror_imm (Register dst, Register src, uint32_t shift, Register tmp)
31253125{
3126+ if (UseRVB) {
3127+ rori (dst, src, shift);
3128+ return ;
3129+ }
3130+
31263131 assert_different_registers (dst, tmp);
31273132 assert_different_registers (src, tmp);
3128- assert (shift <= 64 , " shift amount must be <= 64" );
3133+ assert (shift < 64 , " shift amount must be < 64" );
31293134 slli (tmp, src, 64 - shift);
31303135 srli (dst, src, shift);
31313136 orr (dst, dst, tmp);
@@ -3207,7 +3212,7 @@ void MacroAssembler::multiply_64_x_64_loop(Register x, Register xstart, Register
32073212 slli (t0, xstart, LogBytesPerInt);
32083213 add (t0, x, t0);
32093214 ld (x_xstart, Address (t0, 0 ));
3210- ror (x_xstart, x_xstart, 32 ); // convert big-endian to little-endian
3215+ ror_imm (x_xstart, x_xstart, 32 ); // convert big-endian to little-endian
32113216
32123217 bind (L_first_loop);
32133218 subw (idx, idx, 1 );
@@ -3218,7 +3223,7 @@ void MacroAssembler::multiply_64_x_64_loop(Register x, Register xstart, Register
32183223 slli (t0, idx, LogBytesPerInt);
32193224 add (t0, y, t0);
32203225 ld (y_idx, Address (t0, 0 ));
3221- ror (y_idx, y_idx, 32 ); // convert big-endian to little-endian
3226+ ror_imm (y_idx, y_idx, 32 ); // convert big-endian to little-endian
32223227 bind (L_multiply);
32233228
32243229 mulhu (t0, x_xstart, y_idx);
@@ -3227,7 +3232,7 @@ void MacroAssembler::multiply_64_x_64_loop(Register x, Register xstart, Register
32273232 adc (carry, t0, zr, t1);
32283233
32293234 subw (kdx, kdx, 2 );
3230- ror (product, product, 32 ); // back to big-endian
3235+ ror_imm (product, product, 32 ); // back to big-endian
32313236 slli (t0, kdx, LogBytesPerInt);
32323237 add (t0, z, t0);
32333238 sd (product, Address (t0, 0 ));
@@ -3292,17 +3297,17 @@ void MacroAssembler::multiply_128_x_128_loop(Register y, Register z,
32923297 slli (t0, idx, LogBytesPerInt);
32933298 add (tmp6, z, t0);
32943299
3295- ror (yz_idx1, yz_idx1, 32 ); // convert big-endian to little-endian
3296- ror (yz_idx2, yz_idx2, 32 );
3300+ ror_imm (yz_idx1, yz_idx1, 32 ); // convert big-endian to little-endian
3301+ ror_imm (yz_idx2, yz_idx2, 32 );
32973302
32983303 ld (t1, Address (tmp6, 0 ));
32993304 ld (t0, Address (tmp6, wordSize));
33003305
33013306 mul (tmp3, product_hi, yz_idx1); // yz_idx1 * product_hi -> tmp4:tmp3
33023307 mulhu (tmp4, product_hi, yz_idx1);
33033308
3304- ror (t0, t0, 32 , tmp); // convert big-endian to little-endian
3305- ror (t1, t1, 32 , tmp);
3309+ ror_imm (t0, t0, 32 , tmp); // convert big-endian to little-endian
3310+ ror_imm (t1, t1, 32 , tmp);
33063311
33073312 mul (tmp, product_hi, yz_idx2); // yz_idx2 * product_hi -> carry2:tmp
33083313 mulhu (carry2, product_hi, yz_idx2);
@@ -3315,8 +3320,8 @@ void MacroAssembler::multiply_128_x_128_loop(Register y, Register z,
33153320 cad (tmp4, tmp4, t1, carry2);
33163321 adc (carry, carry, zr, carry2);
33173322
3318- ror (tmp3, tmp3, 32 ); // convert little-endian to big-endian
3319- ror (tmp4, tmp4, 32 );
3323+ ror_imm (tmp3, tmp3, 32 ); // convert little-endian to big-endian
3324+ ror_imm (tmp4, tmp4, 32 );
33203325 sd (tmp4, Address (tmp6, 0 ));
33213326 sd (tmp3, Address (tmp6, wordSize));
33223327
@@ -3334,19 +3339,19 @@ void MacroAssembler::multiply_128_x_128_loop(Register y, Register z,
33343339 slli (t0, idx, LogBytesPerInt);
33353340 add (t0, y, t0);
33363341 ld (yz_idx1, Address (t0, 0 ));
3337- ror (yz_idx1, yz_idx1, 32 );
3342+ ror_imm (yz_idx1, yz_idx1, 32 );
33383343
33393344 mul (tmp3, product_hi, yz_idx1); // yz_idx1 * product_hi -> tmp4:tmp3
33403345 mulhu (tmp4, product_hi, yz_idx1);
33413346
33423347 slli (t0, idx, LogBytesPerInt);
33433348 add (t0, z, t0);
33443349 ld (yz_idx2, Address (t0, 0 ));
3345- ror (yz_idx2, yz_idx2, 32 , tmp);
3350+ ror_imm (yz_idx2, yz_idx2, 32 , tmp);
33463351
33473352 add2_with_carry (carry, tmp4, tmp3, carry, yz_idx2, tmp);
33483353
3349- ror (tmp3, tmp3, 32 , tmp);
3354+ ror_imm (tmp3, tmp3, 32 , tmp);
33503355 sd (tmp3, Address (t0, 0 ));
33513356
33523357 bind (L_check_1);
@@ -3532,7 +3537,7 @@ void MacroAssembler::multiply_to_len(Register x, Register xlen, Register y, Regi
35323537 slli (t0, xstart, LogBytesPerInt);
35333538 add (t0, x, t0);
35343539 ld (product_hi, Address (t0, 0 ));
3535- ror (product_hi, product_hi, 32 ); // convert big-endian to little-endian
3540+ ror_imm (product_hi, product_hi, 32 ); // convert big-endian to little-endian
35363541
35373542 Label L_third_loop_prologue;
35383543 bind (L_third_loop_prologue);
0 commit comments