Skip to content

Commit 2a6ff15

Browse files
committed
Move RVC code to the proper location after rebasing (#42)
1 parent 6ffb88c commit 2a6ff15

File tree

1 file changed

+76
-81
lines changed

1 file changed

+76
-81
lines changed

src/hotspot/cpu/riscv/assembler_riscv.hpp

+76-81
Original file line numberDiff line numberDiff line change
@@ -2007,76 +2007,24 @@ enum Nf {
20072007

20082008
#undef INSN
20092009

2010-
void bgt(Register Rs, Register Rt, const address &dest);
2011-
void ble(Register Rs, Register Rt, const address &dest);
2012-
void bgtu(Register Rs, Register Rt, const address &dest);
2013-
void bleu(Register Rs, Register Rt, const address &dest);
2014-
void bgt(Register Rs, Register Rt, Label &l, bool is_far = false);
2015-
void ble(Register Rs, Register Rt, Label &l, bool is_far = false);
2016-
void bgtu(Register Rs, Register Rt, Label &l, bool is_far = false);
2017-
void bleu(Register Rs, Register Rt, Label &l, bool is_far = false);
2018-
2019-
typedef void (Assembler::* jal_jalr_insn)(Register Rt, address dest);
2020-
typedef void (Assembler::* load_insn_by_temp)(Register Rt, address dest, Register temp);
2021-
typedef void (Assembler::* compare_and_branch_insn)(Register Rs1, Register Rs2, const address dest);
2022-
typedef void (Assembler::* compare_and_branch_label_insn)(Register Rs1, Register Rs2, Label &L, bool is_far);
2023-
2024-
void wrap_label(Register r1, Register r2, Label &L, compare_and_branch_insn insn,
2025-
compare_and_branch_label_insn neg_insn, bool is_far);
2026-
void wrap_label(Register r, Label &L, Register t, load_insn_by_temp insn);
2027-
void wrap_label(Register r, Label &L, jal_jalr_insn insn);
2028-
2029-
// calculate pseudoinstruction
2030-
void add(Register Rd, Register Rn, int64_t increment, Register temp = t0);
2031-
void addw(Register Rd, Register Rn, int64_t increment, Register temp = t0);
2032-
void sub(Register Rd, Register Rn, int64_t decrement, Register temp = t0);
2033-
void subw(Register Rd, Register Rn, int64_t decrement, Register temp = t0);
2034-
2035-
// RVB pseudo instructions
2036-
// zero extend word
2037-
void zext_w(Register Rd, Register Rs);
2038-
2039-
Assembler(CodeBuffer* code) : AbstractAssembler(code), _in_compressible_region(false) {
2040-
}
2041-
2042-
// Stack overflow checking
2043-
virtual void bang_stack_with_offset(int offset) { Unimplemented(); }
2044-
2045-
static bool operand_valid_for_add_immediate(long imm) {
2046-
return is_imm_in_range(imm, 12, 0);
2047-
}
2048-
2049-
// The maximum range of a branch is fixed for the riscv64
2050-
// architecture.
2051-
static const unsigned long branch_range = 1 * M;
2052-
2053-
static bool reachable_from_branch_at(address branch, address target) {
2054-
return uabs(target - branch) < branch_range;
2055-
}
2056-
2057-
// ---------------------------------------------------------------------------------
2058-
// RVC: If an instruction is compressible, then
2059-
// we will implicitly emit a 16-bit compressed instruction instead of the 32-bit
2060-
// instruction in Assembler. All below logic follows Chapter -
2061-
// "C" Standard Extension for Compressed Instructions, Version 2.0.
2062-
// We can get code size reduction and performance improvement with this extension,
2063-
// considering the reduction of instruction size and the code density increment.
2064-
2065-
// Note:
2066-
// 1. When UseRVC is enabled, 32-bit instructions under 'CompressibleRegion's will be
2067-
// transformed to 16-bit instructions if compressible.
2068-
// 2. RVC instructions in Assembler always begin with 'c_' prefix, as 'c_li',
2069-
// but most of time we have no need to explicitly use these instructions.
2070-
// 3. We introduce 'CompressibleRegion' to hint instructions in this Region's RTTI range
2071-
// are qualified to change to their 2-byte versions.
2072-
// An example:
2073-
//
2074-
// CompressibleRegion cr(_masm);
2075-
// __ andr(...); // this instruction could change to c.and if able to
2076-
//
2077-
// 4. Using -XX:PrintAssemblyOptions=no-aliases could print RVC instructions instead of
2078-
// normal ones.
2079-
//
2010+
// ========================================
2011+
// RISC-V Compressed Instructions Extension
2012+
// ========================================
2013+
// Note:
2014+
// 1. When UseRVC is enabled, 32-bit instructions under 'CompressibleRegion's will be
2015+
// transformed to 16-bit instructions if compressible.
2016+
// 2. RVC instructions in Assembler always begin with 'c_' prefix, as 'c_li',
2017+
// but most of time we have no need to explicitly use these instructions.
2018+
// 3. We introduce 'CompressibleRegion' to hint instructions in this Region's RTTI range
2019+
// are qualified to change to their 2-byte versions.
2020+
// An example:
2021+
//
2022+
// CompressibleRegion cr(_masm);
2023+
// __ andr(...); // this instruction could change to c.and if able to
2024+
//
2025+
// 4. Using -XX:PrintAssemblyOptions=no-aliases could print RVC instructions instead of
2026+
// normal ones.
2027+
//
20802028

20812029
private:
20822030
bool _in_compressible_region;
@@ -2881,6 +2829,20 @@ enum Nf {
28812829

28822830
#undef INSN
28832831

2832+
#define INSN(NAME) \
2833+
void NAME() { \
2834+
/* The illegal instruction in RVC is presented by a 16-bit 0. */ \
2835+
if (do_compress()) { \
2836+
emit_int16(0); \
2837+
return; \
2838+
} \
2839+
_halt(); \
2840+
}
2841+
2842+
INSN(halt);
2843+
2844+
#undef INSN
2845+
28842846
// --------------------------
28852847
// Immediate Instructions
28862848
// --------------------------
@@ -3007,21 +2969,54 @@ enum Nf {
30072969

30082970
#undef INSN
30092971

3010-
#define INSN(NAME) \
3011-
void NAME() { \
3012-
/* The illegal instruction in RVC is presented by a 16-bit 0. */ \
3013-
if (do_compress()) { \
3014-
emit_int16(0); \
3015-
return; \
3016-
} \
3017-
_halt(); \
2972+
// ---------------------------------------------------------------------------------------
2973+
2974+
void bgt(Register Rs, Register Rt, const address &dest);
2975+
void ble(Register Rs, Register Rt, const address &dest);
2976+
void bgtu(Register Rs, Register Rt, const address &dest);
2977+
void bleu(Register Rs, Register Rt, const address &dest);
2978+
void bgt(Register Rs, Register Rt, Label &l, bool is_far = false);
2979+
void ble(Register Rs, Register Rt, Label &l, bool is_far = false);
2980+
void bgtu(Register Rs, Register Rt, Label &l, bool is_far = false);
2981+
void bleu(Register Rs, Register Rt, Label &l, bool is_far = false);
2982+
2983+
typedef void (Assembler::* jal_jalr_insn)(Register Rt, address dest);
2984+
typedef void (Assembler::* load_insn_by_temp)(Register Rt, address dest, Register temp);
2985+
typedef void (Assembler::* compare_and_branch_insn)(Register Rs1, Register Rs2, const address dest);
2986+
typedef void (Assembler::* compare_and_branch_label_insn)(Register Rs1, Register Rs2, Label &L, bool is_far);
2987+
2988+
void wrap_label(Register r1, Register r2, Label &L, compare_and_branch_insn insn,
2989+
compare_and_branch_label_insn neg_insn, bool is_far);
2990+
void wrap_label(Register r, Label &L, Register t, load_insn_by_temp insn);
2991+
void wrap_label(Register r, Label &L, jal_jalr_insn insn);
2992+
2993+
// calculate pseudoinstruction
2994+
void add(Register Rd, Register Rn, int64_t increment, Register temp = t0);
2995+
void addw(Register Rd, Register Rn, int64_t increment, Register temp = t0);
2996+
void sub(Register Rd, Register Rn, int64_t decrement, Register temp = t0);
2997+
void subw(Register Rd, Register Rn, int64_t decrement, Register temp = t0);
2998+
2999+
// RVB pseudo instructions
3000+
// zero extend word
3001+
void zext_w(Register Rd, Register Rs);
3002+
3003+
Assembler(CodeBuffer* code) : AbstractAssembler(code), _in_compressible_region(false) {
30183004
}
30193005

3020-
INSN(halt);
3006+
// Stack overflow checking
3007+
virtual void bang_stack_with_offset(int offset) { Unimplemented(); }
30213008

3022-
#undef INSN
3009+
static bool operand_valid_for_add_immediate(long imm) {
3010+
return is_imm_in_range(imm, 12, 0);
3011+
}
30233012

3024-
// ---------------------------------------------------------------------------------------
3013+
// The maximum range of a branch is fixed for the riscv64
3014+
// architecture.
3015+
static const unsigned long branch_range = 1 * M;
3016+
3017+
static bool reachable_from_branch_at(address branch, address target) {
3018+
return uabs(target - branch) < branch_range;
3019+
}
30253020

30263021
virtual ~Assembler() {}
30273022

0 commit comments

Comments
 (0)