correct jump distance of hsw's jmpi.
authorJunyan He <junyan.he@linux.intel.com>
Wed, 7 May 2014 10:03:04 +0000 (18:03 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Mon, 12 May 2014 06:42:56 +0000 (14:42 +0800)
Gen5+ bspec: the jump distance is in number of eight-byte units.
Gen7.5+: the offset is in unit of 8bits for JMPI, 64bits for other flow control instructions.
So need multiple all jump distance with 8 in jmpi.

Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Junyan He <junyan.he@linux.intel.com>
backend/src/backend/gen_encoder.cpp

index 059ea94..ceaa199 100644 (file)
@@ -1106,14 +1106,15 @@ namespace gbe
                insn.header.opcode == GEN_OPCODE_BRC);
 
     if (insn.header.opcode != GEN_OPCODE_JMPI || (jumpDistance > -32769 && jumpDistance < 32768))  {
-          int offset = 0;
            if (insn.header.opcode == GEN_OPCODE_IF) {
              this->setSrc1(&insn, GenRegister::immd(jumpDistance));
              return;
            }
-           else if (insn.header.opcode == GEN_OPCODE_JMPI)
-             offset = -2;
-          this->setSrc1(&insn, GenRegister::immd(jumpDistance + offset));
+           else if (insn.header.opcode == GEN_OPCODE_JMPI) {
+             jumpDistance = (jumpDistance - 2)* jump_width;
+           }
+
+           this->setSrc1(&insn, GenRegister::immd(jumpDistance));
     } else if ( insn.header.predicate_control == GEN_PREDICATE_NONE ) {
       // For the conditional jump distance out of S15 range, we need to use an
       // inverted jmp followed by a add ip, ip, distance to implement.