Fix compile warnings for ICC compiler
authorLv Meng <meng.lv@intel.com>
Thu, 14 Aug 2014 03:33:06 +0000 (11:33 +0800)
committerYang Rong <rong.r.yang@intel.com>
Tue, 19 Aug 2014 06:05:42 +0000 (14:05 +0800)
1.the "const" associated functions' modification is to fix "type qualifier on return type is meaningless" for ICC compile warning.
2.the "operator new" shoud have the corresponding "operator delete" function.
3.In C++0x std::auto_ptr will be deprecated in favor of std::unique_ptr.

Signed-off-by: Lv Meng <meng.lv@intel.com>
Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
15 files changed:
backend/src/backend/gen_context.hpp
backend/src/backend/gen_program.cpp
backend/src/backend/gen_program.hpp
backend/src/backend/gen_reg_allocation.cpp
backend/src/backend/program.hpp
backend/src/ir/function.hpp
backend/src/ir/image.cpp
backend/src/ir/image.hpp
backend/src/ir/instruction.cpp
backend/src/ir/instruction.hpp
backend/src/ir/register.hpp
backend/src/llvm/llvm_to_gen.cpp
backend/src/sys/alloc.hpp
utests/utest_helper.cpp
utests/utest_helper.hpp

index 088798d..4a01fd5 100644 (file)
@@ -192,9 +192,9 @@ namespace gbe
     uint32_t reservedSpillRegs;
     bool limitRegisterPressure;
     bool relaxMath;
-    const bool getIFENDIFFix(void) const { return ifEndifFix; }
+    bool getIFENDIFFix(void) const { return ifEndifFix; }
     void setIFENDIFFix(bool fix) { ifEndifFix = fix; }
