@@ -143,18 +143,21 @@ std::vector<Walrus::ByteCodeStackOffset> ByteCode::getByteCodeStackOffsets(Funct
143143 FOR_EACH_BYTECODE_LOAD_OP (GENERATE_MEMORY_LOAD_CODE_CASE)
144144 FOR_EACH_BYTECODE_SIMD_LOAD_EXTEND_OP (GENERATE_MEMORY_LOAD_CODE_CASE)
145145 FOR_EACH_BYTECODE_SIMD_LOAD_SPLAT_OP (GENERATE_MEMORY_LOAD_CODE_CASE)
146+ FOR_EACH_BYTECODE_SIMD_ETC_MEMIDX_OP (GENERATE_MEMORY_LOAD_CODE_CASE)
146147#undef GENERATE_MEMORY_LOAD_CODE_CASE
147- {
148- offsets.push_back (reinterpret_cast <Walrus::MemoryLoad *>(const_cast <ByteCode *>(this ))->srcOffset ());
149- offsets.push_back (reinterpret_cast <Walrus::MemoryLoad *>(const_cast <ByteCode *>(this ))->dstOffset ());
150- break ;
151- }
148+ case Walrus::ByteCode::V128Load32ZeroOpcode:
149+ case Walrus::ByteCode::V128Load64ZeroOpcode: {
150+ offsets.push_back (reinterpret_cast <Walrus::MemoryLoad *>(const_cast <ByteCode *>(this ))->srcOffset ());
151+ offsets.push_back (reinterpret_cast <Walrus::MemoryLoad *>(const_cast <ByteCode *>(this ))->dstOffset ());
152+ break ;
153+ }
152154
153155#define GENERATE_SIMD_MEMORY_LOAD_CASE (name, ...) \
154156 case Walrus::ByteCode::name##Opcode:
155157 FOR_EACH_BYTECODE_SIMD_LOAD_LANE_OP (GENERATE_SIMD_MEMORY_LOAD_CASE)
156158#undef GENERATE_SIMD_MEMORY_LOAD_CASE
157159 {
160+ offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryLoad *>(const_cast <ByteCode *>(this ))->index ());
158161 offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryLoad *>(const_cast <ByteCode *>(this ))->src0Offset ());
159162 offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryLoad *>(const_cast <ByteCode *>(this ))->src1Offset ());
160163 offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryLoad *>(const_cast <ByteCode *>(this ))->dstOffset ());
@@ -187,6 +190,7 @@ std::vector<Walrus::ByteCodeStackOffset> ByteCode::getByteCodeStackOffsets(Funct
187190 FOR_EACH_BYTECODE_SIMD_STORE_LANE_OP (GENERATE_SIMD_MEMORY_STORE_CASE)
188191#undef GENERATE_SIMD_MEMORY_STORE_CASE
189192 {
193+ offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryStore *>(const_cast <ByteCode *>(this ))->index ());
190194 offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryStore *>(const_cast <ByteCode *>(this ))->src0Offset ());
191195 offsets.push_back (reinterpret_cast <Walrus::SIMDMemoryStore *>(const_cast <ByteCode *>(this ))->src1Offset ());
192196 break ;
@@ -196,6 +200,7 @@ std::vector<Walrus::ByteCodeStackOffset> ByteCode::getByteCodeStackOffsets(Funct
196200 FOR_EACH_BYTECODE_SIMD_EXTRACT_LANE_OP (GENERATE_SIMD_EXTRACT_LANE_CODE_CASE)
197201#undef GENERATE_SIMD_EXTRACT_LANE_CODE_CASE
198202 {
203+ offsets.push_back (reinterpret_cast <Walrus::SIMDExtractLane *>(const_cast <ByteCode *>(this ))->index ());
199204 offsets.push_back (reinterpret_cast <Walrus::SIMDExtractLane *>(const_cast <ByteCode *>(this ))->srcOffset ());
200205 offsets.push_back (reinterpret_cast <Walrus::SIMDExtractLane *>(const_cast <ByteCode *>(this ))->dstOffset ());
201206 break ;
@@ -205,6 +210,7 @@ std::vector<Walrus::ByteCodeStackOffset> ByteCode::getByteCodeStackOffsets(Funct
205210 FOR_EACH_BYTECODE_SIMD_REPLACE_LANE_OP (GENERATE_SIMD_REPLACE_LANE_CODE_CASE)
206211#undef GENERATE_SIMD_REPLACE_LANE_CODE_CASE
207212 {
213+ offsets.push_back (reinterpret_cast <Walrus::SIMDReplaceLane *>(const_cast <ByteCode *>(this ))->index ());
208214 offsets.push_back (reinterpret_cast <Walrus::SIMDReplaceLane *>(const_cast <ByteCode *>(this ))->srcOffsets ()[0 ]);
209215 offsets.push_back (reinterpret_cast <Walrus::SIMDReplaceLane *>(const_cast <ByteCode *>(this ))->srcOffsets ()[1 ]);
210216 offsets.push_back (reinterpret_cast <Walrus::SIMDReplaceLane *>(const_cast <ByteCode *>(this ))->dstOffset ());
@@ -536,8 +542,6 @@ void ByteCode::setByteCodeOffset(size_t index, Walrus::ByteCodeStackOffset offse
536542 }
537543 break ;
538544 }
539-
540-
541545#define GENERATE_BYTECODE_OFFSET2VALUE_MEMIDX_CASE (name, ...) \
542546 case Walrus::ByteCode::name##Opcode:
543547 FOR_EACH_BYTECODE_STORE_MEMIDX_OP (GENERATE_BYTECODE_OFFSET2VALUE_MEMIDX_CASE)
@@ -558,30 +562,125 @@ void ByteCode::setByteCodeOffset(size_t index, Walrus::ByteCodeStackOffset offse
558562 FOR_EACH_BYTECODE_SIMD_LOAD_LANE_OP (GENERATE_SIMD_MEMORY_LOAD_CASE)
559563#undef GENERATE_SIMD_MEMORY_LOAD_CASE
560564 {
565+ SIMDMemoryLoad *memoryLoad = reinterpret_cast <SIMDMemoryLoad *>(const_cast <ByteCode *>(this ));
566+ switch (index) {
567+ case 0 : {
568+ memoryLoad->setIndex (offset);
569+ break ;
570+ }
571+ case 1 : {
572+ memoryLoad->setSrc0Offset (offset);
573+ break ;
574+ }
575+ case 2 : {
576+ memoryLoad->setSrc1Offset (offset);
577+ break ;
578+ }
579+ case 3 : {
580+ memoryLoad->setDstOffset (offset);
581+ break ;
582+ }
583+ }
561584 break ;
562585 }
563- #define GENERATE_SIMD_MEMORY_STORE_CASE (name, ...) \
586+ #define GENERATE_SIMD_MEMORY_LOAD_LANE_MEMIDX_CASE (name, ...) \
564587 case Walrus::ByteCode::name##Opcode:
565- FOR_EACH_BYTECODE_SIMD_STORE_LANE_OP (GENERATE_SIMD_MEMORY_STORE_CASE)
566- #undef GENERATE_SIMD_MEMORY_STORE_CASE
588+ FOR_EACH_BYTECODE_SIMD_LOAD_LANE_MEMIDX_OP (GENERATE_SIMD_MEMORY_LOAD_LANE_MEMIDX_CASE)
589+ #undef GENERATE_SIMD_MEMORY_LOAD_LANE_MEMIDX_CASE
590+ {
591+ SIMDMemoryLoadMemIdx *memoryLoad = reinterpret_cast <SIMDMemoryLoadMemIdx *>(const_cast <ByteCode *>(this ));
592+ switch (index) {
593+ case 0 : {
594+ memoryLoad->setIndex (offset);
595+ break ;
596+ }
597+ case 1 : {
598+ memoryLoad->setSrc0Offset (offset);
599+ break ;
600+ }
601+ case 2 : {
602+ memoryLoad->setSrc1Offset (offset);
603+ break ;
604+ }
605+ case 3 : {
606+ memoryLoad->setDstOffset (offset);
607+ break ;
608+ }
609+ }
610+ break ;
611+ }
612+ #define GENERATE_SIMD_MEMORY_STORE_LANE_CASE (name, ...) \
613+ case Walrus::ByteCode::name##Opcode:
614+ FOR_EACH_BYTECODE_SIMD_STORE_LANE_OP (GENERATE_SIMD_MEMORY_STORE_LANE_CASE)
615+ #undef GENERATE_SIMD_MEMORY_STORE_LANE_CASE
616+ {
617+ SIMDMemoryStore *memoryStore = reinterpret_cast <SIMDMemoryStore *>(const_cast <ByteCode *>(this ));
618+ if (index == 0 ) {
619+ memoryStore->setIndex (offset);
620+ } else if (index == 1 ) {
621+ memoryStore->setSrc0Offset (offset);
622+ } else {
623+ memoryStore->setSrc1Offset (offset);
624+ }
625+ break ;
626+ }
627+ #define GENERATE_SIMD_MEMORY_STORE_LANE_MEMIDX_CASE (name, ...) \
628+ case Walrus::ByteCode::name##Opcode:
629+ FOR_EACH_BYTECODE_SIMD_STORE_LANE_MEMIDX_OP (GENERATE_SIMD_MEMORY_STORE_LANE_MEMIDX_CASE)
630+ #undef GENERATE_SIMD_MEMORY_STORE_LANE_MEMIDX_CASE
567631 {
632+ SIMDMemoryStoreMemIdx *memoryStore = reinterpret_cast <SIMDMemoryStoreMemIdx *>(const_cast <ByteCode *>(this ));
633+ if (index == 0 ) {
634+ memoryStore->setIndex (offset);
635+ } else if (index == 1 ) {
636+ memoryStore->setSrc0Offset (offset);
637+ } else {
638+ memoryStore->setSrc1Offset (offset);
639+ }
568640 break ;
569641 }
570642#define GENERATE_SIMD_EXTRACT_LANE_CODE_CASE (name, ...) \
571643 case Walrus::ByteCode::name##Opcode:
572644 FOR_EACH_BYTECODE_SIMD_EXTRACT_LANE_OP (GENERATE_SIMD_EXTRACT_LANE_CODE_CASE)
573645#undef GENERATE_SIMD_EXTRACT_LANE_CODE_CASE
574646 {
647+ SIMDExtractLane *extractLane = reinterpret_cast <SIMDExtractLane *>(const_cast <ByteCode *>(this ));
648+ if (index == 0 ) {
649+ extractLane->setIndex (offset);
650+ } else if (index == 1 ) {
651+ extractLane->setSrcOffset (offset);
652+ } else {
653+ extractLane->setDstOffset (offset);
654+ }
575655 break ;
576656 }
577657#define GENERATE_SIMD_REPLACE_LANE_CODE_CASE (name, ...) \
578658 case Walrus::ByteCode::name##Opcode:
579659 FOR_EACH_BYTECODE_SIMD_REPLACE_LANE_OP (GENERATE_SIMD_REPLACE_LANE_CODE_CASE)
580660#undef GENERATE_SIMD_REPLACE_LANE_CODE_CASE
581661 {
662+ SIMDReplaceLane *replaceLane = reinterpret_cast <SIMDReplaceLane *>(const_cast <ByteCode *>(this ));
663+
664+ switch (index) {
665+ case 0 : {
666+ replaceLane->setIndex (offset);
667+ break ;
668+ }
669+ case 1 : {
670+ replaceLane->setSrc0Offset (offset);
671+ break ;
672+ }
673+ case 2 : {
674+ replaceLane->setSrc1Offset (offset);
675+ break ;
676+ }
677+ case 3 : {
678+ replaceLane->setDstOffset (offset);
679+ break ;
680+ }
681+ }
582682 break ;
583683 }
584- // Special cases that require manual handling. This list needs to be extended if new byte codes are introduced.
585684 case Walrus::ByteCode::SelectOpcode: {
586685 Walrus::Select *sel = reinterpret_cast <Walrus::Select *>(const_cast <ByteCode *>(this ));
587686 switch (index) {
@@ -615,6 +714,8 @@ void ByteCode::setByteCodeOffset(size_t index, Walrus::ByteCodeStackOffset offse
615714 break ;
616715 }
617716 case Walrus::ByteCode::MemorySizeOpcode: {
717+ MemorySize *memorySize = reinterpret_cast <Walrus::MemorySize *>(const_cast <ByteCode *>(this ));
718+ memorySize->setDstOffset (offset);
618719 break ;
619720 }
620721 case Walrus::ByteCode::MemoryInitOpcode: {
0 commit comments