[Beignet] [PATCH] GBE: add an assert at JMPI instruction patching.

Zhigang Gong zhigang.gong at intel.com
Sun Jan 26 17:29:54 PST 2014


Although the immediate data type is 32 bit, the JMPI can only accept
the low 16 bit and will ignore the 16 msb. We need to add an assert here.

Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
 backend/src/backend/gen_encoder.cpp |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/backend/src/backend/gen_encoder.cpp b/backend/src/backend/gen_encoder.cpp
index c372e36..11e27da 100644
--- a/backend/src/backend/gen_encoder.cpp
+++ b/backend/src/backend/gen_encoder.cpp
@@ -1054,8 +1054,9 @@ namespace gbe
 
   void GenEncoder::patchJMPI(uint32_t insnID, int32_t jumpDistance) {
     GenInstruction &insn = this->store[insnID];
-    assert(insnID < this->store.size());
-    assert(insn.header.opcode == GEN_OPCODE_JMPI);
+    GBE_ASSERT(insnID < this->store.size());
+    GBE_ASSERT(insn.header.opcode == GEN_OPCODE_JMPI);
+    GBE_ASSERT(jumpDistance < 32768 && jumpDistance >= -32768);
     this->setSrc1(&insn, GenRegister::immd(jumpDistance));
   }
 
-- 
1.7.9.5



More information about the Beignet mailing list