@@ -148,18 +148,21 @@ std::vector<Walrus::ByteCodeStackOffset> ByteCode::getByteCodeStackOffsets(Funct
148
148
FOR_EACH_BYTECODE_LOAD_OP (GENERATE_MEMORY_LOAD_CODE_CASE)
149
149
FOR_EACH_BYTECODE_SIMD_LOAD_EXTEND_OP (GENERATE_MEMORY_LOAD_CODE_CASE)
150
150
FOR_EACH_BYTECODE_SIMD_LOAD_SPLAT_OP (GENERATE_MEMORY_LOAD_CODE_CASE)
151
+ FOR_EACH_BYTECODE_SIMD_ETC_MEMIDX_OP (GENERATE_MEMORY_LOAD_CODE_CASE)
151
152
#undef GENERATE_MEMORY_LOAD_CODE_CASE
152
- {
153
- offsets.push_back (reinterpret_cast <Walrus::MemoryLoad *>(const_cast <ByteCode *>(this ))->srcOffset ());
154
- offsets.push_back (reinterpret_cast <Walrus::MemoryLoad *>(const_cast <ByteCode *>(this ))->dstOffset ());
155
- break ;
156
- }
153
+ case Walrus::ByteCode::V128Load32ZeroOpcode:
154
+ case Walrus::ByteCode::V128Load64ZeroOpcode: {
155
+ offsets.push_back (reinterpret_cast <Walrus::MemoryLoad *>(const_cast <ByteCode *>(this ))->srcOffset ());
156
+ offsets.push_back (reinterpret_cast <Walrus::MemoryLoad *>(const_cast <ByteCode *>(this ))->dstOffset ());
157
+ break ;
158
+ }
157
159
158
160
#define GENERATE_SIMD_MEMORY_LOAD_CASE (name, ...) \
159
161
case Walrus::ByteCode::name##Opcode:
160
162
FOR_EACH_BYTECODE_SIMD_LOAD_LANE_OP (GENERATE_SIMD_MEMORY_LOAD_CASE)
161
163
#undef GENERATE_SIMD_MEMORY_LOAD_CASE
162
164
{
165
+ offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryLoad *>(const_cast <ByteCode *>(this ))->index ());
163
166
offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryLoad *>(const_cast <ByteCode *>(this ))->src0Offset ());
164
167
offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryLoad *>(const_cast <ByteCode *>(this ))->src1Offset ());
165
168
offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryLoad *>(const_cast <ByteCode *>(this ))->dstOffset ());
@@ -192,6 +195,7 @@ std::vector<Walrus::ByteCodeStackOffset> ByteCode::getByteCodeStackOffsets(Funct
192
195
FOR_EACH_BYTECODE_SIMD_STORE_LANE_OP (GENERATE_SIMD_MEMORY_STORE_CASE)
193
196
#undef GENERATE_SIMD_MEMORY_STORE_CASE
194
197
{
198
+ offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryStore *>(const_cast <ByteCode *>(this ))->index ());
195
199
offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryStore *>(const_cast <ByteCode *>(this ))->src0Offset ());
196
200
offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryStore *>(const_cast <ByteCode *>(this ))->src1Offset ());
197
201
break ;
@@ -201,6 +205,7 @@ std::vector<Walrus::ByteCodeStackOffset> ByteCode::getByteCodeStackOffsets(Funct
201
205
FOR_EACH_BYTECODE_SIMD_EXTRACT_LANE_OP (GENERATE_SIMD_EXTRACT_LANE_CODE_CASE)
202
206
#undef GENERATE_SIMD_EXTRACT_LANE_CODE_CASE
203
207
{
208
+ offsets.push_back (reinterpret_cast <Walrus::SIMDExtractLane *>(const_cast <ByteCode *>(this ))->index ());
204
209
offsets.push_back (reinterpret_cast <Walrus::SIMDExtractLane *>(const_cast <ByteCode *>(this ))->srcOffset ());
205
210
offsets.push_back (reinterpret_cast <Walrus::SIMDExtractLane *>(const_cast <ByteCode *>(this ))->dstOffset ());
206
211
break ;
@@ -210,6 +215,7 @@ std::vector<Walrus::ByteCodeStackOffset> ByteCode::getByteCodeStackOffsets(Funct
210
215
FOR_EACH_BYTECODE_SIMD_REPLACE_LANE_OP (GENERATE_SIMD_REPLACE_LANE_CODE_CASE)
211
216
#undef GENERATE_SIMD_REPLACE_LANE_CODE_CASE
212
217
{
218
+ offsets.push_back (reinterpret_cast <Walrus::SIMDReplaceLane *>(const_cast <ByteCode *>(this ))->index ());
213
219
offsets.push_back (reinterpret_cast <Walrus::SIMDReplaceLane *>(const_cast <ByteCode *>(this ))->srcOffsets ()[0 ]);
214
220
offsets.push_back (reinterpret_cast <Walrus::SIMDReplaceLane *>(const_cast <ByteCode *>(this ))->srcOffsets ()[1 ]);
215
221
offsets.push_back (reinterpret_cast <Walrus::SIMDReplaceLane *>(const_cast <ByteCode *>(this ))->dstOffset ());
@@ -541,8 +547,6 @@ void ByteCode::setByteCodeOffset(size_t index, Walrus::ByteCodeStackOffset offse
541
547
}
542
548
break ;
543
549
}
544
-
545
-
546
550
#define GENERATE_BYTECODE_OFFSET2VALUE_MEMIDX_CASE (name, ...) \
547
551
case Walrus::ByteCode::name##Opcode:
548
552
FOR_EACH_BYTECODE_STORE_MEMIDX_OP (GENERATE_BYTECODE_OFFSET2VALUE_MEMIDX_CASE)
@@ -563,30 +567,125 @@ void ByteCode::setByteCodeOffset(size_t index, Walrus::ByteCodeStackOffset offse
563
567
FOR_EACH_BYTECODE_SIMD_LOAD_LANE_OP (GENERATE_SIMD_MEMORY_LOAD_CASE)
564
568
#undef GENERATE_SIMD_MEMORY_LOAD_CASE
565
569
{
570
+ SIMDMemoryLoad *memoryLoad = reinterpret_cast <SIMDMemoryLoad *>(const_cast <ByteCode *>(this ));
571
+ switch (index) {
572
+ case 0 : {
573
+ memoryLoad->setIndex (offset);
574
+ break ;
575
+ }
576
+ case 1 : {
577
+ memoryLoad->setSrc0Offset (offset);
578
+ break ;
579
+ }
580
+ case 2 : {
581
+ memoryLoad->setSrc1Offset (offset);
582
+ break ;
583
+ }
584
+ case 3 : {
585
+ memoryLoad->setDstOffset (offset);
586
+ break ;
587
+ }
588
+ }
566
589
break ;
567
590
}
568
- #define GENERATE_SIMD_MEMORY_STORE_CASE (name, ...) \
591
+ #define GENERATE_SIMD_MEMORY_LOAD_LANE_MEMIDX_CASE (name, ...) \
569
592
case Walrus::ByteCode::name##Opcode:
570
- FOR_EACH_BYTECODE_SIMD_STORE_LANE_OP (GENERATE_SIMD_MEMORY_STORE_CASE)
571
- #undef GENERATE_SIMD_MEMORY_STORE_CASE
593
+ FOR_EACH_BYTECODE_SIMD_LOAD_LANE_MEMIDX_OP (GENERATE_SIMD_MEMORY_LOAD_LANE_MEMIDX_CASE)
594
+ #undef GENERATE_SIMD_MEMORY_LOAD_LANE_MEMIDX_CASE
595
+ {
596
+ SIMDMemoryLoadMemIdx *memoryLoad = reinterpret_cast <SIMDMemoryLoadMemIdx *>(const_cast <ByteCode *>(this ));
597
+ switch (index) {
598
+ case 0 : {
599
+ memoryLoad->setIndex (offset);
600
+ break ;
601
+ }
602
+ case 1 : {
603
+ memoryLoad->setSrc0Offset (offset);
604
+ break ;
605
+ }
606
+ case 2 : {
607
+ memoryLoad->setSrc1Offset (offset);
608
+ break ;
609
+ }
610
+ case 3 : {
611
+ memoryLoad->setDstOffset (offset);
612
+ break ;
613
+ }
614
+ }
615
+ break ;
616
+ }
617
+ #define GENERATE_SIMD_MEMORY_STORE_LANE_CASE (name, ...) \
618
+ case Walrus::ByteCode::name##Opcode:
619
+ FOR_EACH_BYTECODE_SIMD_STORE_LANE_OP (GENERATE_SIMD_MEMORY_STORE_LANE_CASE)
620
+ #undef GENERATE_SIMD_MEMORY_STORE_LANE_CASE
621
+ {
622
+ SIMDMemoryStore *memoryStore = reinterpret_cast <SIMDMemoryStore *>(const_cast <ByteCode *>(this ));
623
+ if (index == 0 ) {
624
+ memoryStore->setIndex (offset);
625
+ } else if (index == 1 ) {
626
+ memoryStore->setSrc0Offset (offset);
627
+ } else {
628
+ memoryStore->setSrc1Offset (offset);
629
+ }
630
+ break ;
631
+ }
632
+ #define GENERATE_SIMD_MEMORY_STORE_LANE_MEMIDX_CASE (name, ...) \
633
+ case Walrus::ByteCode::name##Opcode:
634
+ FOR_EACH_BYTECODE_SIMD_STORE_LANE_MEMIDX_OP (GENERATE_SIMD_MEMORY_STORE_LANE_MEMIDX_CASE)
635
+ #undef GENERATE_SIMD_MEMORY_STORE_LANE_MEMIDX_CASE
572
636
{
637
+ SIMDMemoryStoreMemIdx *memoryStore = reinterpret_cast <SIMDMemoryStoreMemIdx *>(const_cast <ByteCode *>(this ));
638
+ if (index == 0 ) {
639
+ memoryStore->setIndex (offset);
640
+ } else if (index == 1 ) {
641
+ memoryStore->setSrc0Offset (offset);
642
+ } else {
643
+ memoryStore->setSrc1Offset (offset);
644
+ }
573
645
break ;
574
646
}
575
647
#define GENERATE_SIMD_EXTRACT_LANE_CODE_CASE (name, ...) \
576
648
case Walrus::ByteCode::name##Opcode:
577
649
FOR_EACH_BYTECODE_SIMD_EXTRACT_LANE_OP (GENERATE_SIMD_EXTRACT_LANE_CODE_CASE)
578
650
#undef GENERATE_SIMD_EXTRACT_LANE_CODE_CASE
579
651
{
652
+ SIMDExtractLane *extractLane = reinterpret_cast <SIMDExtractLane *>(const_cast <ByteCode *>(this ));
653
+ if (index == 0 ) {
654
+ extractLane->setIndex (offset);
655
+ } else if (index == 1 ) {
656
+ extractLane->setSrcOffset (offset);
657
+ } else {
658
+ extractLane->setDstOffset (offset);
659
+ }
580
660
break ;
581
661
}
582
662
#define GENERATE_SIMD_REPLACE_LANE_CODE_CASE (name, ...) \
583
663
case Walrus::ByteCode::name##Opcode:
584
664
FOR_EACH_BYTECODE_SIMD_REPLACE_LANE_OP (GENERATE_SIMD_REPLACE_LANE_CODE_CASE)
585
665
#undef GENERATE_SIMD_REPLACE_LANE_CODE_CASE
586
666
{
667
+ SIMDReplaceLane *replaceLane = reinterpret_cast <SIMDReplaceLane *>(const_cast <ByteCode *>(this ));
668
+
669
+ switch (index) {
670
+ case 0 : {
671
+ replaceLane->setIndex (offset);
672
+ break ;
673
+ }
674
+ case 1 : {
675
+ replaceLane->setSrc0Offset (offset);
676
+ break ;
677
+ }
678
+ case 2 : {
679
+ replaceLane->setSrc1Offset (offset);
680
+ break ;
681
+ }
682
+ case 3 : {
683
+ replaceLane->setDstOffset (offset);
684
+ break ;
685
+ }
686
+ }
587
687
break ;
588
688
}
589
- // Special cases that require manual handling. This list needs to be extended if new byte codes are introduced.
590
689
case Walrus::ByteCode::SelectOpcode: {
591
690
Walrus::Select *sel = reinterpret_cast <Walrus::Select *>(const_cast <ByteCode *>(this ));
592
691
switch (index) {
@@ -620,6 +719,8 @@ void ByteCode::setByteCodeOffset(size_t index, Walrus::ByteCodeStackOffset offse
620
719
break ;
621
720
}
622
721
case Walrus::ByteCode::MemorySizeOpcode: {
722
+ MemorySize *memorySize = reinterpret_cast <Walrus::MemorySize *>(const_cast <ByteCode *>(this ));
723
+ memorySize->setDstOffset (offset);
623
724
break ;
624
725
}
625
726
case Walrus::ByteCode::MemoryInitOpcode: {
0 commit comments