From 91c1afb4691ccffff9c5de85ef4251d39b18165b Mon Sep 17 00:00:00 2001 From: Junyan He Date: Wed, 7 May 2014 18:03:04 +0800 Subject: [PATCH] correct jump distance of hsw's jmpi. 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 Reviewed-by: Junyan He --- backend/src/backend/gen_encoder.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp index 059ea94..ceaa199 100644 --- a/backend/src/backend/gen_encoder.cpp +++ b/backend/src/backend/gen_encoder.cpp @@ -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. -- 2.7.4