-    const CompileErrorCode getErrCode() { return errCode; }
+    CompileErrorCode getErrCode() { return errCode; }
 
   protected:
     virtual GenEncoder* generateEncoder(void) {
index 3e16fd6..ce43fd0 100644 (file)
@@ -74,7 +74,7 @@ namespace gbe {
   {}
   GenKernel::~GenKernel(void) { GBE_SAFE_DELETE_ARRAY(insns); }
   const char *GenKernel::getCode(void) const { return (const char*) insns; }
-  const void GenKernel::setCode(const char * ins, size_t size) {
+  void GenKernel::setCode(const char * ins, size_t size) {
     insns = (GenInstruction *)ins;
     insnNum = size / sizeof(GenInstruction);
   }
index 1b5136e..8e8989b 100644 (file)
@@ -44,7 +44,7 @@ namespace gbe
     /*! Implements base class */
     virtual const char *getCode(void) const;
     /*! Set the instruction stream (to be implemented) */
-    virtual const void setCode(const char *, size_t size);
+    virtual void setCode(const char *, size_t size);
     /*! Implements get the code size */
     virtual size_t getCodeSize(void) const;
     /*! Implements printStatus*/
index 524eb76..7d95997 100644 (file)
@@ -60,7 +60,7 @@ namespace gbe
     const ir::Register getReg() const {
       return (ir::Register)(key & 0xFFFF);
     }
-    const int32_t getMaxID() const {
+    int32_t getMaxID() const {
       return key >> 16;
     }
     uint64_t key;
index 8f5f125..6a8af61 100644 (file)
@@ -80,7 +80,7 @@ namespace gbe {
     /*! Return the instruction stream (to be implemented) */
     virtual const char *getCode(void) const = 0;
     /*! Set the instruction stream.*/
-    virtual const void setCode(const char *, size_t size) = 0;
+    virtual void setCode(const char *, size_t size) = 0;
     /*! Return the instruction stream size (to be implemented) */
     virtual size_t getCodeSize(void) const = 0;
     /*! Get the kernel name */
index 7b68c60..c5582b4 100644 (file)
@@ -407,7 +407,7 @@ namespace ir {
     /*! Get required work group size. */
     const size_t *getCompileWorkGroupSize(void) const {return compileWgSize;}
     /*! Get stack size. */
-    INLINE const uint32_t getStackSize(void) const { return this->stackSize; }
+    INLINE uint32_t getStackSize(void) const { return this->stackSize; }
     /*! Push stack size. */
     INLINE void pushStackSize(uint32_t step) { this->stackSize += step; }
     /*! add the loop info for later liveness analysis */
index a9b1563..3362c1b 100644 (file)
@@ -76,8 +76,7 @@ namespace ir {
       imageInfo->channelOrderSlot = -1;
     }
   }
-
-  const int32_t ImageSet::getInfoOffset(ImageInfoKey key) const
+  int32_t ImageSet::getInfoOffset(ImageInfoKey key) const
   {
     auto it = indexMap.find(key.index);
     if (it == indexMap.end())
@@ -86,7 +85,7 @@ namespace ir {
     return getInfoOffset4Type(imageInfo, key.type);
   }
 
-  const uint32_t ImageSet::getIdx(const Register imageReg) const
+  uint32_t ImageSet::getIdx(const Register imageReg) const
   {
     auto it = regMap.find(imageReg);
     GBE_ASSERT(it != regMap.end());
index b31c7da..a435cfe 100644 (file)
@@ -52,11 +52,11 @@ namespace ir {
     /*! clear image info. */
     void clearInfo();
     /*! Get the image's index(actual location). */
-    const uint32_t getIdx(const Register imageReg) const;
+    uint32_t getIdx(const Register imageReg) const;
     size_t getDataSize(void) { return regMap.size(); }
     size_t getDataSize(void) const { return regMap.size(); }
 
-    const int32_t getInfoOffset(ImageInfoKey key) const;
+    int32_t getInfoOffset(ImageInfoKey key) const;
     void getData(struct ImageInfo *imageInfos) const;
     void operator = (const ImageSet& other) {
       regMap.insert(other.regMap.begin(), other.regMap.end());
index aa69148..bfb2000 100644 (file)
@@ -531,11 +531,11 @@ namespace ir {
       Tuple src;
       Tuple dst;
 
-      INLINE const uint8_t getImageIndex(void) const { return this->imageIdx; }
+      INLINE uint8_t getImageIndex(void) const { return this->imageIdx; }
       INLINE Type getSrcType(void) const { return this->srcIsFloat ? TYPE_FLOAT : TYPE_S32; }
       INLINE Type getDstType(void) const { return this->dstIsFloat ? TYPE_FLOAT : TYPE_U32; }
-      INLINE const uint8_t getSamplerIndex(void) const { return this->samplerIdx; }
-      INLINE const uint8_t getSamplerOffset(void) const { return this->samplerOffset; }
+      INLINE uint8_t getSamplerIndex(void) const { return this->samplerIdx; }
+      INLINE uint8_t getSamplerOffset(void) const { return this->samplerOffset; }
       uint8_t srcIsFloat:1;
       uint8_t dstIsFloat:1;
       uint8_t samplerIdx:4;
@@ -578,7 +578,7 @@ namespace ir {
       uint8_t coordType;
       uint8_t imageIdx;
 
-      INLINE const uint8_t getImageIndex(void) const { return this->imageIdx; }
+      INLINE uint8_t getImageIndex(void) const { return this->imageIdx; }
       INLINE Type getSrcType(void) const { return (Type)this->srcType; }
       INLINE Type getCoordType(void) const { return (Type)this->coordType; }
       // bti, u, v, w, 4 data elements
@@ -614,7 +614,7 @@ namespace ir {
             << " info reg %" << this->getSrc(fn, 0);
       }
 
-      INLINE const uint8_t getImageIndex(void) const { return imageIdx; }
+      INLINE uint8_t getImageIndex(void) const { return imageIdx; }
 
       uint8_t infoType;                 //!< Type of the requested information.
       uint8_t imageIdx;                //!< surface index.
@@ -1467,14 +1467,14 @@ DECL_MEM_FN(BranchInstruction, LabelIndex, getLabelIndex(void), getLabelIndex())
 DECL_MEM_FN(SyncInstruction, uint32_t, getParameters(void), getParameters())
 DECL_MEM_FN(SampleInstruction, Type, getSrcType(void), getSrcType())
 DECL_MEM_FN(SampleInstruction, Type, getDstType(void), getDstType())
-DECL_MEM_FN(SampleInstruction, const uint8_t, getSamplerIndex(void), getSamplerIndex())
-DECL_MEM_FN(SampleInstruction, const uint8_t, getSamplerOffset(void), getSamplerOffset())
-DECL_MEM_FN(SampleInstruction, const uint8_t, getImageIndex(void), getImageIndex())
+DECL_MEM_FN(SampleInstruction, uint8_t, getSamplerIndex(void), getSamplerIndex())
+DECL_MEM_FN(SampleInstruction, uint8_t, getSamplerOffset(void), getSamplerOffset())
+DECL_MEM_FN(SampleInstruction, uint8_t, getImageIndex(void), getImageIndex())
 DECL_MEM_FN(TypedWriteInstruction, Type, getSrcType(void), getSrcType())
 DECL_MEM_FN(TypedWriteInstruction, Type, getCoordType(void), getCoordType())
-DECL_MEM_FN(TypedWriteInstruction, const uint8_t, getImageIndex(void), getImageIndex())
+DECL_MEM_FN(TypedWriteInstruction, uint8_t, getImageIndex(void), getImageIndex())
 DECL_MEM_FN(GetImageInfoInstruction, uint32_t, getInfoType(void), getInfoType())
-DECL_MEM_FN(GetImageInfoInstruction, const uint8_t, getImageIndex(void), getImageIndex())
+DECL_MEM_FN(GetImageInfoInstruction, uint8_t, getImageIndex(void), getImageIndex())
 
 #undef DECL_MEM_FN
 
index 0db950d..e245638 100644 (file)
@@ -137,6 +137,7 @@ namespace ir {
       InstructionBase(reinterpret_cast<const char*>(&other.opcode)) {
       parent = other.parent;
     }
+
   private:
     /*! To be consistant with copy constructor */
     INLINE Instruction &operator= (const Instruction &other) { return *this; }
@@ -364,7 +365,7 @@ namespace ir {
   public:
     /*! Return true if the given instruction is an instance of this class */
     static bool isClassOf(const Instruction &insn);
-    const uint8_t getImageIndex() const;
+    uint8_t getImageIndex() const;
     Type getSrcType(void) const;
     Type getCoordType(void) const;
   };
@@ -372,9 +373,9 @@ namespace ir {
   /*! Load texels from a texture */
   class SampleInstruction : public Instruction {
   public:
-    const uint8_t getImageIndex() const;
-    const uint8_t getSamplerIndex(void) const;
-    const uint8_t getSamplerOffset(void) const;
+    uint8_t getImageIndex() const;
+    uint8_t getSamplerIndex(void) const;
+    uint8_t getSamplerOffset(void) const;
     Type getSrcType(void) const;
     Type getDstType(void) const;
     /*! Return true if the given instruction is an instance of this class */
@@ -416,7 +417,7 @@ namespace ir {
      return 0;
    }
 
-    const uint8_t getImageIndex() const;
+    uint8_t getImageIndex() const;
     uint32_t getInfoType() const;
     /*! Return true if the given instruction is an instance of this class */
     static bool isClassOf(const Instruction &insn);
index 7bd4f6e..5995ba5 100644 (file)
@@ -83,7 +83,7 @@ namespace ir {
     /*! Nothing really happens here */
     INLINE ~RegisterData(void) {}
     RegisterFamily family;            //!< Register size or if it is a flag
-    INLINE const bool isUniform() const { return uniform; }
+    INLINE bool isUniform() const { return uniform; }
     INLINE void setUniform(bool uni) { uniform = uni; }
   private:
     bool uniform;
index 3527491..beb36c0 100644 (file)
@@ -186,7 +186,8 @@ namespace gbe
 
     // Get the module from its file
     llvm::SMDiagnostic Err;
-    std::auto_ptr<Module> M;
+    std::unique_ptr<Module> M;
+
     if(fileName){
       // only when module is null, Get the global LLVM context
       llvm::LLVMContext& c = llvm::getGlobalContext();
index 8fcb3a7..7ac91de 100644 (file)
@@ -73,13 +73,15 @@ public: \
   void* operator new(size_t size) { \
     return gbe::alignedMalloc(size, GBE_DEFAULT_ALIGNMENT); \
   } \
+  void  operator delete(void* ptr) { return gbe::alignedFree(ptr); } \
   void* operator new[](size_t size) { \
    return gbe::alignedMalloc(size, GBE_DEFAULT_ALIGNMENT); \
   } \
+  void  operator delete[](void* ptr) { return gbe::alignedFree(ptr); } \
   void* operator new(size_t size, void *p) { return p; } \
+  void  operator delete(void* ptr, void *p) {/*do nothing*/} \
   void* operator new[](size_t size, void *p) { return p; } \
-  void  operator delete(void* ptr) { return gbe::alignedFree(ptr); } \
-  void  operator delete[](void* ptr) { return gbe::alignedFree(ptr); }
+  void  operator delete[](void* ptr, void *p) { /*do nothing*/ }
 
 /*! Macros to handle allocation position */
 #define GBE_NEW(T,...) \
index cb4dd66..90cd11e 100644 (file)
@@ -655,7 +655,7 @@ int cl_check_image(const int *img, int w, int h, const char *bmp)
   return (float(discrepancy) / float(n) > max_error_ratio) ? 0 : 1;
 }
 
-const float cl_FLT_ULP(float float_number)
+float cl_FLT_ULP(float float_number)
 {
   SF floatBin, ulpBin, ulpBinBase;
   floatBin.f = float_number;
@@ -668,7 +668,7 @@ const float cl_FLT_ULP(float float_number)
   return ulpBin.f - ulpBinBase.f;
 }
 
-const int cl_INT_ULP(int int_number)
+int cl_INT_ULP(int int_number)
 {
   return 0;
 }
index de4d277..a434fb4 100644 (file)
@@ -225,10 +225,10 @@ extern void cl_write_bmp(const int *data, int width, int height, const char *fil
 extern int cl_check_image(const int *img, int w, int h, const char *bmp);
 
 /* Calculator ULP of each FLOAT value */
-extern const float cl_FLT_ULP(float float_number);
+extern float cl_FLT_ULP(float float_number);
 
 /* Calculator ULP of each INT value */
-extern const int cl_INT_ULP(int int_number);
+extern int cl_INT_ULP(int int_number);
 
 #endif /* __UTEST_HELPER_HPP__ */