@@ -58,7 +58,11 @@ class RegisterImpl: public AbstractRegisterImpl {
5858 enum {
5959 number_of_registers = 32 ,
6060 number_of_byte_registers = 32 ,
61- max_slots_per_register = 2
61+ max_slots_per_register = 2 ,
62+
63+ // C-Ext: integer registers in the range of [x8~x15] are correspond for RVC. Please see Table 16.2 in spec.
64+ compressed_register_base = 8 ,
65+ compressed_register_top = 15 ,
6266 };
6367
6468 // derived registers, offsets, and addresses
@@ -71,10 +75,13 @@ class RegisterImpl: public AbstractRegisterImpl {
7175
7276 // accessors
7377 int encoding () const { assert (is_valid (), " invalid register" ); return (intptr_t )this ; }
78+ int compressed_encoding () const { assert (is_compressed_valid (), " invalid compressed register" ); return ((intptr_t )this - compressed_register_base); }
7479 bool is_valid () const { return 0 <= (intptr_t )this && (intptr_t )this < number_of_registers; }
80+ bool is_compressed_valid () const { return compressed_register_base <= (intptr_t )this && (intptr_t )this <= compressed_register_top; }
7581 bool has_byte_register () const { return 0 <= (intptr_t )this && (intptr_t )this < number_of_byte_registers; }
7682 const char * name () const ;
7783 int encoding_nocheck () const { return (intptr_t )this ; }
84+ int compressed_encoding_nocheck () const { return ((intptr_t )this - compressed_register_base); }
7885
7986 // Return the bit which represents this register. This is intended
8087 // to be ORed into a bitmask: for usage see class RegSet below.
@@ -131,7 +138,11 @@ class FloatRegisterImpl: public AbstractRegisterImpl {
131138 public:
132139 enum {
133140 number_of_registers = 32 ,
134- max_slots_per_register = 2
141+ max_slots_per_register = 2 ,
142+
143+ // C-Ext: float registers in the range of [f8~f15] are correspond for RVC. Please see Table 16.2 in spec.
144+ compressed_register_base = 8 ,
145+ compressed_register_top = 15 ,
135146 };
136147
137148 // construction
@@ -144,8 +155,11 @@ class FloatRegisterImpl: public AbstractRegisterImpl {
144155
145156 // accessors
146157 int encoding () const { assert (is_valid (), " invalid register" ); return (intptr_t )this ; }
158+ int compressed_encoding () const { assert (is_compressed_valid (), " invalid compressed register" ); return ((intptr_t )this - compressed_register_base); }
147159 int encoding_nocheck () const { return (intptr_t )this ; }
160+ int compressed_encoding_nocheck () const { return ((intptr_t )this - compressed_register_base); }
148161 bool is_valid () const { return 0 <= (intptr_t )this && (intptr_t )this < number_of_registers; }
162+ bool is_compressed_valid () const { return compressed_register_base <= (intptr_t )this && (intptr_t )this <= compressed_register_top; }
149163 const char * name () const ;
150164
151165};
0 commit comments