@@ -127,6 +127,164 @@ static inline bool is_overlapped_widen(const int astart, int asize,
127
127
#define require_align (val, pos ) CHECK_EQ(is_aligned(val, pos), true )
128
128
#endif
129
129
130
+ // RVV
131
+ // The following code about RVV was based from:
132
+ // https://github.com/riscv/riscv-isa-sim
133
+ // Copyright (c) 2010-2017, The Regents of the University of California
134
+ // (Regents). All Rights Reserved.
135
+
136
+ // Redistribution and use in source and binary forms, with or without
137
+ // modification, are permitted provided that the following conditions are met:
138
+ // 1. Redistributions of source code must retain the above copyright
139
+ // notice, this list of conditions and the following disclaimer.
140
+ // 2. Redistributions in binary form must reproduce the above copyright
141
+ // notice, this list of conditions and the following disclaimer in the
142
+ // documentation and/or other materials provided with the distribution.
143
+ // 3. Neither the name of the Regents nor the
144
+ // names of its contributors may be used to endorse or promote products
145
+ // derived from this software without specific prior written permission.
146
+
147
+ // IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
148
+ // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
149
+ // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
150
+ // REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
151
+
152
+ // REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED
153
+ // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
154
+ // PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
155
+ // HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
156
+ // MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
157
+ template <uint64_t N>
158
+ struct type_usew_t ;
159
+ template <>
160
+ struct type_usew_t <8 > {
161
+ using type = uint8_t ;
162
+ };
163
+
164
+ template <>
165
+ struct type_usew_t <16 > {
166
+ using type = uint16_t ;
167
+ };
168
+
169
+ template <>
170
+ struct type_usew_t <32 > {
171
+ using type = uint32_t ;
172
+ };
173
+
174
+ template <>
175
+ struct type_usew_t <64 > {
176
+ using type = uint64_t ;
177
+ };
178
+
179
+ template <>
180
+ struct type_usew_t <128 > {
181
+ using type = __uint128_t ;
182
+ };
183
+ template <uint64_t N>
184
+ struct type_sew_t ;
185
+
186
+ template <>
187
+ struct type_sew_t <8 > {
188
+ using type = int8_t ;
189
+ };
190
+
191
+ template <>
192
+ struct type_sew_t <16 > {
193
+ using type = int16_t ;
194
+ };
195
+
196
+ template <>
197
+ struct type_sew_t <32 > {
198
+ using type = int32_t ;
199
+ };
200
+
201
+ template <>
202
+ struct type_sew_t <64 > {
203
+ using type = int64_t ;
204
+ };
205
+
206
+ template <>
207
+ struct type_sew_t <128 > {
208
+ using type = __int128_t ;
209
+ };
210
+
211
+ #define VV_PARAMS (x ) \
212
+ type_sew_t <x>::type& vd = \
213
+ Rvvelt<type_sew_t <x>::type>(rvv_vd_reg(), i, true ); \
214
+ type_sew_t <x>::type vs1 = Rvvelt<type_sew_t <x>::type>(rvv_vs1_reg(), i); \
215
+ type_sew_t <x>::type vs2 = Rvvelt<type_sew_t <x>::type>(rvv_vs2_reg(), i);
216
+
217
+ #define VV_UPARAMS (x ) \
218
+ type_usew_t <x>::type& vd = \
219
+ Rvvelt<type_usew_t <x>::type>(rvv_vd_reg(), i, true ); \
220
+ type_usew_t <x>::type vs1 = Rvvelt<type_usew_t <x>::type>(rvv_vs1_reg(), i); \
221
+ type_usew_t <x>::type vs2 = Rvvelt<type_usew_t <x>::type>(rvv_vs2_reg(), i);
222
+
223
+ #define VX_PARAMS (x ) \
224
+ type_sew_t <x>::type& vd = \
225
+ Rvvelt<type_sew_t <x>::type>(rvv_vd_reg(), i, true ); \
226
+ type_sew_t <x>::type rs1 = (type_sew_t <x>::type)(get_register(rs1_reg())); \
227
+ type_sew_t <x>::type vs2 = Rvvelt<type_sew_t <x>::type>(rvv_vs2_reg(), i);
228
+
229
+ #define VX_UPARAMS (x ) \
230
+ type_usew_t <x>::type& vd = \
231
+ Rvvelt<type_usew_t <x>::type>(rvv_vd_reg(), i, true ); \
232
+ type_usew_t <x>::type rs1 = (type_usew_t <x>::type)(get_register(rs1_reg())); \
233
+ type_usew_t <x>::type vs2 = Rvvelt<type_usew_t <x>::type>(rvv_vs2_reg(), i);
234
+
235
+ #define VI_PARAMS (x ) \
236
+ type_sew_t <x>::type& vd = \
237
+ Rvvelt<type_sew_t <x>::type>(rvv_vd_reg(), i, true ); \
238
+ type_sew_t <x>::type simm5 = (type_sew_t <x>::type)(instr_.RvvSimm5()); \
239
+ type_sew_t <x>::type vs2 = Rvvelt<type_sew_t <x>::type>(rvv_vs2_reg(), i);
240
+
241
+ #define VI_UPARAMS (x ) \
242
+ type_usew_t <x>::type& vd = \
243
+ Rvvelt<type_usew_t <x>::type>(rvv_vd_reg(), i, true ); \
244
+ type_usew_t <x>::type uimm5 = (type_usew_t <x>::type)(instr_.RvvUimm5()); \
245
+ type_usew_t <x>::type vs2 = Rvvelt<type_usew_t <x>::type>(rvv_vs2_reg(), i);
246
+
247
+ #define VN_PARAMS (x ) \
248
+ constexpr int half_x = x >> 1 ; \
249
+ type_sew_t <half_x>::type& vd = \
250
+ Rvvelt<type_sew_t <half_x>::type>(rvv_vd_reg(), i, true ); \
251
+ type_sew_t <x>::type uimm5 = (type_sew_t <x>::type)(instr_.RvvUimm5()); \
252
+ type_sew_t <x>::type vs2 = Rvvelt<type_sew_t <x>::type>(rvv_vs2_reg(), i);
253
+
254
+ #define VN_UPARAMS (x ) \
255
+ constexpr int half_x = x >> 1 ; \
256
+ type_usew_t <half_x>::type& vd = \
257
+ Rvvelt<type_usew_t <half_x>::type>(rvv_vd_reg(), i, true ); \
258
+ type_usew_t <x>::type uimm5 = (type_usew_t <x>::type)(instr_.RvvUimm5()); \
259
+ type_sew_t <x>::type vs2 = Rvvelt<type_sew_t <x>::type>(rvv_vs2_reg(), i);
260
+
261
+ #define VXI_PARAMS (x ) \
262
+ type_sew_t <x>::type& vd = \
263
+ Rvvelt<type_sew_t <x>::type>(rvv_vd_reg(), i, true ); \
264
+ type_sew_t <x>::type vs1 = Rvvelt<type_sew_t <x>::type>(rvv_vs1_reg(), i); \
265
+ type_sew_t <x>::type vs2 = Rvvelt<type_sew_t <x>::type>(rvv_vs2_reg(), i); \
266
+ type_sew_t <x>::type rs1 = (type_sew_t <x>::type)(get_register(rs1_reg())); \
267
+ type_sew_t <x>::type simm5 = (type_sew_t <x>::type)(instr_.RvvSimm5());
268
+
269
+ #define VI_XI_SLIDEDOWN_PARAMS (x, off ) \
270
+ auto & vd = Rvvelt<type_sew_t <x>::type>(rvv_vd_reg(), i, true ); \
271
+ auto vs2 = Rvvelt<type_sew_t <x>::type>(rvv_vs2_reg(), i + off);
272
+
273
+ #define VI_XI_SLIDEUP_PARAMS (x, offset ) \
274
+ auto & vd = Rvvelt<type_sew_t <x>::type>(rvv_vd_reg(), i, true ); \
275
+ auto vs2 = Rvvelt<type_sew_t <x>::type>(rvv_vs2_reg(), i - offset);
276
+
277
+ /* Vector Integer Extension */
278
+ #define VI_VIE_PARAMS (x, scale ) \
279
+ if ((x / scale) < 8 ) UNREACHABLE(); \
280
+ auto & vd = Rvvelt<type_sew_t <x>::type>(rvv_vd_reg(), i, true ); \
281
+ auto vs2 = Rvvelt<type_sew_t <x / scale>::type>(rvv_vs2_reg(), i);
282
+
283
+ #define VI_VIE_UPARAMS (x, scale ) \
284
+ if ((x / scale) < 8 ) UNREACHABLE(); \
285
+ auto & vd = Rvvelt<type_sew_t <x>::type>(rvv_vd_reg(), i, true ); \
286
+ auto vs2 = Rvvelt<type_usew_t <x / scale>::type>(rvv_vs2_reg(), i);
287
+
130
288
#define require_noover (astart, asize, bstart, bsize ) \
131
289
CHECK_EQ (!is_overlapped(astart, asize, bstart, bsize), true)
132
290
#define require_noover_widen (astart, asize, bstart, bsize ) \
0 commit comments