[Beignet] [PATCH 1/2] GBE: support load/store of char/short vector.

Zhigang Gong zhigang.gong at linux.intel.com
Fri May 24 02:46:03 PDT 2013


We just load/store those vector elements one by one.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 backend/src/llvm/llvm_gen_backend.cpp | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 3fe0cbf..0037af2 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -2224,8 +2224,27 @@ namespace gbe
               ctx.STORE(type, tuple, addr, addrSpace, 4, true);
           }
         }
-      } else
-        GBE_ASSERTM(false, "loads / stores of vectors of short / chars is not supported yet");
+      } else {
+        for (uint32_t elemID = 0; elemID < elemNum; elemID++) {
+          const ir::Register reg = this->getRegister(llvmValues, elemID);
+          ir::Register addr;
+          if (elemID == 0)
+            addr = ptr;
+          else {
+              const ir::Register offset = ctx.reg(pointerFamily);
+              ir::ImmediateIndex immIndex;
+              int elemSize = getTypeByteSize(unit, elemType);
+              immIndex = ctx.newImmediate(int32_t(elemID * elemSize));
+              addr = ctx.reg(pointerFamily);
+              ctx.LOADI(ir::TYPE_S32, offset, immIndex);
+              ctx.ADD(ir::TYPE_S32, addr, ptr, offset);
+          }
+          if (isLoad)
+           ctx.LOAD(type, addr, addrSpace, dwAligned, reg);
+          else
+           ctx.STORE(type, addr, addrSpace, dwAligned, reg);
+        }
+      }
     }
   }
 
-- 
1.7.11.7



More information about the Beignet mailing list