OSDN Git Service

Work around Visual Studio template specialization issue.
authorNicolas Capens <capn@google.com>
Fri, 2 Sep 2016 10:32:56 +0000 (06:32 -0400)
committerNicolas Capens <nicolascapens@google.com>
Fri, 9 Sep 2016 03:30:34 +0000 (03:30 +0000)
Visual Studio 2015 generates an error for using array_lengthof() on
a template class member array. Since the array content does not
depend on the template types, just make it a global.

BUG=swiftshader:7

Change-Id: If197308413f880484be06e6738f246be144d0ba6
Reviewed-on: https://chromium-review.googlesource.com/380501
Reviewed-by: Jim Stichnoth <stichnot@chromium.org>
Tested-by: Nicolas Capens <nicolascapens@google.com>
src/IceTargetLoweringX86Base.h
src/IceTargetLoweringX86BaseImpl.h

index eaecb40..940954d 100644 (file)
@@ -415,7 +415,6 @@ protected:
   static Type stackSlotType();
 
   static constexpr uint32_t NoSizeLimit = 0;
-  static const Type TypeForSize[];
   /// Returns the largest type which is equal to or larger than Size bytes. The
   /// type is suitable for copying memory i.e. a load and store will be a single
   /// instruction (for example x86 will get f64 not i64).
index c193e76..5f1c31a 100644 (file)
@@ -7655,9 +7655,9 @@ Variable *TargetX86Base<TraitsType>::makeReg(Type Type, RegNumT RegNum) {
   return Reg;
 }
 
-template <typename TraitsType>
-const Type TargetX86Base<TraitsType>::TypeForSize[] = {
-    IceType_i8, IceType_i16, IceType_i32, IceType_f64, IceType_v16i8};
+const Type TypeForSize[] = {IceType_i8, IceType_i16, IceType_i32, IceType_f64,
+                            IceType_v16i8};
+
 template <typename TraitsType>
 Type TargetX86Base<TraitsType>::largestTypeInSize(uint32_t Size,
                                                   uint32_t MaxSize) {