[Beignet] [PATCH 3/4] GBE: fixed the incorrect max_dst_num and max_src_num.

Zhigang Gong zhigang.gong at intel.com
Tue Feb 18 16:38:14 PST 2014


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 at intel.com>
---
 backend/src/backend/gen_insn_selection.cpp |    1 +
 backend/src/backend/gen_insn_selection.hpp |   12 ++++++------
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 697ed1a..53038b2 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -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)
diff --git a/backend/src/backend/gen_insn_selection.hpp b/backend/src/backend/gen_insn_selection.hpp
index cb80d7c..7cbe271 100644
--- a/backend/src/backend/gen_insn_selection.hpp
+++ b/backend/src/backend/gen_insn_selection.hpp
@@ -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 */
-- 
1.7.9.5



More information about the Beignet mailing list