[Beignet] [PATCH] [PATCH_V2]Fix compile errors for CLANG compiler

Song, Ruiling ruiling.song at intel.com
Mon Aug 11 19:58:00 PDT 2014


This patch LGTM. A minor problem is make your commit message in good format.

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Lv Meng
Sent: Friday, August 08, 2014 4:10 PM
To: beignet at lists.freedesktop.org
Cc: Lv, Meng
Subject: [Beignet] [PATCH] [PATCH_V2]Fix compile errors for CLANG compiler

use vector to fix "variable length array of non-POD element type" compiler error.
the /beignet/backend/src/./ir/context.hpp "fn->immediates[index] = imm" would call a private func 'operator=' which would trigger error, and it is not being used.
the undefined reference to `check_copy_overlap' would occur in the following calling
Signed-off-by: Lv Meng <meng.lv at intel.com>
---
 backend/src/backend/gen_insn_selection.cpp | 13 ++++++-------
 backend/src/ir/context.hpp                 |  5 -----
 src/cl_api.c                               |  8 ++++----
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/backend/src/backend/gen_insn_selection.cpp b/backend/src/backend/gen_insn_selection.cpp
index 090f897..b7a39af 100644
--- a/backend/src/backend/gen_insn_selection.cpp
+++ b/backend/src/backend/gen_insn_selection.cpp
@@ -2799,11 +2799,11 @@ namespace gbe
       /* XXX support scalar only right now. */
       GBE_ASSERT(valueNum == 1);
       GBE_ASSERT(bti.count == 1);
-      GenRegister dst[valueNum];
+      vector<GenRegister> dst(valueNum);
       GenRegister tmpAddr = getRelativeAddress(sel, addr, insn.getAddressSpace(), bti.bti[0]);
       for ( uint32_t dstID = 0; dstID < valueNum; ++dstID)
         dst[dstID] = sel.selReg(insn.getValue(dstID), ir::TYPE_U64);
-      sel.READ64(tmpAddr, dst, valueNum, bti.bti[0]);
+      sel.READ64(tmpAddr, dst.data(), valueNum, bti.bti[0]);
     }
 
     void readByteAsDWord(Selection::Opaque &sel, @@ -2999,11 +2999,11 @@ namespace gbe
       /* XXX support scalar only right now. */
       GBE_ASSERT(valueNum == 1);
       addr = GenRegister::retype(addr, GEN_TYPE_UD);
-      GenRegister src[valueNum];
+      vector<GenRegister> src(valueNum);
 
       for (uint32_t valueID = 0; valueID < valueNum; ++valueID)
         src[valueID] = sel.selReg(insn.getValue(valueID), ir::TYPE_U64);
-      sel.WRITE64(addr, src, valueNum, bti);
+      sel.WRITE64(addr, src.data(), valueNum, bti);
     }
 
     void emitByteScatter(Selection::Opaque &sel, @@ -3710,11 +3710,10 @@ namespace gbe
     {
       using namespace ir;
       GenRegister msgPayloads[4];
-      GenRegister dst[insn.getDstNum()];
+      vector<GenRegister> dst(insn.getDstNum());
       uint32_t srcNum = insn.getSrcNum();
       uint32_t valueID = 0;
       uint32_t msgLen = 0;
-
       for (valueID = 0; valueID < insn.getDstNum(); ++valueID)
         dst[valueID] = sel.selReg(insn.getDst(valueID), insn.getDstType());
 
@@ -3751,7 +3750,7 @@ namespace gbe
       }
       uint32_t sampler = insn.getSamplerIndex();
 
-      sel.SAMPLE(dst, insn.getDstNum(), msgPayloads, msgLen, bti, sampler, insn.getSamplerOffset() != 0, false);
+      sel.SAMPLE(dst.data(), insn.getDstNum(), msgPayloads, msgLen, 
+ bti, sampler, insn.getSamplerOffset() != 0, false);
       return true;
     }
     DECL_CTOR(SampleInstruction, 1, 1); diff --git a/backend/src/ir/context.hpp b/backend/src/ir/context.hpp index cd09413..ff9e000 100644
--- a/backend/src/ir/context.hpp
+++ b/backend/src/ir/context.hpp
@@ -117,11 +117,6 @@ namespace ir {
       return fn->newImmediate(dstImm);
     }
 
-    /*! Set an immediate value */
-    template <typename T> INLINE void setImmediate(ImmediateIndex index, T value) {
-      const Immediate imm(value);
-      fn->immediates[index] = imm;
-    }
     /*! Create a new register holding the given value. A LOADI is pushed */
     template <typename T> INLINE Register immReg(T value) {
       GBE_ASSERTM(fn != NULL, "No function currently defined"); diff --git a/src/cl_api.c b/src/cl_api.c index 177a7e8..d74df40 100644
--- a/src/cl_api.c
+++ b/src/cl_api.c
@@ -90,10 +90,10 @@ handle_events(cl_command_queue queue, cl_int num, const cl_event *wait_list,  }
 
 /* The following code checking overlap is from Appendix of openCL spec 1.1 */ -inline cl_bool check_copy_overlap(const size_t src_offset[3],
-                                  const size_t dst_offset[3],
-                                  const size_t region[3],
-                                  size_t row_pitch, size_t slice_pitch)
+cl_bool check_copy_overlap(const size_t src_offset[3],
+                           const size_t dst_offset[3],
+                           const size_t region[3],
+                           size_t row_pitch, size_t slice_pitch)
 {
   const size_t src_min[] = {src_offset[0], src_offset[1], src_offset[2]};
   const size_t src_max[] = {src_offset[0] + region[0],
--
1.8.3.2

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list