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