Fixing warnings under the new VC++.

This commit is contained in:
Ben Vanik 2014-12-19 19:29:12 -08:00
parent 95bfe40a00
commit 1ae2f2a7af
9 changed files with 44 additions and 42 deletions

View File

@ -114,7 +114,7 @@ uint32_t AllocDynamicRegister(TranslationContext& ctx, Value* value) {
} else { } else {
value->flags |= VALUE_IS_ALLOCATED; value->flags |= VALUE_IS_ALLOCATED;
auto reg = ctx.register_count++; auto reg = ctx.register_count++;
value->tag = reinterpret_cast<void*>(reg); value->tag = reinterpret_cast<void*>(static_cast<uintptr_t>(reg));
return (uint32_t)reg; return (uint32_t)reg;
} }
} }
@ -3179,8 +3179,8 @@ uint32_t IntCode_NEG_F64(IntCodeState& ics, const IntCode* i) {
uint32_t IntCode_NEG_V128(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_NEG_V128(IntCodeState& ics, const IntCode* i) {
const vec128_t& src1 = ics.rf[i->src1_reg].v128; const vec128_t& src1 = ics.rf[i->src1_reg].v128;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 4; i++) { for (size_t j = 0; j < 4; j++) {
dest.f32[i] = -src1.f32[i]; dest.f32[j] = -src1.f32[j];
} }
return IA_NEXT; return IA_NEXT;
} }
@ -3219,8 +3219,8 @@ uint32_t IntCode_ABS_F64(IntCodeState& ics, const IntCode* i) {
uint32_t IntCode_ABS_V128(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_ABS_V128(IntCodeState& ics, const IntCode* i) {
const vec128_t& src1 = ics.rf[i->src1_reg].v128; const vec128_t& src1 = ics.rf[i->src1_reg].v128;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 4; i++) { for (size_t j = 0; j < 4; j++) {
dest.f32[i] = abs(src1.f32[i]); dest.f32[j] = abs(src1.f32[j]);
} }
return IA_NEXT; return IA_NEXT;
} }
@ -3275,8 +3275,8 @@ uint32_t IntCode_SQRT_F64(IntCodeState& ics, const IntCode* i) {
uint32_t IntCode_SQRT_V128(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_SQRT_V128(IntCodeState& ics, const IntCode* i) {
const vec128_t& src1 = ics.rf[i->src1_reg].v128; const vec128_t& src1 = ics.rf[i->src1_reg].v128;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 4; i++) { for (size_t j = 0; j < 4; j++) {
dest.f32[i] = sqrt(src1.f32[i]); dest.f32[j] = sqrt(src1.f32[j]);
} }
return IA_NEXT; return IA_NEXT;
} }
@ -3317,8 +3317,8 @@ uint32_t IntCode_POW2_F64(IntCodeState& ics, const IntCode* i) {
uint32_t IntCode_POW2_V128(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_POW2_V128(IntCodeState& ics, const IntCode* i) {
const vec128_t& src1 = ics.rf[i->src1_reg].v128; const vec128_t& src1 = ics.rf[i->src1_reg].v128;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 4; i++) { for (size_t j = 0; j < 4; j++) {
dest.f32[i] = (float)pow(2, src1.f32[i]); dest.f32[j] = (float)pow(2, src1.f32[j]);
} }
return IA_NEXT; return IA_NEXT;
} }
@ -3342,8 +3342,8 @@ uint32_t IntCode_LOG2_F64(IntCodeState& ics, const IntCode* i) {
uint32_t IntCode_LOG2_V128(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_LOG2_V128(IntCodeState& ics, const IntCode* i) {
const vec128_t& src1 = ics.rf[i->src1_reg].v128; const vec128_t& src1 = ics.rf[i->src1_reg].v128;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 4; i++) { for (size_t j = 0; j < 4; j++) {
dest.f32[i] = log2(src1.f32[i]); dest.f32[j] = log2(src1.f32[j]);
} }
return IA_NEXT; return IA_NEXT;
} }
@ -3911,32 +3911,32 @@ int Translate_INSERT(TranslationContext& ctx, Instr* i) {
uint32_t IntCode_SPLAT_V128_INT8(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_SPLAT_V128_INT8(IntCodeState& ics, const IntCode* i) {
int8_t src1 = ics.rf[i->src1_reg].i8; int8_t src1 = ics.rf[i->src1_reg].i8;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 16; i++) { for (size_t j = 0; j < 16; j++) {
dest.u8[i] = src1; dest.u8[j] = src1;
} }
return IA_NEXT; return IA_NEXT;
} }
uint32_t IntCode_SPLAT_V128_INT16(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_SPLAT_V128_INT16(IntCodeState& ics, const IntCode* i) {
int16_t src1 = ics.rf[i->src1_reg].i16; int16_t src1 = ics.rf[i->src1_reg].i16;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 8; i++) { for (size_t j = 0; j < 8; j++) {
dest.u16[i] = src1; dest.u16[j] = src1;
} }
return IA_NEXT; return IA_NEXT;
} }
uint32_t IntCode_SPLAT_V128_INT32(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_SPLAT_V128_INT32(IntCodeState& ics, const IntCode* i) {
int32_t src1 = ics.rf[i->src1_reg].i32; int32_t src1 = ics.rf[i->src1_reg].i32;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 4; i++) { for (size_t j = 0; j < 4; j++) {
dest.u32[i] = src1; dest.u32[j] = src1;
} }
return IA_NEXT; return IA_NEXT;
} }
uint32_t IntCode_SPLAT_V128_FLOAT32(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_SPLAT_V128_FLOAT32(IntCodeState& ics, const IntCode* i) {
float src1 = ics.rf[i->src1_reg].f32; float src1 = ics.rf[i->src1_reg].f32;
vec128_t& dest = ics.rf[i->dest_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128;
for (size_t i = 0; i < 4; i++) { for (size_t j = 0; j < 4; j++) {
dest.f32[i] = src1; dest.f32[j] = src1;
} }
return IA_NEXT; return IA_NEXT;
} }

View File

@ -1548,7 +1548,7 @@ EMITTER(STORE_I8, MATCH(I<OPCODE_STORE, VoidOp, I64<>, I8<>>)) {
e.mov(e.byte[addr], i.src2); e.mov(e.byte[addr], i.src2);
} }
if (IsTracingData()) { if (IsTracingData()) {
auto addr = ComputeMemoryAddress(e, i.src1); addr = ComputeMemoryAddress(e, i.src1);
e.mov(e.r8b, e.byte[addr]); e.mov(e.r8b, e.byte[addr]);
e.lea(e.rdx, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]);
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI8)); e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI8));
@ -1564,7 +1564,7 @@ EMITTER(STORE_I16, MATCH(I<OPCODE_STORE, VoidOp, I64<>, I16<>>)) {
e.mov(e.word[addr], i.src2); e.mov(e.word[addr], i.src2);
} }
if (IsTracingData()) { if (IsTracingData()) {
auto addr = ComputeMemoryAddress(e, i.src1); addr = ComputeMemoryAddress(e, i.src1);
e.mov(e.r8w, e.word[addr]); e.mov(e.r8w, e.word[addr]);
e.lea(e.rdx, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]);
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI16)); e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI16));
@ -1580,7 +1580,7 @@ EMITTER(STORE_I32, MATCH(I<OPCODE_STORE, VoidOp, I64<>, I32<>>)) {
e.mov(e.dword[addr], i.src2); e.mov(e.dword[addr], i.src2);
} }
if (IsTracingData()) { if (IsTracingData()) {
auto addr = ComputeMemoryAddress(e, i.src1); addr = ComputeMemoryAddress(e, i.src1);
e.mov(e.r8d, e.dword[addr]); e.mov(e.r8d, e.dword[addr]);
e.lea(e.rdx, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]);
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI32)); e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI32));
@ -1596,7 +1596,7 @@ EMITTER(STORE_I64, MATCH(I<OPCODE_STORE, VoidOp, I64<>, I64<>>)) {
e.mov(e.qword[addr], i.src2); e.mov(e.qword[addr], i.src2);
} }
if (IsTracingData()) { if (IsTracingData()) {
auto addr = ComputeMemoryAddress(e, i.src1); addr = ComputeMemoryAddress(e, i.src1);
e.mov(e.r8, e.qword[addr]); e.mov(e.r8, e.qword[addr]);
e.lea(e.rdx, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]);
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI64)); e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreI64));
@ -1612,7 +1612,7 @@ EMITTER(STORE_F32, MATCH(I<OPCODE_STORE, VoidOp, I64<>, F32<>>)) {
e.vmovss(e.dword[addr], i.src2); e.vmovss(e.dword[addr], i.src2);
} }
if (IsTracingData()) { if (IsTracingData()) {
auto addr = ComputeMemoryAddress(e, i.src1); addr = ComputeMemoryAddress(e, i.src1);
e.lea(e.r8, e.ptr[addr]); e.lea(e.r8, e.ptr[addr]);
e.lea(e.rdx, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]);
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreF32)); e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreF32));
@ -1628,7 +1628,7 @@ EMITTER(STORE_F64, MATCH(I<OPCODE_STORE, VoidOp, I64<>, F64<>>)) {
e.vmovsd(e.qword[addr], i.src2); e.vmovsd(e.qword[addr], i.src2);
} }
if (IsTracingData()) { if (IsTracingData()) {
auto addr = ComputeMemoryAddress(e, i.src1); addr = ComputeMemoryAddress(e, i.src1);
e.lea(e.r8, e.ptr[addr]); e.lea(e.r8, e.ptr[addr]);
e.lea(e.rdx, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]);
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreF64)); e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreF64));
@ -1645,7 +1645,7 @@ EMITTER(STORE_V128, MATCH(I<OPCODE_STORE, VoidOp, I64<>, V128<>>)) {
e.vmovaps(e.ptr[addr], i.src2); e.vmovaps(e.ptr[addr], i.src2);
} }
if (IsTracingData()) { if (IsTracingData()) {
auto addr = ComputeMemoryAddress(e, i.src1); addr = ComputeMemoryAddress(e, i.src1);
e.lea(e.r8, e.ptr[addr]); e.lea(e.r8, e.ptr[addr]);
e.lea(e.rdx, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]);
e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreV128)); e.CallNative(reinterpret_cast<void*>(TraceMemoryStoreV128));

