Просмотр исходного кода

Merge pull request #2785 from yuriks/compile-flags

CMake: Set MSVC flags for improved C++ standards conformance
Yuri Kunde Schlesner 9 лет назад
Родитель
Сommit
7dc72daea9
4 измененных файлов с 21 добавлено и 20 удалено
  1. 6 3
      CMakeLists.txt
  2. 1 3
      externals/CMakeLists.txt
  3. 1 1
      externals/dynarmic
  4. 13 13
      src/video_core/shader/shader_jit_x64_compiler.cpp

+ 6 - 3
CMakeLists.txt

@@ -92,10 +92,13 @@ else()
     # /W3 - Level 3 warnings
     # /W3 - Level 3 warnings
     # /MP - Multi-threaded compilation
     # /MP - Multi-threaded compilation
     # /Zi - Output debugging information
     # /Zi - Output debugging information
-    # /Zo - enahnced debug info for optimized builds
-    set(CMAKE_C_FLAGS   "/W3 /MP /Zi /Zo" CACHE STRING "" FORCE)
+    # /Zo - enhanced debug info for optimized builds
+    # /permissive- - enables stricter C++ standards conformance checks
+    set(CMAKE_C_FLAGS   "/W3 /MP /Zi /Zo /permissive-" CACHE STRING "" FORCE)
     # /EHsc - C++-only exception handling semantics
     # /EHsc - C++-only exception handling semantics
-    set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /EHsc" CACHE STRING "" FORCE)
+    # /Zc:throwingNew - let codegen assume `operator new` will never return null
+    # /Zc:inline - let codegen omit inline functions in object files
+    set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /EHsc /Zc:throwingNew,inline" CACHE STRING "" FORCE)
 
 
     # /MDd - Multi-threaded Debug Runtime DLL
     # /MDd - Multi-threaded Debug Runtime DLL
     set(CMAKE_C_FLAGS_DEBUG   "/Od /MDd" CACHE STRING "" FORCE)
     set(CMAKE_C_FLAGS_DEBUG   "/Od /MDd" CACHE STRING "" FORCE)

+ 1 - 3
externals/CMakeLists.txt

@@ -46,7 +46,5 @@ if (ARCHITECTURE_x86_64)
     # Defined before "dynarmic" above
     # Defined before "dynarmic" above
     # add_library(xbyak INTERFACE)
     # add_library(xbyak INTERFACE)
     target_include_directories(xbyak INTERFACE ./xbyak/xbyak)
     target_include_directories(xbyak INTERFACE ./xbyak/xbyak)
-    if (NOT MSVC)
-        target_compile_options(xbyak INTERFACE -fno-operator-names)
-    endif()
+    target_compile_definitions(xbyak INTERFACE XBYAK_NO_OP_NAMES)
 endif()
 endif()

+ 1 - 1
externals/dynarmic

@@ -1 +1 @@
-Subproject commit 7707ff13e981b0aecf87f3156ee0b641469f7bb3
+Subproject commit 8f15e3f70cb96e56705e5de6ba97b5d09423a56b

+ 13 - 13
src/video_core/shader/shader_jit_x64_compiler.cpp

@@ -321,27 +321,27 @@ void JitShader::Compile_EvaluateCondition(Instruction instr) {
     case Instruction::FlowControlType::Or:
     case Instruction::FlowControlType::Or:
         mov(eax, COND0);
         mov(eax, COND0);
         mov(ebx, COND1);
         mov(ebx, COND1);
-        xor(eax, (instr.flow_control.refx.Value() ^ 1));
-        xor(ebx, (instr.flow_control.refy.Value() ^ 1));
-        or (eax, ebx);
+        xor_(eax, (instr.flow_control.refx.Value() ^ 1));
+        xor_(ebx, (instr.flow_control.refy.Value() ^ 1));
+        or_(eax, ebx);
         break;
         break;
 
 
     case Instruction::FlowControlType::And:
     case Instruction::FlowControlType::And:
         mov(eax, COND0);
         mov(eax, COND0);
         mov(ebx, COND1);
         mov(ebx, COND1);
-        xor(eax, (instr.flow_control.refx.Value() ^ 1));
-        xor(ebx, (instr.flow_control.refy.Value() ^ 1));
-        and(eax, ebx);
+        xor_(eax, (instr.flow_control.refx.Value() ^ 1));
+        xor_(ebx, (instr.flow_control.refy.Value() ^ 1));
+        and_(eax, ebx);
         break;
         break;
 
 
     case Instruction::FlowControlType::JustX:
     case Instruction::FlowControlType::JustX:
         mov(eax, COND0);
         mov(eax, COND0);
-        xor(eax, (instr.flow_control.refx.Value() ^ 1));
+        xor_(eax, (instr.flow_control.refx.Value() ^ 1));
         break;
         break;
 
 
     case Instruction::FlowControlType::JustY:
     case Instruction::FlowControlType::JustY:
         mov(eax, COND1);
         mov(eax, COND1);
-        xor(eax, (instr.flow_control.refy.Value() ^ 1));
+        xor_(eax, (instr.flow_control.refy.Value() ^ 1));
         break;
         break;
     }
     }
 }
 }
@@ -734,10 +734,10 @@ void JitShader::Compile_LOOP(Instruction instr) {
     mov(LOOPCOUNT, dword[SETUP + offset]);
     mov(LOOPCOUNT, dword[SETUP + offset]);
     mov(LOOPCOUNT_REG, LOOPCOUNT);
     mov(LOOPCOUNT_REG, LOOPCOUNT);
     shr(LOOPCOUNT_REG, 4);
     shr(LOOPCOUNT_REG, 4);
-    and(LOOPCOUNT_REG, 0xFF0); // Y-component is the start
+    and_(LOOPCOUNT_REG, 0xFF0); // Y-component is the start
     mov(LOOPINC, LOOPCOUNT);
     mov(LOOPINC, LOOPCOUNT);
     shr(LOOPINC, 12);
     shr(LOOPINC, 12);
-    and(LOOPINC, 0xFF0);                // Z-component is the incrementer
+    and_(LOOPINC, 0xFF0);               // Z-component is the incrementer
     movzx(LOOPCOUNT, LOOPCOUNT.cvt8()); // X-component is iteration count
     movzx(LOOPCOUNT, LOOPCOUNT.cvt8()); // X-component is iteration count
     add(LOOPCOUNT, 1);                  // Iteration count is X-component + 1
     add(LOOPCOUNT, 1);                  // Iteration count is X-component + 1
 
 
@@ -858,9 +858,9 @@ void JitShader::Compile(const std::array<u32, MAX_PROGRAM_CODE_LENGTH>* program_
     mov(STATE, ABI_PARAM2);
     mov(STATE, ABI_PARAM2);
 
 
     // Zero address/loop  registers
     // Zero address/loop  registers
-    xor(ADDROFFS_REG_0.cvt32(), ADDROFFS_REG_0.cvt32());
-    xor(ADDROFFS_REG_1.cvt32(), ADDROFFS_REG_1.cvt32());
-    xor(LOOPCOUNT_REG, LOOPCOUNT_REG);
+    xor_(ADDROFFS_REG_0.cvt32(), ADDROFFS_REG_0.cvt32());
+    xor_(ADDROFFS_REG_1.cvt32(), ADDROFFS_REG_1.cvt32());
+    xor_(LOOPCOUNT_REG, LOOPCOUNT_REG);
 
 
     // Used to set a register to one
     // Used to set a register to one
     static const __m128 one = {1.f, 1.f, 1.f, 1.f};
     static const __m128 one = {1.f, 1.f, 1.f, 1.f};