Skip to content

Commit

Permalink
base: rename WUFFS_BASE__CPU_ARCH__ETC
Browse files Browse the repository at this point in the history
See
#148 (comment)

Updates #148
  • Loading branch information
nigeltao committed Jul 8, 2024
1 parent 5d4bb4c commit 37a3c3c
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 167 deletions.
38 changes: 19 additions & 19 deletions internal/cgen/base/fundamental-public.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
// intrinsics. Look for __ARM_FEATURE_CRC32 instead.
#if defined(__ARM_FEATURE_CRC32)
#include <arm_acle.h>
#define WUFFS_BASE__CPU_ARCH__ARM_CRC32
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__ARM_CRC32
#endif // defined(__ARM_FEATURE_CRC32)
#if defined(__ARM_NEON)
#include <arm_neon.h>
#define WUFFS_BASE__CPU_ARCH__ARM_NEON
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__ARM_NEON
#endif // defined(__ARM_NEON)
#endif // defined(__ARM_FEATURE_UNALIGNED) etc

Expand All @@ -77,9 +77,9 @@
#include <cpuid.h>
#include <x86intrin.h>
// X86_FAMILY means X86 (32-bit) or X86_64 (64-bit, obviously).
#define WUFFS_BASE__CPU_ARCH__X86_FAMILY
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_FAMILY
#if defined(__x86_64__)
#define WUFFS_BASE__CPU_ARCH__X86_64
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64
#endif // defined(__x86_64__)
#endif // !defined(__native_client__)
#endif // defined(__i386__) || defined(__x86_64__)
Expand All @@ -101,9 +101,9 @@
#include <nmmintrin.h> // SSE4.2
#include <wmmintrin.h> // AES, PCLMUL
// X86_FAMILY means X86 (32-bit) or X86_64 (64-bit, obviously).
#define WUFFS_BASE__CPU_ARCH__X86_FAMILY
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_FAMILY
#if defined(_M_X64)
#define WUFFS_BASE__CPU_ARCH__X86_64
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64
#endif // defined(_M_X64)

#else // defined(__AVX__) || defined(__clang__)
Expand Down Expand Up @@ -141,20 +141,20 @@

static inline bool //
wuffs_base__cpu_arch__have_arm_crc32(void) {
#if defined(WUFFS_BASE__CPU_ARCH__ARM_CRC32)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__ARM_CRC32)
return true;
#else
return false;
#endif // defined(WUFFS_BASE__CPU_ARCH__ARM_CRC32)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__ARM_CRC32)
}

static inline bool //
wuffs_base__cpu_arch__have_arm_neon(void) {
#if defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__ARM_NEON)
return true;
#else
return false;
#endif // defined(WUFFS_BASE__CPU_ARCH__ARM_NEON)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__ARM_NEON)
}

