@@ -2019,76 +2019,24 @@ enum Nf {
20192019
20202020#undef INSN
20212021
2022- void bgt (Register Rs, Register Rt, const address &dest);
2023- void ble (Register Rs, Register Rt, const address &dest);
2024- void bgtu (Register Rs, Register Rt, const address &dest);
2025- void bleu (Register Rs, Register Rt, const address &dest);
2026- void bgt (Register Rs, Register Rt, Label &l, bool is_far = false );
2027- void ble (Register Rs, Register Rt, Label &l, bool is_far = false );
2028- void bgtu (Register Rs, Register Rt, Label &l, bool is_far = false );
2029- void bleu (Register Rs, Register Rt, Label &l, bool is_far = false );
2030-
2031- typedef void (Assembler::* jal_jalr_insn)(Register Rt, address dest);
2032- typedef void (Assembler::* load_insn_by_temp)(Register Rt, address dest, Register temp);
2033- typedef void (Assembler::* compare_and_branch_insn)(Register Rs1, Register Rs2, const address dest);
2034- typedef void (Assembler::* compare_and_branch_label_insn)(Register Rs1, Register Rs2, Label &L, bool is_far);
2035-
2036- void wrap_label (Register r1, Register r2, Label &L, compare_and_branch_insn insn,
2037- compare_and_branch_label_insn neg_insn, bool is_far);
2038- void wrap_label (Register r, Label &L, Register t, load_insn_by_temp insn);
2039- void wrap_label (Register r, Label &L, jal_jalr_insn insn);
2040-
2041- // calculate pseudoinstruction
2042- void add (Register Rd, Register Rn, int64_t increment, Register temp = t0);
2043- void addw (Register Rd, Register Rn, int64_t increment, Register temp = t0);
2044- void sub (Register Rd, Register Rn, int64_t decrement, Register temp = t0);
2045- void subw (Register Rd, Register Rn, int64_t decrement, Register temp = t0);
2046-
2047- // RVB pseudo instructions
2048- // zero extend word
2049- void zext_w (Register Rd, Register Rs);
2050-
2051- Assembler (CodeBuffer* code) : AbstractAssembler(code), _in_compressible_region(false ) {
2052- }
2053-
2054- // Stack overflow checking
2055- virtual void bang_stack_with_offset (int offset) { Unimplemented (); }
2056-
2057- static bool operand_valid_for_add_immediate (long imm) {
2058- return is_imm_in_range (imm, 12 , 0 );
2059- }
2060-
2061- // The maximum range of a branch is fixed for the riscv64
2062- // architecture.
2063- static const unsigned long branch_range = 1 * M;
2064-
2065- static bool reachable_from_branch_at (address branch, address target) {
2066- return uabs (target - branch) < branch_range;
2067- }
2068-
2069- // ---------------------------------------------------------------------------------
2070- // RVC: If an instruction is compressible, then
2071- // we will implicitly emit a 16-bit compressed instruction instead of the 32-bit
2072- // instruction in Assembler. All below logic follows Chapter -
2073- // "C" Standard Extension for Compressed Instructions, Version 2.0.
2074- // We can get code size reduction and performance improvement with this extension,
2075- // considering the reduction of instruction size and the code density increment.
2076-
2077- // Note:
2078- // 1. When UseRVC is enabled, 32-bit instructions under 'CompressibleRegion's will be
2079- // transformed to 16-bit instructions if compressible.
2080- // 2. RVC instructions in Assembler always begin with 'c_' prefix, as 'c_li',
2081- // but most of time we have no need to explicitly use these instructions.
2082- // 3. We introduce 'CompressibleRegion' to hint instructions in this Region's RTTI range
2083- // are qualified to change to their 2-byte versions.
2084- // An example:
2085- //
2086- // CompressibleRegion cr(_masm);
2087- // __ andr(...); // this instruction could change to c.and if able to
2088- //
2089- // 4. Using -XX:PrintAssemblyOptions=no-aliases could print RVC instructions instead of
2090- // normal ones.
2091- //
2022+ // ========================================
2023+ // RISC-V Compressed Instructions Extension
2024+ // ========================================
2025+ // Note:
2026+ // 1. When UseRVC is enabled, 32-bit instructions under 'CompressibleRegion's will be
2027+ // transformed to 16-bit instructions if compressible.
2028+ // 2. RVC instructions in Assembler always begin with 'c_' prefix, as 'c_li',
2029+ // but most of time we have no need to explicitly use these instructions.
2030+ // 3. We introduce 'CompressibleRegion' to hint instructions in this Region's RTTI range
2031+ // are qualified to change to their 2-byte versions.
2032+ // An example:
2033+ //
2034+ // CompressibleRegion cr(_masm);
2035+ // __ andr(...); // this instruction could change to c.and if able to
2036+ //
2037+ // 4. Using -XX:PrintAssemblyOptions=no-aliases could print RVC instructions instead of
2038+ // normal ones.
2039+ //
20922040
20932041private:
20942042 bool _in_compressible_region;
@@ -2893,6 +2841,20 @@ enum Nf {
28932841
28942842#undef INSN
28952843
2844+ #define INSN (NAME ) \
2845+ void NAME () { \
2846+ /* The illegal instruction in RVC is presented by a 16-bit 0. */ \
2847+ if (do_compress ()) { \
2848+ emit_int16 (0 ); \
2849+ return ; \
2850+ } \
2851+ _halt (); \
2852+ }
2853+
2854+ INSN (halt);
2855+
2856+ #undef INSN
2857+
28962858// --------------------------
28972859// Immediate Instructions
28982860// --------------------------
@@ -3019,21 +2981,54 @@ enum Nf {
30192981
30202982#undef INSN
30212983
3022- #define INSN (NAME ) \
3023- void NAME () { \
3024- /* The illegal instruction in RVC is presented by a 16-bit 0. */ \
3025- if (do_compress ()) { \
3026- emit_int16 (0 ); \
3027- return ; \
3028- } \
3029- _halt (); \
2984+ // ---------------------------------------------------------------------------------------
2985+
2986+ void bgt (Register Rs, Register Rt, const address &dest);
2987+ void ble (Register Rs, Register Rt, const address &dest);
2988+ void bgtu (Register Rs, Register Rt, const address &dest);
2989+ void bleu (Register Rs, Register Rt, const address &dest);
2990+ void bgt (Register Rs, Register Rt, Label &l, bool is_far = false );
2991+ void ble (Register Rs, Register Rt, Label &l, bool is_far = false );
2992+ void bgtu (Register Rs, Register Rt, Label &l, bool is_far = false );
2993+ void bleu (Register Rs, Register Rt, Label &l, bool is_far = false );
2994+
2995+ typedef void (Assembler::* jal_jalr_insn)(Register Rt, address dest);
2996+ typedef void (Assembler::* load_insn_by_temp)(Register Rt, address dest, Register temp);
2997+ typedef void (Assembler::* compare_and_branch_insn)(Register Rs1, Register Rs2, const address dest);
2998+ typedef void (Assembler::* compare_and_branch_label_insn)(Register Rs1, Register Rs2, Label &L, bool is_far);
2999+
3000+ void wrap_label (Register r1, Register r2, Label &L, compare_and_branch_insn insn,
3001+ compare_and_branch_label_insn neg_insn, bool is_far);
3002+ void wrap_label (Register r, Label &L, Register t, load_insn_by_temp insn);
3003+ void wrap_label (Register r, Label &L, jal_jalr_insn insn);
3004+
3005+ // calculate pseudoinstruction
3006+ void add (Register Rd, Register Rn, int64_t increment, Register temp = t0);
3007+ void addw (Register Rd, Register Rn, int64_t increment, Register temp = t0);
3008+ void sub (Register Rd, Register Rn, int64_t decrement, Register temp = t0);
3009+ void subw (Register Rd, Register Rn, int64_t decrement, Register temp = t0);
3010+
3011+ // RVB pseudo instructions
3012+ // zero extend word
3013+ void zext_w (Register Rd, Register Rs);
3014+
3015+ Assembler (CodeBuffer* code) : AbstractAssembler(code), _in_compressible_region(false ) {
30303016 }
30313017
3032- INSN (halt);
3018+ // Stack overflow checking
3019+ virtual void bang_stack_with_offset (int offset) { Unimplemented (); }
30333020
3034- #undef INSN
3021+ static bool operand_valid_for_add_immediate (long imm) {
3022+ return is_imm_in_range (imm, 12 , 0 );
3023+ }
30353024
3036- // ---------------------------------------------------------------------------------------
3025+ // The maximum range of a branch is fixed for the riscv64
3026+ // architecture.
3027+ static const unsigned long branch_range = 1 * M;
3028+
3029+ static bool reachable_from_branch_at (address branch, address target) {
3030+ return uabs (target - branch) < branch_range;
3031+ }
30373032
30383033 virtual ~Assembler () {}
30393034
0 commit comments