void GenEncoder::patchJMPI(uint32_t insnID, int32_t jumpDistance) {
GenNativeInstruction &insn = *(GenNativeInstruction *)&this->store[insnID];
- GenNativeInstruction &insn2 = *(GenNativeInstruction *)&this->store[insnID+2];
GBE_ASSERT(insnID < this->store.size());
GBE_ASSERT(insn.header.opcode == GEN_OPCODE_JMPI ||
insn.header.opcode == GEN_OPCODE_BRD ||
// for all the branching instruction. And need to adjust the distance
// for those branch instruction's start point and end point contains
// this instruction.
- GBE_ASSERT(insn2.header.opcode == GEN_OPCODE_NOP);
+ GenNativeInstruction *insn2 = (GenNativeInstruction *)&this->store[insnID+2];
+ GBE_ASSERT(insn2->header.opcode == GEN_OPCODE_NOP);
+ insn2 = insn2;
insn.header.opcode = GEN_OPCODE_ADD;
this->setDst(&insn, GenRegister::ip());
this->setSrc0(&insn, GenRegister::ip());
this->setSrc1(&insn, GenRegister::immd(jumpDistance * 8));
} else {
+ GenNativeInstruction &insn2 = *(GenNativeInstruction *)&this->store[insnID+2];
insn.header.predicate_inverse ^= 1;
this->setSrc1(&insn, GenRegister::immd(2));
GBE_ASSERT(insn2.header.opcode == GEN_OPCODE_NOP);