gem5 v24.0.0.0
Loading...
Searching...
No Matches
vector.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 PLCT Lab
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
30
31#include <sstream>
32#include <string>
33
35#include "arch/riscv/isa.hh"
38#include "arch/riscv/utility.hh"
39#include "cpu/static_inst.hh"
40
41namespace gem5
42{
43
44namespace RiscvISA
45{
46
61float
62getVflmul(uint32_t vlmul_encoding)
63{
64 int vlmul = sext<3>(vlmul_encoding & 7);
65 float vflmul = vlmul >= 0 ? 1 << vlmul : 1.0 / (1 << -vlmul);
66 return vflmul;
67}
68
69uint32_t
70getVlmax(VTYPE vtype, uint32_t vlen)
71{
72 uint32_t sew = getSew(vtype.vsew);
73 // vlmax is defined in RVV 1.0 spec p12 chapter 3.4.2.
74 uint32_t vlmax = (vlen/sew) * getVflmul(vtype.vlmul);
75 return vlmax;
76}
77
78std::string
80{
81 std::stringstream ss;
82 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", ";
83 if (bit31 && bit30 == 0) {
84 ss << registerName(srcRegIdx(0)) << ", " << registerName(srcRegIdx(1));
85 } else if (bit31 && bit30) {
86 ss << uimm << ", " << generateZimmDisassembly();
87 } else {
89 }
90 return ss.str();
91}
92
93std::string
95{
96 std::stringstream s;
97
98 // VSETIVLI uses ZIMM10 and VSETVLI uses ZIMM11
99 uint64_t zimm = (bit31 && bit30) ? zimm10 : zimm11;
100
101 bool frac_lmul = bits(zimm, 2);
102 int sew = 1 << (bits(zimm, 5, 3) + 3);
103 int lmul = bits(zimm, 1, 0);
104 auto vta = bits(zimm, 6) == 1 ? "ta" : "tu";
105 auto vma = bits(zimm, 7) == 1 ? "ma" : "mu";
106 s << "e" << sew;
107 if (frac_lmul) {
108 std::string lmul_str = "";
109 switch(lmul){
110 case 3:
111 lmul_str = "f2";
112 break;
113 case 2:
114 lmul_str = "f4";
115 break;
116 case 1:
117 lmul_str = "f8";
118 break;
119 default:
120 panic("Unsupport fractional LMUL");
121 }
122 s << ", m" << lmul_str;
123 } else {
124 s << ", m" << (1 << lmul);
125 }
126 s << ", " << vta << ", " << vma;
127 return s.str();
128}
129
130std::string
132 const loader::SymbolTable *symtab) const
133{
134 std::stringstream ss;
135 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", "
136 << registerName(srcRegIdx(0));
137 if (machInst.vm == 0) ss << ", v0.t";
138 return ss.str();
139}
140
142 const loader::SymbolTable *symtab) const
143{
144 std::stringstream ss;
145 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", ";
146 if (machInst.funct3 == 0x3) {
147 // OPIVI
148 ss << registerName(srcRegIdx(0)) << ", " << machInst.vecimm;
149 } else {
150 ss << registerName(srcRegIdx(1)) << ", " << registerName(srcRegIdx(0));
151 }
152 if (machInst.vm == 0) ss << ", v0.t";
153 return ss.str();
154}
155
157 const loader::SymbolTable *symtab) const
158{
159 std::stringstream ss;
160 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", ";
161 if (machInst.funct3 == 0x3) {
162 // OPIVI
163 ss << registerName(srcRegIdx(0)) << ", " << machInst.vecimm;
164 } else {
165 ss << registerName(srcRegIdx(1)) << ", " << registerName(srcRegIdx(0));
166 }
167 if (machInst.vm == 0) ss << ", v0.t";
168 return ss.str();
169}
170
172 const loader::SymbolTable *symtab) const
173{
174 std::stringstream ss;
175 ss << mnemonic << ' ' << registerName(destRegIdx(0));
176 if (machInst.vm == 0) ss << ", v0.t";
177 return ss.str();
178}
179
181 const loader::SymbolTable *symtab) const
182{
183 std::stringstream ss;
184 ss << mnemonic << ' ' << registerName(destRegIdx(0));
185 if (machInst.vm == 0) ss << ", v0.t";
186 return ss.str();
187}
188
190 const loader::SymbolTable *symtab) const
191{
192 std::stringstream ss;
193 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", ";
194 if (machInst.funct3 == 0x3) {
195 ss << registerName(srcRegIdx(0)) << ", " << machInst.vecimm;
196 } else {
197 ss << registerName(srcRegIdx(1)) << ", " << registerName(srcRegIdx(0));
198 }
199 if (machInst.vm == 0) ss << ", v0.t";
200 return ss.str();
201}
202
204 const loader::SymbolTable *symtab) const
205{
206 std::stringstream ss;
207 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", ";
208 if (machInst.funct3 == 0x3) {
209 ss << registerName(srcRegIdx(0)) << ", " << machInst.vecimm;
210 } else {
211 ss << registerName(srcRegIdx(1)) << ", " << registerName(srcRegIdx(0));
212 }
213 if (machInst.vm == 0) ss << ", v0.t";
214 return ss.str();
215}
216
218 const loader::SymbolTable *symtab) const
219{
220 std::stringstream ss;
221 unsigned vlenb = vlen >> 3;
222 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", "
223 << vlenb * microIdx << '(' << registerName(srcRegIdx(0)) << ')' << ", "
224 << registerName(srcRegIdx(1));
225 if (!machInst.vm) ss << ", v0.t";
226 return ss.str();
227}
228
230 const loader::SymbolTable *symtab) const
231{
232 std::stringstream ss;
233 unsigned vlenb = vlen >> 3;
234 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", "
235 << vlenb * microIdx << '(' << registerName(srcRegIdx(0)) << ')';
236 return ss.str();
237}
238
240 const loader::SymbolTable *symtab) const
241{
242 std::stringstream ss;
243 unsigned vlenb = vlen >> 3;
244 ss << mnemonic << ' ' << registerName(srcRegIdx(1)) << ", "
245 << vlenb * microIdx << '(' << registerName(srcRegIdx(0)) << ')';
246 if (!machInst.vm) ss << ", v0.t";
247 return ss.str();
248}
249
251 const loader::SymbolTable *symtab) const
252{
253 std::stringstream ss;
254 unsigned vlenb = vlen >> 3;
255 ss << mnemonic << ' ' << registerName(srcRegIdx(1)) << ", "
256 << vlenb * microIdx << '(' << registerName(srcRegIdx(0)) << ')';
257 return ss.str();
258}
259
261 const loader::SymbolTable *symtab) const
262{
263 std::stringstream ss;
264 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
265 '(' << registerName(srcRegIdx(0)) << ')';
266 if (!machInst.vm) ss << ", v0.t";
267 return ss.str();
268}
269
271 const loader::SymbolTable *symtab) const
272{
273 std::stringstream ss;
274 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
275 '(' << registerName(srcRegIdx(0)) << ')';
276 return ss.str();
277}
278
280 const loader::SymbolTable *symtab) const
281{
282 std::stringstream ss;
283 ss << mnemonic << ' ' << registerName(srcRegIdx(1)) << ", " <<
284 '(' << registerName(srcRegIdx(0)) << ')';
285 if (!machInst.vm) ss << ", v0.t";
286 return ss.str();
287}
288
290 const loader::SymbolTable *symtab) const
291{
292 std::stringstream ss;
293 ss << mnemonic << ' ' << registerName(srcRegIdx(1)) << ", " <<
294 '(' << registerName(srcRegIdx(0)) << ')';
295 return ss.str();
296}
297
299 const loader::SymbolTable *symtab) const
300{
301 std::stringstream ss;
302 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
303 '(' << registerName(srcRegIdx(0)) << ')' <<
304 ", " << registerName(srcRegIdx(1));
305 if (!machInst.vm) ss << ", v0.t";
306 return ss.str();
307}
308
310 const loader::SymbolTable *symtab) const
311{
312 std::stringstream ss;
313 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
314 '(' << registerName(srcRegIdx(0)) << ')' <<
315 ", "<< registerName(srcRegIdx(1));
316 if (microIdx != 0 || machInst.vtype8.vma == 0 || machInst.vtype8.vta == 0)
317 ss << ", " << registerName(srcRegIdx(2));
318 if (!machInst.vm) ss << ", v0.t";
319 return ss.str();
320}
321
323 const loader::SymbolTable *symtab) const
324{
325 std::stringstream ss;
326 ss << mnemonic << ' ' << registerName(srcRegIdx(2)) << ", " <<
327 '(' << registerName(srcRegIdx(0)) << ')' <<
328 ", " << registerName(srcRegIdx(1));
329 if (!machInst.vm) ss << ", v0.t";
330 return ss.str();
331}
332
334 const loader::SymbolTable *symtab) const
335{
336 std::stringstream ss;
337 ss << mnemonic << ' ' << registerName(srcRegIdx(2)) << ", " <<
338 '(' << registerName(srcRegIdx(0)) << ')' <<
339 ", "<< registerName(srcRegIdx(1));
340 if (microIdx != 0 || machInst.vtype8.vma == 0 || machInst.vtype8.vta == 0)
341 ss << ", " << registerName(srcRegIdx(2));
342 if (!machInst.vm) ss << ", v0.t";
343 return ss.str();
344}
345
347 const loader::SymbolTable *symtab) const
348{
349 std::stringstream ss;
350 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", "
351 << '(' << registerName(srcRegIdx(0)) << "),"
352 << registerName(srcRegIdx(1));
353 if (!machInst.vm) ss << ", v0.t";
354 return ss.str();
355}
356
358 const loader::SymbolTable *symtab) const
359{
360 std::stringstream ss;
361 ss << mnemonic << ' '
362 << registerName(destRegIdx(0)) << "[" << uint16_t(vdElemIdx) << "], "
363 << '(' << registerName(srcRegIdx(0)) << "), "
364 << registerName(srcRegIdx(1)) << "[" << uint16_t(vs2ElemIdx) << "]";
365 if (microIdx != 0 || machInst.vtype8.vma == 0 || machInst.vtype8.vta == 0)
366 ss << ", " << registerName(srcRegIdx(2));
367 if (!machInst.vm) ss << ", v0.t";
368 return ss.str();
369}
370
372 const loader::SymbolTable *symtab) const
373{
374 std::stringstream ss;
375 ss << mnemonic << ' ' << registerName(srcRegIdx(2)) << ", "
376 << '(' << registerName(srcRegIdx(0)) << "),"
377 << registerName(srcRegIdx(1));
378 if (!machInst.vm) ss << ", v0.t";
379 return ss.str();
380}
381
383 const loader::SymbolTable *symtab) const
384{
385 std::stringstream ss;
386 ss << mnemonic << ' '
387 << registerName(srcRegIdx(2)) << "[" << uint16_t(vs3ElemIdx) << "], "
388 << '(' << registerName(srcRegIdx(0)) << "), "
389 << registerName(srcRegIdx(1)) << "[" << uint16_t(vs2ElemIdx) << "]";
390 if (!machInst.vm) ss << ", v0.t";
391 return ss.str();
392}
393
394std::string
396 const loader::SymbolTable *symtab) const
397{
398 std::stringstream ss;
399 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
401 return ss.str();
402}
403
404std::string
406 const loader::SymbolTable *symtab) const
407{
408 std::stringstream ss;
409 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
411 return ss.str();
412}
413
415 uint8_t _dstReg, uint8_t _numSrcs, uint32_t _vlen, size_t _elemSize)
416 : VectorArithMicroInst("vmask_mv_micro", extMachInst,
417 SimdAddOp, 0, 0),
418 vlen(_vlen),
419 elemSize(_elemSize)
420{
422 reinterpret_cast<RegIdArrayPtr>(
423 &std::remove_pointer_t<decltype(this)>::srcRegIdxArr),
424 reinterpret_cast<RegIdArrayPtr>(
425 &std::remove_pointer_t<decltype(this)>::destRegIdxArr));
426
427 _numSrcRegs = 0;
428 _numDestRegs = 0;
429
432 for (uint8_t i=0; i<_numSrcs; i++) {
434 }
435}
436
437Fault
439 trace::InstRecord* traceData) const
440{
441 vreg_t& tmp_d0 = *(vreg_t *)xc->getWritableRegOperand(this, 0);
442 PCStateBase *pc_ptr = xc->tcBase()->pcState().clone();
443 auto Vd = tmp_d0.as<uint8_t>();
444 uint32_t vlenb = pc_ptr->as<PCState>().vlenb();
445 const uint32_t elems_per_vreg = vlenb / elemSize;
446 size_t bit_cnt = elems_per_vreg;
447 vreg_t tmp_s;
448 xc->getRegOperand(this, 0, &tmp_s);
449 auto s = tmp_s.as<uint8_t>();
450 // cp the first result and tail
451 memcpy(Vd, s, vlenb);
452 for (uint8_t i = 1; i < this->_numSrcRegs; i++) {
453 xc->getRegOperand(this, i, &tmp_s);
454 s = tmp_s.as<uint8_t>();
455 if (elems_per_vreg < 8) {
456 const uint32_t m = (1 << elems_per_vreg) - 1;
457 const uint32_t mask = m << (i * elems_per_vreg % 8);
458 // clr & ext bits
459 Vd[bit_cnt/8] ^= Vd[bit_cnt/8] & mask;
460 Vd[bit_cnt/8] |= s[bit_cnt/8] & mask;
461 bit_cnt += elems_per_vreg;
462 } else {
463 const uint32_t byte_offset = elems_per_vreg / 8;
464 memcpy(Vd + i * byte_offset, s + i * byte_offset, byte_offset);
465 }
466 }
467 if (traceData) {
468 traceData->setData(vecRegClass, &tmp_d0);
469 }
470 return NoFault;
471}
472
473std::string
475 const loader::SymbolTable *symtab) const
476{
477 std::stringstream ss;
478 ss << mnemonic << ' ' << registerName(destRegIdx(0));
479 for (uint8_t i = 0; i < this->_numSrcRegs; i++) {
480 ss << ", " << registerName(srcRegIdx(i));
481 }
482 unsigned vlenb = vlen >> 3;
483 ss << ", offset:" << vlenb / elemSize;
484 return ss.str();
485}
486
487Fault
489{
491 auto vcsr = xc->readMiscReg(MISCREG_VCSR);
492 xc->setMiscReg(MISCREG_VCSR, ((vcsr&~1)|*vxsat));
493 return NoFault;
494}
495
496std::string
498 const loader::SymbolTable *symtab) const
499{
500 std::stringstream ss;
501 ss << mnemonic << ' ' << "VXSAT" << ", " << (*vxsat ? "0x1" : "0x0");
502 return ss.str();
503}
504
506 uint32_t _microIdx, uint32_t _vlen, std::vector<StaticInstPtr>& _microops)
507 : VectorMicroInst("vlff_trimvl_v_micro", _machInst, SimdConfigOp,
508 _microVl, _microIdx, _vlen),
509 microops(_microops)
510{
512 reinterpret_cast<RegIdArrayPtr>(
513 &std::remove_pointer_t<decltype(this)>::srcRegIdxArr),
514 nullptr
515 );
516
517 // Create data dependency with load micros
518 for (uint8_t i=0; i<microIdx; i++) {
519 setSrcRegIdx(_numSrcRegs++, vecRegClass[_machInst.vd + i]);
520 }
521
522 this->flags[IsControl] = true;
523 this->flags[IsIndirectControl] = true;
524 this->flags[IsInteger] = true;
525 this->flags[IsUncondControl] = true;
526}
527
528uint32_t
530{
531 uint32_t vl = 0;
532 for (uint8_t i=0; i<microIdx; i++) {
533 VleMicroInst& micro = static_cast<VleMicroInst&>(*microops[i]);
534 vl += micro.faultIdx;
535
536 if (micro.trimVl)
537 break;
538 }
539 return vl;
540}
541
542Fault
544{
545 auto tc = xc->tcBase();
546 MISA misa = xc->readMiscReg(MISCREG_ISA);
547 STATUS status = xc->readMiscReg(MISCREG_STATUS);
548 if (!misa.rvv || status.vs == VPUStatus::OFF) {
549 return std::make_shared<IllegalInstFault>(
550 "RVV is disabled or VPU is off", machInst);
551 }
552
553 PCState pc;
554 set(pc, xc->pcState());
555
556 uint32_t new_vl = calcVl();
557
558 tc->setMiscReg(MISCREG_VSTART, 0);
559
560 RegVal final_val = new_vl;
561 if (traceData) {
562 traceData->setData(miscRegClass, final_val);
563 }
564
565 pc.vl(new_vl);
566 xc->pcState(pc);
567
568 return NoFault;
569}
570
571std::unique_ptr<PCStateBase>
573{
574 PCStateBase *pc_ptr = tc->pcState().clone();
575
576 uint32_t new_vl = calcVl();
577
578 pc_ptr->as<PCState>().vl(new_vl);
579 return std::unique_ptr<PCStateBase>{pc_ptr};
580}
581
582std::string
584 const loader::SymbolTable *symtab) const
585{
586 std::stringstream ss;
587 ss << mnemonic << " vl";
588 return ss.str();
589}
590
592 const loader::SymbolTable *symtab) const
593{
594 std::stringstream ss;
595 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
596 '(' << registerName(srcRegIdx(0)) << ')' <<
597 ", " << registerName(srcRegIdx(1));
598 if (!machInst.vm)
599 ss << ", v0.t";
600 return ss.str();
601}
602
604 const loader::SymbolTable *symtab) const
605{
606 std::stringstream ss;
607 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
608 '(' << registerName(srcRegIdx(0)) << ')' <<
609 ", "<< registerName(srcRegIdx(1));
610 if (microIdx != 0 || machInst.vtype8.vma == 0 || machInst.vtype8.vta == 0)
611 ss << ", " << registerName(srcRegIdx(2));
612 if (!machInst.vm)
613 ss << ", v0.t";
614 return ss.str();
615}
616
618 uint32_t _dstReg, uint32_t _numSrcs,
619 uint32_t _microIdx, uint32_t _numMicroops,
620 uint32_t _field, uint32_t _vlen, uint32_t _sizeOfElement)
621 : VectorArithMicroInst("vlseg_deintrlv_micro", extMachInst,
622 SimdAddOp, 0, 0),
623 vlen(_vlen)
624{
626 reinterpret_cast<RegIdArrayPtr>(
627 &std::remove_pointer_t<decltype(this)>::srcRegIdxArr),
628 reinterpret_cast<RegIdArrayPtr>(
629 &std::remove_pointer_t<decltype(this)>::destRegIdxArr));
630
631 _numSrcRegs = 0;
632 _numDestRegs = 0;
633 numSrcs = _numSrcs;
634 numMicroops = _numMicroops;
635 field =_field;
636 sizeOfElement = _sizeOfElement;
637 microIdx = _microIdx;
638 micro_vl = _micro_vl;
639
642 for (uint32_t i=0; i < _numSrcs; i++) {
643 uint32_t index = VecMemInternalReg0 + i + (microIdx * _numSrcs);
645 }
646}
647
648Fault
650{
651 vreg_t& tmp_d0 = *(vreg_t *)xc->getWritableRegOperand(this, 0);
652 auto Vd = tmp_d0.as<uint8_t>();
653 const uint32_t elems_per_vreg = micro_vl;
654 vreg_t tmp_s;
655 auto s = tmp_s.as<uint8_t>();
656 uint32_t elem = 0;
657 uint32_t index = field;
658 for (uint32_t i = 0; i < numSrcs; i++) {
659 xc->getRegOperand(this, i, &tmp_s);
660 s = tmp_s.as<uint8_t>();
661 while(index < (i + 1) * elems_per_vreg)
662 {
663 memcpy(Vd + (elem * sizeOfElement),
664 s + ((index % elems_per_vreg) * sizeOfElement),
666 index += numSrcs;
667 elem++;
668 }
669 }
670 if (traceData) {
671 traceData->setData(vecRegClass, &tmp_d0);
672 }
673 return NoFault;
674}
675
676std::string
678 const
679{
680 std::stringstream ss;
681 ss << mnemonic << ' ' << registerName(destRegIdx(0));
682 for (uint8_t i = 0; i < this->_numSrcRegs; i++) {
683 ss << ", " << registerName(srcRegIdx(i));
684 }
685 ss << ", field: " << field;
686 return ss.str();
687}
688
690 const loader::SymbolTable *symtab) const
691{
692 std::stringstream ss;
693 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
694 '(' << registerName(srcRegIdx(0)) << ')' <<
695 ", " << registerName(srcRegIdx(1));
696 if (!machInst.vm)
697 ss << ", v0.t";
698 return ss.str();
699}
700
702 const loader::SymbolTable *symtab) const
703{
704 std::stringstream ss;
705 ss << mnemonic << ' ' << registerName(destRegIdx(0)) << ", " <<
706 '(' << registerName(srcRegIdx(0)) << ')' <<
707 ", "<< registerName(srcRegIdx(1));
708 if (microIdx != 0 || machInst.vtype8.vma == 0 || machInst.vtype8.vta == 0)
709 ss << ", " << registerName(srcRegIdx(2));
710 if (!machInst.vm)
711 ss << ", v0.t";
712 return ss.str();
713}
714
716 uint32_t _dstReg, uint32_t _numSrcs,
717 uint32_t _microIdx, uint32_t _numMicroops,
718 uint32_t _field, uint32_t _vlen, uint32_t _sizeOfElement)
719 : VectorArithMicroInst("vsseg_reintrlv_micro", extMachInst,
720 SimdAddOp, 0, 0),
721 vlen(_vlen)
722{
724 reinterpret_cast<RegIdArrayPtr>(
725 &std::remove_pointer_t<decltype(this)>::srcRegIdxArr),
726 reinterpret_cast<RegIdArrayPtr>(
727 &std::remove_pointer_t<decltype(this)>::destRegIdxArr));
728
729 _numSrcRegs = 0;
730 _numDestRegs = 0;
731 numSrcs = _numSrcs;
732 numMicroops = _numMicroops;
733 field =_field;
734 sizeOfElement = _sizeOfElement;
735 microIdx = _microIdx;
736 micro_vl = _micro_vl;
737
739 (_microIdx * numSrcs)]);
740
742 for (uint8_t i=0; i<_numSrcs; i++) {
744 (microIdx)]);
745 }
746}
747
748Fault
750 trace::InstRecord* traceData) const
751{
752 const uint32_t elems_per_vreg = micro_vl;
753 vreg_t& tmp_d0 = *(vreg_t *)xc->getWritableRegOperand(this, 0);
754 auto Vd = tmp_d0.as<uint8_t>();
755
756 vreg_t tmp_s;
757 auto s = tmp_s.as<uint8_t>();
758 xc->getRegOperand(this, 0, &tmp_s);
759 s = tmp_s.as<uint8_t>();
760
761 uint32_t indexVd = 0;
762 uint32_t srcReg = (field * elems_per_vreg) % numSrcs;
763 uint32_t indexs = (field * elems_per_vreg) / numSrcs;
764
765 while (indexVd < elems_per_vreg) {
766 xc->getRegOperand(this, srcReg, &tmp_s);
767 s = tmp_s.as<uint8_t>();
768
769 memcpy(Vd + (indexVd * sizeOfElement),
770 s + (indexs * sizeOfElement),
772
773 indexVd++;
774 srcReg++;
775 if (srcReg >= numSrcs) {
776 srcReg = 0;
777 indexs++;
778 }
779 }
780
781 if (traceData) {
782 traceData->setData(vecRegClass, &tmp_d0);
783 }
784 return NoFault;
785}
786
787std::string
789 const loader::SymbolTable *symtab) const
790{
791 std::stringstream ss;
792 ss << mnemonic << ' ' << registerName(destRegIdx(0));
793 for (uint8_t i = 0; i < this->_numSrcRegs; i++) {
794 ss << ", " << registerName(srcRegIdx(i));
795 }
796 ss << ", field: " << field;
797 return ss.str();
798}
799
800} // namespace RiscvISA
801} // namespace gem5
The ExecContext is an abstract base class the provides the interface used by the ISA to manipulate th...
virtual void * getWritableRegOperand(const StaticInst *si, int idx)=0
virtual ThreadContext * tcBase() const =0
Returns a pointer to the ThreadContext.
virtual RegVal readMiscReg(int misc_reg)=0
Reads a miscellaneous register, handling any architectural side effects due to reading that register.
virtual void setMiscReg(int misc_reg, RegVal val)=0
Sets a miscellaneous register, handling any architectural side effects due to writing that register.
virtual const PCStateBase & pcState() const =0
virtual RegVal getRegOperand(const StaticInst *si, int idx)=0
Target & as()
Definition pcstate.hh:73
virtual PCStateBase * clone() const =0
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:79
std::string generateZimmDisassembly() const
Definition vector.cc:94
VMaskMergeMicroInst(ExtMachInst extMachInst, uint8_t _dstReg, uint8_t _numSrcs, uint32_t _vlen, size_t _elemSize)
Definition vector.cc:414
std::string generateDisassembly(Addr, const loader::SymbolTable *) const override
Internal function to generate disassembly string.
Definition vector.cc:474
Fault execute(ExecContext *, trace::InstRecord *) const override
Definition vector.cc:438
RegId srcRegIdxArr[NumVecInternalRegs]
Definition vector.hh:552
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:395
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:405
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:156
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:141
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:131
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:203
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:189
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:180
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:171
Fault execute(ExecContext *, trace::InstRecord *) const override
Definition vector.cc:543
std::string generateDisassembly(Addr, const loader::SymbolTable *) const override
Internal function to generate disassembly string.
Definition vector.cc:583
std::unique_ptr< PCStateBase > branchTarget(ThreadContext *) const override
Return the target address for an indirect branch (jump).
Definition vector.cc:572
std::vector< StaticInstPtr > & microops
Definition vector.hh:586
VlFFTrimVlMicroOp(ExtMachInst _machInst, uint32_t _microVl, uint32_t _microIdx, uint32_t _vlen, std::vector< StaticInstPtr > &_microops)
Definition vector.cc:505
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:346
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:357
VlSegDeIntrlvMicroInst(ExtMachInst extMachInst, uint32_t _micro_vl, uint32_t _dstReg, uint32_t _numSrcs, uint32_t _microIdx, uint32_t _numMicroops, uint32_t _field, uint32_t _vlen, uint32_t _sizeOfElement)
Definition vector.cc:617
Fault execute(ExecContext *, trace::InstRecord *) const override
Definition vector.cc:649
RegId srcRegIdxArr[NumVecInternalRegs]
Definition vector.hh:635
std::string generateDisassembly(Addr, const loader::SymbolTable *) const override
Internal function to generate disassembly string.
Definition vector.cc:677
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:591
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:603
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:298
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:309
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:270
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:229
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:260
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:217
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:371
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:382
std::string generateDisassembly(Addr, const loader::SymbolTable *) const override
Internal function to generate disassembly string.
Definition vector.cc:788
VsSegIntrlvMicroInst(ExtMachInst extMachInst, uint32_t _micro_vl, uint32_t _dstReg, uint32_t _numSrcs, uint32_t _microIdx, uint32_t _numMicroops, uint32_t _field, uint32_t _vlen, uint32_t _sizeOfElement)
Definition vector.cc:715
RegId srcRegIdxArr[NumVecInternalRegs]
Definition vector.hh:694
Fault execute(ExecContext *, trace::InstRecord *) const override
Definition vector.cc:749
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:689
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:701
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:322
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:333
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:289
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:250
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:279
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition vector.cc:239
Fault execute(ExecContext *, trace::InstRecord *) const override
Definition vector.cc:488
std::string generateDisassembly(Addr, const loader::SymbolTable *) const override
Internal function to generate disassembly string.
Definition vector.cc:497
void setDestRegIdx(int i, const RegId &val)
void setRegIdxArrays(RegIdArrayPtr src, RegIdArrayPtr dest)
Set the pointers which point to the arrays of source and destination register indices.
std::array< uint8_t, MiscRegClass+1 > _numTypedDestRegs
RegId(StaticInst::*)[] RegIdArrayPtr
uint8_t _numSrcRegs
See numSrcRegs().
uint8_t _numDestRegs
See numDestRegs().
const RegId & destRegIdx(int i) const
Return logical index (architectural reg num) of i'th destination reg.
void setSrcRegIdx(int i, const RegId &val)
const char * mnemonic
Base mnemonic (e.g., "add").
std::bitset< Num_Flags > flags
Flag values for this instruction.
const RegId & srcRegIdx(int i) const
Return logical index (architectural reg num) of i'th source reg.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual const PCStateBase & pcState() const =0
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
Definition vec_reg.hh:126
VecElem * as()
View interposers.
Definition vec_reg.hh:191
void setData(std::array< T, N > d)
STL vector class.
Definition stl.hh:37
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition bitfield.hh:79
constexpr uint64_t sext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
Definition bitfield.hh:129
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:188
Bitfield< 5, 0 > status
constexpr RegClass miscRegClass
Definition misc.hh:2937
Bitfield< 12, 11 > set
Bitfield< 0 > m
float getVflmul(uint32_t vlmul_encoding)
This function translates the 3-bit value of vlmul bits to the corresponding lmul value as specified i...
Definition vector.cc:62
Bitfield< 7 > vma
Definition vector.hh:79
const int VecMemInternalReg0
Definition vector.hh:67
Bitfield< 6 > vta
Definition vector.hh:80
Bitfield< 30, 0 > index
uint32_t getVlmax(VTYPE vtype, uint32_t vlen)
Definition vector.cc:70
std::string registerName(RegId reg)
Definition utility.hh:130
Bitfield< 2 > i
Bitfield< 57, 41 > vl
Definition types.hh:62
Bitfield< 2 > s
Bitfield< 2, 0 > vlmul
Definition vector.hh:82
constexpr RegClass vecRegClass
Definition vector.hh:71
Bitfield< 11, 8 > ss
@ MISCREG_STATUS
Definition misc.hh:76
Bitfield< 4 > pc
uint32_t getSew(uint32_t vsew)
Definition vector.hh:52
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
uint64_t RegVal
Definition types.hh:173
static const OpClass SimdAddOp
Definition op_class.hh:67
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
static const OpClass SimdConfigOp
Definition op_class.hh:134
constexpr decltype(nullptr) NoFault
Definition types.hh:253
@ VecRegClass
Vector Register.
Definition reg_class.hh:64

Generated on Tue Jun 18 2024 16:24:00 for gem5 by doxygen 1.11.0