Avoid type shadowing warnings in SkVM.

We intend for these types to shadow, but we can avoid getting a warning
by declaring the types in a separate namespace, then explicitly bringing
those different-namespaced types into our function with `using`.

Change-Id: Ie38b6408c2850699f3389d91d8542be255caa51a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439496
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2021-08-16 11:37:20 -04:00 committed by SkCQ
parent 32475751b4
commit 9a6f3990af
2 changed files with 41 additions and 22 deletions

View File

@ -3017,11 +3017,20 @@ namespace skvm {
#if defined(SKVM_JIT)
namespace SkVMJitTypes {
#if defined(__x86_64__) || defined(_M_X64)
using Reg = Assembler::Ymm;
#elif defined(__aarch64__)
using Reg = Assembler::V;
#endif
} // namespace SkVMJitTypes
bool Program::jit(const std::vector<OptimizedInstruction>& instructions,
int* stack_hint,
uint32_t* registers_used,
Assembler* a) const {
using A = Assembler;
using SkVMJitTypes::Reg;
SkTHashMap<int, A::Label> constants; // Constants (mostly splats) share the same pool.
A::Label iota; // Varies per lane, for Op::index.
@ -3041,13 +3050,11 @@ namespace skvm {
const int nstack_slots = *stack_hint >= 0 ? *stack_hint
: stack_slot.size();
#if defined(__x86_64__) || defined(_M_X64)
if (!SkCpu::Supports(SkCpu::HSW)) {
return false;
}
const int K = 8;
using Reg = A::Ymm;
#if defined(_M_X64) // Important to check this first; clang-cl defines both.
const A::GP64 N = A::rcx,
GP0 = A::rax,
@ -3168,7 +3175,6 @@ namespace skvm {
};
#elif defined(__aarch64__)
const int K = 4;
using Reg = A::V;
const A::X N = A::x0,
GP0 = A::x8,
GP1 = A::x9,

View File

@ -25,32 +25,45 @@ static inline skvx::Vec<N,int> gather32(const int* ptr, const skvx::Vec<N,int>&
namespace SK_OPTS_NS {
namespace SkVMInterpreterTypes {
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2
constexpr inline int K = 32; // 1024-bit: 4 ymm or 2 zmm at a time
#else
constexpr inline int K = 8; // 256-bit: 2 xmm, 2 v-registers, etc.
#endif
using I32 = skvx::Vec<K, int>;
using I16 = skvx::Vec<K, int16_t>;
using F32 = skvx::Vec<K, float>;
using U64 = skvx::Vec<K, uint64_t>;
using U32 = skvx::Vec<K, uint32_t>;
using U16 = skvx::Vec<K, uint16_t>;
using U8 = skvx::Vec<K, uint8_t>;
union Slot {
F32 f32;
I32 i32;
U32 u32;
I16 i16;
U16 u16;
};
} // namespace SkVMInterpreterTypes
inline void interpret_skvm(const skvm::InterpreterInstruction insts[], const int ninsts,
const int nregs, const int loop,
const int strides[], const int nargs,
int n, void* args[]) {
using namespace skvm;
using SkVMInterpreterTypes::K;
using SkVMInterpreterTypes::I32;
using SkVMInterpreterTypes::I16;
using SkVMInterpreterTypes::F32;
using SkVMInterpreterTypes::U64;
using SkVMInterpreterTypes::U32;
using SkVMInterpreterTypes::U16;
using SkVMInterpreterTypes::U8;
using SkVMInterpreterTypes::Slot;
// We'll operate in SIMT style, knocking off K-size chunks from n while possible.
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2
constexpr int K = 32; // 1024-bit: 4 ymm or 2 zmm at a time
#else
constexpr int K = 8; // 256-bit: 2 xmm, 2 v-registers, etc.
#endif
using I32 = skvx::Vec<K, int>;
using I16 = skvx::Vec<K, int16_t>;
using F32 = skvx::Vec<K, float>;
using U64 = skvx::Vec<K, uint64_t>;
using U32 = skvx::Vec<K, uint32_t>;
using U16 = skvx::Vec<K, uint16_t>;
using U8 = skvx::Vec<K, uint8_t>;
union Slot {
F32 f32;
I32 i32;
U32 u32;
I16 i16;
U16 u16;
};
Slot few_regs[16];
std::unique_ptr<char[]> many_regs;