static inline bool //
Expand All @@ -163,7 +163,7 @@ wuffs_base__cpu_arch__have_x86_avx2(void) {
defined(__AVX2__)
return true;
#else
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
// GCC defines these macros but MSVC does not.
// - bit_AVX2 = (1 << 5)
const unsigned int avx2_ebx7 = 0x00000020;
Expand Down Expand Up @@ -201,9 +201,9 @@ wuffs_base__cpu_arch__have_x86_avx2(void) {
}
}
#else
#error "WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler"
#error "WUFFS_PRIVATE_IMPL__CPU_ARCH__ETC combined with an unsupported compiler"
#endif // defined(__GNUC__); defined(_MSC_VER)
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
return false;
#endif // defined(__PCLMUL__) && defined(__POPCNT__) && defined(__SSE4_2__) &&
// defined(__AVX2__)
Expand All @@ -214,7 +214,7 @@ wuffs_base__cpu_arch__have_x86_bmi2(void) {
#if defined(__BMI2__)
return true;
#else
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
// GCC defines these macros but MSVC does not.
// - bit_BMI2 = (1 << 8)
const unsigned int bmi2_ebx7 = 0x00000100;
Expand All @@ -236,9 +236,9 @@ wuffs_base__cpu_arch__have_x86_bmi2(void) {
return true;
}
#else
#error "WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler"
#error "WUFFS_PRIVATE_IMPL__CPU_ARCH__ETC combined with an unsupported compiler"
#endif // defined(__GNUC__); defined(_MSC_VER)
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
return false;
#endif // defined(__BMI2__)
}
Expand All @@ -248,7 +248,7 @@ wuffs_base__cpu_arch__have_x86_sse42(void) {
#if defined(__PCLMUL__) && defined(__POPCNT__) && defined(__SSE4_2__)
return true;
#else
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
// GCC defines these macros but MSVC does not.
// - bit_PCLMUL = (1 << 1)
// - bit_POPCNT = (1 << 23)
Expand All @@ -272,9 +272,9 @@ wuffs_base__cpu_arch__have_x86_sse42(void) {
return true;
}
#else
#error "WUFFS_BASE__CPU_ARCH__ETC combined with an unsupported compiler"
#error "WUFFS_PRIVATE_IMPL__CPU_ARCH__ETC combined with an unsupported compiler"
#endif // defined(__GNUC__); defined(_MSC_VER)
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
return false;
#endif // defined(__PCLMUL__) && defined(__POPCNT__) && defined(__SSE4_2__)
}
Expand Down
34 changes: 17 additions & 17 deletions internal/cgen/base/pixconv-submodule-regular.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// ---------------- Pixel Swizzler

#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET("pclmul,popcnt,sse4.2")
static uint64_t //
wuffs_private_impl__swizzle_bgrw__bgr__x86_sse42(uint8_t* dst_ptr,
Expand Down Expand Up @@ -45,7 +45,7 @@ wuffs_private_impl__swizzle_xxxx__y__x86_sse42(uint8_t* dst_ptr,
size_t dst_palette_len,
const uint8_t* src_ptr,
size_t src_len);
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)

// --------

Expand Down Expand Up @@ -881,7 +881,7 @@ wuffs_private_impl__swizzle_swap_rgb_bgr(uint8_t* dst_ptr,
}

// ‼ WUFFS MULTI-FILE SECTION +x86_sse42
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET("pclmul,popcnt,sse4.2")
static uint64_t //
wuffs_private_impl__swizzle_swap_rgbx_bgrx__x86_sse42(uint8_t* dst_ptr,
Expand Down Expand Up @@ -925,7 +925,7 @@ wuffs_private_impl__swizzle_swap_rgbx_bgrx__x86_sse42(uint8_t* dst_ptr,
}
return len;
}
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
// ‼ WUFFS MULTI-FILE SECTION -x86_sse42

static uint64_t //
Expand Down Expand Up @@ -3593,7 +3593,7 @@ wuffs_private_impl__swizzle_bgrw__bgrx(uint8_t* dst_ptr,
}

