Fixed bug in fwd branch encoding
authorBenjamin Segovia <segovia.benjamin@gmail.com>
Thu, 3 May 2012 20:17:52 +0000 (20:17 +0000)
committerKeith Packard <keithp@keithp.com>
Fri, 10 Aug 2012 23:17:04 +0000 (16:17 -0700)
backend/src/backend/gen_context.cpp
backend/src/backend/gen_eu.cpp

index 9e1d684..bd2cfb6 100644 (file)
@@ -282,7 +282,7 @@ namespace gbe
       p->push();
         p->curr.flag = 0;
         p->curr.subFlag = 1;
-        p->CMP(GenReg::null(), GEN_CONDITIONAL_G, pred, GenReg::immuw(nextLabel));
+        p->CMP(GenReg::null(), GEN_CONDITIONAL_G, ip, GenReg::immuw(nextLabel));
 
         // Branch to the jump target
         this->branchPos.insert(std::make_pair(&insn, p->insnNum));
index 25b2fc7..7008cd5 100644 (file)
@@ -612,7 +612,11 @@ namespace gbe
     GenInstruction &insn = this->store[insnID];
     assert(insnID < this->insnNum);
     assert(insn.header.opcode == GEN_OPCODE_JMPI);
-    this->setSrc1(&insn, GenReg::retype(GenReg::immw(jumpDistance), GEN_TYPE_D));
+    union { int32_t i32; int16_t i16; } target;
+    target.i32 = 0;
+    target.i16 = int16_t(jumpDistance);
+    //this->setSrc1(&insn, GenReg::retype(GenReg::immw(jumpDistance), GEN_TYPE_D));
+    this->setSrc1(&insn, GenReg::immd(target.i32));
   }
 
   /* To integrate with the above, it makes sense that the comparison