View File

@ -114,7 +114,7 @@ int DeadCodeEliminationPass::Run(HIRBuilder* builder) {
// Remove all nops. // Remove all nops.
if (any_instr_removed) { if (any_instr_removed) {
auto block = builder->first_block(); block = builder->first_block();
while (block) { while (block) {
Instr* i = block->instr_head; Instr* i = block->instr_head;
while (i) { while (i) {

View File

@ -421,9 +421,9 @@ bool RunTests(const std::wstring& test_name) {
int failed_count = 0; int failed_count = 0;
int passed_count = 0; int passed_count = 0;
auto test_path = poly::fix_path_separators(poly::to_wstring(FLAGS_test_path)); auto test_path_root = poly::fix_path_separators(poly::to_wstring(FLAGS_test_path));
std::vector<std::wstring> test_files; std::vector<std::wstring> test_files;
if (!DiscoverTests(test_path, test_files)) { if (!DiscoverTests(test_path_root, test_files)) {
return false; return false;
} }
if (!test_files.size()) { if (!test_files.size()) {

View File

@ -65,7 +65,7 @@ std::unique_ptr<MappedMemory> MappedMemory::Open(const std::wstring& path,
GetSystemInfo(&systemInfo); GetSystemInfo(&systemInfo);
const size_t aligned_offset = const size_t aligned_offset =
offset & (~(systemInfo.dwAllocationGranularity - 1)); offset & ~static_cast<size_t>(systemInfo.dwAllocationGranularity - 1);
const size_t aligned_length = length + (offset - aligned_offset); const size_t aligned_length = length + (offset - aligned_offset);
auto mm = std::make_unique<Win32MappedMemory>(path, mode); auto mm = std::make_unique<Win32MappedMemory>(path, mode);

View File

@ -164,13 +164,13 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length,
header->resource_info_count = (opt_header->length - 4) / 16; header->resource_info_count = (opt_header->length - 4) / 16;
header->resource_infos = (xe_xex2_resource_info_t *)calloc( header->resource_infos = (xe_xex2_resource_info_t *)calloc(
header->resource_info_count, sizeof(xe_xex2_resource_info_t)); header->resource_info_count, sizeof(xe_xex2_resource_info_t));
const uint8_t *ph = pp + 0x04; const uint8_t *phi = pp + 0x04;
for (size_t n = 0; n < header->resource_info_count; n++) { for (size_t m = 0; m < header->resource_info_count; m++) {
auto &res = header->resource_infos[n]; auto &res = header->resource_infos[m];
memcpy(res.name, ph + 0x00, 8); memcpy(res.name, phi + 0x00, 8);
res.address = poly::load_and_swap<uint32_t>(ph + 0x08); res.address = poly::load_and_swap<uint32_t>(phi + 0x08);
res.size = poly::load_and_swap<uint32_t>(ph + 0x0C); res.size = poly::load_and_swap<uint32_t>(phi + 0x0C);
ph += 16; phi += 16;
} }
} break; } break;
case XEX_HEADER_EXECUTION_INFO: { case XEX_HEADER_EXECUTION_INFO: {
@ -609,7 +609,7 @@ int xe_xex2_read_image_basic_compressed(const xe_xex2_header_t *header,
case XEX_ENCRYPTION_NORMAL: { case XEX_ENCRYPTION_NORMAL: {
const uint8_t *ct = p; const uint8_t *ct = p;
uint8_t *pt = d; uint8_t *pt = d;
for (size_t n = 0; n < data_size; n += 16, ct += 16, pt += 16) { for (size_t m = 0; m < data_size; m += 16, ct += 16, pt += 16) {
// Decrypt 16 uint8_ts from input -> output. // Decrypt 16 uint8_ts from input -> output.
rijndaelDecrypt(rk, Nr, ct, pt); rijndaelDecrypt(rk, Nr, ct, pt);
for (size_t i = 0; i < 16; i++) { for (size_t i = 0; i < 16; i++) {

View File

@ -129,7 +129,7 @@ SHIM_CALL RtlInitAnsiString_shim(PPCContext* ppc_state, KernelState* state) {
uint32_t destination_ptr = SHIM_GET_ARG_32(0); uint32_t destination_ptr = SHIM_GET_ARG_32(0);
uint32_t source_ptr = SHIM_GET_ARG_32(1); uint32_t source_ptr = SHIM_GET_ARG_32(1);
const char* source = source_ptr ? (char*)SHIM_MEM_ADDR(source_ptr) : NULL; const char* source = source_ptr ? (char*)SHIM_MEM_ADDR(source_ptr) : nullptr;
XELOGD("RtlInitAnsiString(%.8X, %.8X = %s)", destination_ptr, source_ptr, XELOGD("RtlInitAnsiString(%.8X, %.8X = %s)", destination_ptr, source_ptr,
source ? source : "<null>"); source ? source : "<null>");
@ -138,7 +138,6 @@ SHIM_CALL RtlInitAnsiString_shim(PPCContext* ppc_state, KernelState* state) {
// _In_opt_ PCSZ SourceString // _In_opt_ PCSZ SourceString
if (source_ptr != 0) { if (source_ptr != 0) {
const char* source = (char*)SHIM_MEM_ADDR(source_ptr);
uint16_t length = (uint16_t)strlen(source); uint16_t length = (uint16_t)strlen(source);
SHIM_SET_MEM_16(destination_ptr + 0, length); SHIM_SET_MEM_16(destination_ptr + 0, length);
SHIM_SET_MEM_16(destination_ptr + 2, length + 1); SHIM_SET_MEM_16(destination_ptr + 2, length + 1);

View File

@ -390,7 +390,8 @@ SHIM_CALL KeTlsSetValue_shim(PPCContext* ppc_state, KernelState* state) {
int result = 0; int result = 0;
#if XE_PLATFORM_WIN32 #if XE_PLATFORM_WIN32
result = TlsSetValue(tls_index, (LPVOID)tls_value); result = TlsSetValue(
tls_index, reinterpret_cast<LPVOID>(static_cast<uintptr_t>(tls_value)));
#else #else
result = pthread_setspecific(tls_index, (void*)tls_value) == 0; result = pthread_setspecific(tls_index, (void*)tls_value) == 0;
#endif // WIN32 #endif // WIN32

View File

@ -76,7 +76,9 @@
'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)', 'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
'CharacterSet': '1', 'CharacterSet': '1',
}, },
'msvs_disabled_warnings': [], 'msvs_disabled_warnings': [
4458, # warning C4458: declaration of 'x' hides class member
],
'msvs_configuration_platform': 'x64', 'msvs_configuration_platform': 'x64',
'msvs_cygwin_shell': '0', 'msvs_cygwin_shell': '0',
'msvs_settings': { 'msvs_settings': {