GBE: fixed the incorrect max_dst_num and max_src_num.
authorZhigang Gong <zhigang.gong@intel.com>
Tue, 18 Feb 2014 09:41:05 +0000 (17:41 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Mon, 24 Feb 2014 06:54:55 +0000 (14:54 +0800)
Some I64 instructions are using more than 11 dst registers,
this patch change the max src number to 16. And add a assertion
to check if we run into this type of issue again.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
backend/src/backend/gen_insn_selection.cpp
backend/src/backend/gen_insn_selection.hpp

index 697ed1a..53038b2 100644 (file)
@@ -647,6 +647,7 @@ namespace gbe
                                                       uint32_t dstNum,
                                                       uint32_t srcNum)
   {
+    GBE_ASSERT(dstNum <= SelectionInstruction::MAX_DST_NUM && srcNum <= SelectionInstruction::MAX_SRC_NUM);
     GBE_ASSERT(this->block != NULL);
     SelectionInstruction *insn = this->create(opcode, dstNum, srcNum);
     if (this->bwdCodeGeneration)
index cb80d7c..7cbe271 100644 (file)
@@ -85,10 +85,10 @@ namespace gbe
     const GenRegister &dst(uint32_t dstID) const { return regs[dstID]; }
     /*! Damn C++ */
     const GenRegister &src(uint32_t srcID) const { return regs[dstNum+srcID]; }
-    /*! No more than 17 sources (used by typed writes on simd8 mode.) */
-    enum { MAX_SRC_NUM = 17 };
-    /*! No more than 11 destinations (used by samples and untyped reads) */
-    enum { MAX_DST_NUM = 11 };
+    /*! No more than 9 sources (used by typed writes on simd8 mode.) */
+    enum { MAX_SRC_NUM = 9 };
+    /*! No more than 16 destinations (15 used by I64DIV/I64REM) */
+    enum { MAX_DST_NUM = 16 };
     /*! State of the instruction (extra fields neeed for the encoding) */
     GenInstructionState state;
     union {
@@ -127,9 +127,9 @@ namespace gbe
     /*! Gen opcode */
     uint8_t opcode;
     /*! Number of destinations */
-    uint8_t dstNum:4;
+    uint8_t dstNum:5;
     /*! Number of sources */
-    uint8_t srcNum:5;
+    uint8_t srcNum:4;
     /*! To store various indices */
     uint16_t index;
     /*! Variable sized. Destinations and sources go here */