// ‼ WUFFS MULTI-FILE SECTION +x86_sse42
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET("pclmul,popcnt,sse4.2")
static uint64_t //
wuffs_private_impl__swizzle_bgrw__bgr__x86_sse42(uint8_t* dst_ptr,
Expand Down Expand Up @@ -3699,7 +3699,7 @@ wuffs_private_impl__swizzle_bgrw__rgb__x86_sse42(uint8_t* dst_ptr,

return len;
}
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
// ‼ WUFFS MULTI-FILE SECTION -x86_sse42

static uint64_t //
Expand Down Expand Up @@ -4457,7 +4457,7 @@ wuffs_private_impl__swizzle_xxxx__index_binary_alpha__src_over(
}

// ‼ WUFFS MULTI-FILE SECTION +x86_sse42
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET("pclmul,popcnt,sse4.2")
static uint64_t //
wuffs_private_impl__swizzle_xxxx__y__x86_sse42(uint8_t* dst_ptr,
Expand Down Expand Up @@ -4504,7 +4504,7 @@ wuffs_private_impl__swizzle_xxxx__y__x86_sse42(uint8_t* dst_ptr,

return len;
}
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
// ‼ WUFFS MULTI-FILE SECTION -x86_sse42

static uint64_t //
Expand Down Expand Up @@ -4906,7 +4906,7 @@ wuffs_private_impl__pixel_swizzler__prepare__y(
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:
case WUFFS_BASE__PIXEL_FORMAT__RGBX:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_xxxx__y__x86_sse42;
}
Expand Down Expand Up @@ -5377,7 +5377,7 @@ wuffs_private_impl__pixel_swizzler__prepare__bgr(
case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:
case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:
case WUFFS_BASE__PIXEL_FORMAT__BGRX:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_bgrw__bgr__x86_sse42;
}
Expand All @@ -5395,7 +5395,7 @@ wuffs_private_impl__pixel_swizzler__prepare__bgr(
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:
case WUFFS_BASE__PIXEL_FORMAT__RGBX:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_bgrw__rgb__x86_sse42;
}
Expand Down Expand Up @@ -5484,7 +5484,7 @@ wuffs_private_impl__pixel_swizzler__prepare__bgra_nonpremul(
case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:
switch (blend) {
case WUFFS_BASE__PIXEL_BLEND__SRC:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_swap_rgbx_bgrx__x86_sse42;
}
Expand Down Expand Up @@ -5679,7 +5679,7 @@ wuffs_private_impl__pixel_swizzler__prepare__bgra_premul(
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
switch (blend) {
case WUFFS_BASE__PIXEL_BLEND__SRC:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_swap_rgbx_bgrx__x86_sse42;
}
Expand Down Expand Up @@ -5751,7 +5751,7 @@ wuffs_private_impl__pixel_swizzler__prepare__rgb(
case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:
case WUFFS_BASE__PIXEL_FORMAT__BGRA_BINARY:
case WUFFS_BASE__PIXEL_FORMAT__BGRX:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_bgrw__rgb__x86_sse42;
}
Expand All @@ -5768,7 +5768,7 @@ wuffs_private_impl__pixel_swizzler__prepare__rgb(
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
case WUFFS_BASE__PIXEL_FORMAT__RGBA_BINARY:
case WUFFS_BASE__PIXEL_FORMAT__RGBX:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_bgrw__bgr__x86_sse42;
}
Expand Down Expand Up @@ -5807,7 +5807,7 @@ wuffs_private_impl__pixel_swizzler__prepare__rgba_nonpremul(
case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:
switch (blend) {
case WUFFS_BASE__PIXEL_BLEND__SRC:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_swap_rgbx_bgrx__x86_sse42;
}
Expand Down Expand Up @@ -5923,7 +5923,7 @@ wuffs_private_impl__pixel_swizzler__prepare__rgba_premul(
case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:
switch (blend) {
case WUFFS_BASE__PIXEL_BLEND__SRC:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_sse42()) {
return wuffs_private_impl__swizzle_swap_rgbx_bgrx__x86_sse42;
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cgen/base/pixconv-submodule-x86-avx2.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// --------

// ‼ WUFFS MULTI-FILE SECTION +x86_avx2
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET("pclmul,popcnt,sse4.2,avx2")
static void //
wuffs_private_impl__swizzle_ycc__convert_3_bgrx_x86_avx2(
Expand Down Expand Up @@ -636,5 +636,5 @@ wuffs_private_impl__swizzle_ycc__upsample_inv_h2v2_triangle_x86_avx2(
return dst_ptr;
}
#endif
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
// ‼ WUFFS MULTI-FILE SECTION -x86_avx2
10 changes: 5 additions & 5 deletions internal/cgen/base/pixconv-submodule-ycck.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// --------

#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
WUFFS_BASE__MAYBE_ATTRIBUTE_TARGET("pclmul,popcnt,sse4.2,avx2")
static void //
wuffs_private_impl__swizzle_ycc__convert_3_bgrx_x86_avx2(
Expand Down Expand Up @@ -47,7 +47,7 @@ wuffs_private_impl__swizzle_ycc__upsample_inv_h2v2_triangle_x86_avx2(
bool first_column,
bool last_column);
#endif
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_64)
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)

// --------

Expand Down Expand Up @@ -1277,7 +1277,7 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
case WUFFS_BASE__PIXEL_FORMAT__BGRA_NONPREMUL:
case WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL:
case WUFFS_BASE__PIXEL_FORMAT__BGRX:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_avx2()) {
conv3func = &wuffs_private_impl__swizzle_ycc__convert_3_bgrx_x86_avx2;
break;
Expand All @@ -1288,7 +1288,7 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
case WUFFS_BASE__PIXEL_FORMAT__RGBA_NONPREMUL:
case WUFFS_BASE__PIXEL_FORMAT__RGBA_PREMUL:
case WUFFS_BASE__PIXEL_FORMAT__RGBX:
#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
if (wuffs_base__cpu_arch__have_x86_avx2()) {
conv3func = &wuffs_private_impl__swizzle_ycc__convert_3_rgbx_x86_avx2;
break;
Expand Down Expand Up @@ -1338,7 +1338,7 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
upfuncs[1][0] = wuffs_private_impl__swizzle_ycc__upsample_inv_h2v1_triangle;
upfuncs[1][1] = wuffs_private_impl__swizzle_ycc__upsample_inv_h2v2_triangle;

#if defined(WUFFS_BASE__CPU_ARCH__X86_64)
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
#if defined(__GNUC__) && !defined(__clang__)
// Don't use our AVX2 implementation for GCC (but do use it for clang). For
// some unknown reason, GCC performs noticably better on the non-SIMD
Expand Down
8 changes: 4 additions & 4 deletions internal/cgen/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,14 @@ func (g *gen) writeFuncPrototype(b *buffer, n *a.Func) error {
return err
}
if caMacro != "" {
b.printf("#if defined(WUFFS_BASE__CPU_ARCH__%s)\n", caMacro)
b.printf("#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__%s)\n", caMacro)
}
if err := g.writeFuncSignature(b, n, wfsCDecl); err != nil {
return err
}
b.writes(";\n")
if caMacro != "" {
b.printf("#endif // defined(WUFFS_BASE__CPU_ARCH__%s)\n", caMacro)
b.printf("#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__%s)\n", caMacro)
}
b.writes("\n")
if n.Choosy() {
Expand All @@ -237,7 +237,7 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
}
b.printf("// -------- func %s.%s\n\n", g.pkgName, n.QQID().Str(g.tm))
if caMacro != "" {
b.printf("#if defined(WUFFS_BASE__CPU_ARCH__%s)\n", caMacro)
b.printf("#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__%s)\n", caMacro)
}
if caAttribute != "" {
b.printf("%s\n", caAttribute)
Expand Down Expand Up @@ -277,7 +277,7 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error {
b.writex(k.bEpilogue)
b.writes("}\n")
if caMacro != "" {
b.printf("#endif // defined(WUFFS_BASE__CPU_ARCH__%s)\n", caMacro)
b.printf("#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__%s)\n", caMacro)
}
if caName != "" {
b.printf("// ‼ WUFFS MULTI-FILE SECTION -%s\n", caName)
Expand Down
2 changes: 1 addition & 1 deletion internal/cgen/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (g *gen) writeStatementChoose(b *buffer, n *a.Choose, depth uint32) error {
conclusive = true
break
}
b.printf("#if defined(WUFFS_BASE__CPU_ARCH__%s)\n"+
b.printf("#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__%s)\n"+
"wuffs_base__cpu_arch__have_%s() ? &%s%s__%s%s :\n"+
"#endif\n",
caMacro, caName, g.pkgPrefix, recv.Str(g.tm), id.Str(g.tm), suffix)
Expand Down
Loading

0 comments on commit 37a3c3c

Please sign in to comment.