Get -Wreserved-id-macro clean
This should be a strict refactor,
just taking on some old TODOs.
Change-Id: I084799cbc0a96eaa8d81fbc0aa775b9e18c6a387
Reviewed-on: https://skia-review.googlesource.com/150860
Auto-Submit: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/build/common b/build/common
index a961577..03cf6a8 100644
--- a/build/common
+++ b/build/common
@@ -3,12 +3,10 @@
# Each compiler has enabled all the warnings it can.
# Here we make them errors, and disable a few we don't want bothering us.
-# TODO: -Wno-reserved-id-macro can go away when we refactor skcms_Transform().
warnings = -Werror $
-Wno-double-promotion $
-Wno-float-equal $
-Wno-padded $
- -Wno-reserved-id-macro $
warnings_cc = $warnings $
-Wno-c++98-compat-pedantic $
diff --git a/skcms.cc b/skcms.cc
index 0e93a4c..9d4ea58 100644
--- a/skcms.cc
+++ b/skcms.cc
@@ -1893,39 +1893,15 @@
using U8 = Vec<N,uint8_t>;
#define ATTR __attribute__((target("avx2,f16c")))
-
- // We check these guards to see if we have support for these features.
- // They're likely _not_ defined here in our baseline build config.
- #ifndef __AVX__
- #define __AVX__ 1
- #define UNDEF_AVX
- #endif
- #ifndef __F16C__
- #define __F16C__ 1
- #define UNDEF_F16C
- #endif
- #ifndef __AVX2__
- #define __AVX2__ 1
- #define UNDEF_AVX2
- #endif
+ #define USING_AVX
+ #define USING_AVX_F16C
+ #define USING_AVX2
#include "src/Transform_inl.h"
#undef N
#undef ATTR
-
- #ifdef UNDEF_AVX
- #undef __AVX__
- #undef UNDEF_AVX
- #endif
- #ifdef UNDEF_F16C
- #undef __F16C__
- #undef UNDEF_F16C
- #endif
- #ifdef UNDEF_AVX2
- #undef __AVX2__
- #undef UNDEF_AVX2
- #endif
+ // src/Transform_inl.h will undefine USING_* for us.
}
#define TEST_FOR_HSW
diff --git a/src/Transform_inl.h b/src/Transform_inl.h
index bdf7b5f..effc44a 100644
--- a/src/Transform_inl.h
+++ b/src/Transform_inl.h
@@ -31,15 +31,27 @@
F1 = 1.0f;
#endif
+// Instead of checking __AVX__ below, we'll check USING_AVX.
+// This lets skcms.cc set USING_AVX to force us in even if the compiler's not set that way.
+// Same deal for __F16C__ and __AVX2__ ~~~> USING_AVX_F16C, USING_AVX2.
+
+#if !defined(USING_AVX) && N == 8 && defined(__AVX__)
+ #define USING_AVX
+#endif
+#if !defined(USING_AVX_F16C) && defined(USING_AVX) && defined(__F16C__)
+ #define USING AVX_F16C
+#endif
+#if !defined(USING_AVX2) && defined(USING_AVX) && defined(__AVX2__)
+ #define USING_AVX2
+#endif
+
+// Similar to the AVX+ features, we define USING_NEON and USING_NEON_F16C.
+// This is more for organizational clarity... skcms.cc doesn't force these.
#if N == 4 && defined(__ARM_NEON)
#define USING_NEON
#if __ARM_FP & 2
#define USING_NEON_F16C
#endif
-#elif N == 8 && defined(__AVX__)
- #if defined(__F16C__)
- #define USING_AVX_F16C
- #endif
#endif
// These -Wvector-conversion warnings seem to trigger in very bogus situations,
@@ -191,7 +203,7 @@
return vrndmq_f32(x);
#elif defined(__AVX512F__)
return _mm512_floor_ps(x);
-#elif defined(__AVX__)
+#elif defined(USING_AVX)
return __builtin_ia32_roundps256(x, 0x01/*_MM_FROUND_FLOOR*/);
#elif defined(__SSE4_1__)
return _mm_floor_ps(x);
@@ -353,7 +365,7 @@
return v;
}
-#if !defined(__AVX2__)
+#if !defined(USING_AVX2)
// Helpers for gather_24/48(), loading the ix'th 24/48-bit value from p, and 1/2 extra bytes.
SI ATTR uint32_t load_24_32(const uint8_t* p, int ix) {
return load<uint32_t>(p + 3*ix);
@@ -373,7 +385,7 @@
U32 v = load_24_32(p,ix);
#elif N == 4
U32 v = { load_24_32(p,ix[0]), load_24_32(p,ix[1]), load_24_32(p,ix[2]), load_24_32(p,ix[3]) };
-#elif N == 8 && !defined(__AVX2__)
+#elif N == 8 && !defined(USING_AVX2)
U32 v = { load_24_32(p,ix[0]), load_24_32(p,ix[1]), load_24_32(p,ix[2]), load_24_32(p,ix[3]),
load_24_32(p,ix[4]), load_24_32(p,ix[5]), load_24_32(p,ix[6]), load_24_32(p,ix[7]) };
#elif N == 8
@@ -409,7 +421,7 @@
*v = U64{
load_48_64(p,ix[0]), load_48_64(p,ix[1]), load_48_64(p,ix[2]), load_48_64(p,ix[3]),
};
- #elif N == 8 && !defined(__AVX2__)
+ #elif N == 8 && !defined(USING_AVX2)
*v = U64{
load_48_64(p,ix[0]), load_48_64(p,ix[1]), load_48_64(p,ix[2]), load_48_64(p,ix[3]),
load_48_64(p,ix[4]), load_48_64(p,ix[5]), load_48_64(p,ix[6]), load_48_64(p,ix[7]),
@@ -1126,15 +1138,19 @@
}
// Clean up any #defines we may have set so that we can be #included again.
+#if defined(USING_AVX)
+ #undef USING_AVX
+#endif
+#if defined(USING_AVX_F16C)
+ #undef USING_AVX_F16C
+#endif
+#if defined(USING_AVX2)
+ #undef USING_AVX2
+#endif
#if defined(USING_NEON)
#undef USING_NEON
#endif
-
#if defined(USING_NEON_F16C)
#undef USING_NEON_F16C
#endif
-
-#if defined(USING_AVX_F16C)
- #undef USING_AVX_F16C
-#endif