diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37dd9b5a8..ac6de85f6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -258,9 +258,7 @@ endif() set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen passes ipo irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld object instcombine linker analysis selectiondag scalaropts vectorize executionengine - mc mcdisassembler mcparser mcjit target ) -set( LLVM_COMPONENTS_X86 x86asmprinter x86info x86desc x86utils x86codegen ) -set( LLVM_COMPONENTS_X64 aarch64asmprinter aarch64info aarch64desc aarch64utils aarch64codegen ) + mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen ) # Path where it looks for the LLVM compiled files on Windows set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" ) @@ -270,24 +268,22 @@ if( NOT WIN32 ) find_package(LLVM REQUIRED CONFIG) message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") - llvm_map_components_to_libnames( llvm_libs ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X86} ${LLVM_COMPONENTS_X64} ) + llvm_map_components_to_libnames( llvm_libs ${LLVM_COMPONENTS} ) include_directories( ${LLVM_INCLUDE_DIRS} ) set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) else() include_directories( "${LLVM_PRECOMPILED_DIR}/include" ) if( X64 ) - include_directories( "${LLVM_PRECOMPILED_DIR}/64bit/include" ) - set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/llvm/64bit" ) - set( LLVM_ALL_COMPONENTS ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X64} ) + include_directories( "${LLVM_PRECOMPILED_DIR}/64bit-include" ) + set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/64bit-" ) else() - include_directories( "${LLVM_PRECOMPILED_DIR}/32bit/include" ) - set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit" ) - set( LLVM_ALL_COMPONENTS ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X86} ) + include_directories( "${LLVM_PRECOMPILED_DIR}/32bit-include" ) + set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit-" ) endif() foreach(buildtype IN ITEMS RELEASE DEBUG) - set( llvm_libs_${buildtype} "${llvm_libs_base}/${buildtype}" ) + set( llvm_libs_${buildtype} "${llvm_libs_base}${buildtype}" ) set( LLVM_${buildtype}_LIBS "" ) - foreach( llvm_module ${LLVM_ALL_COMPONENTS} ) + foreach( llvm_module ${LLVM_COMPONENTS} ) find_library( LLVM_${llvm_module}_LIBRARY_${buildtype} LLVM${llvm_module} PATHS ${llvm_libs_${buildtype}} ) set( LLVM_${buildtype}_LIBS ${LLVM_${buildtype}_LIBS} ${LLVM_${llvm_module}_LIBRARY_${buildtype}} ) endforeach( llvm_module ) @@ -1492,6 +1488,10 @@ set_source_files_properties( sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRE set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE ) if ( WIN32 ) set_source_files_properties( win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp PROPERTIES COMPILE_FLAGS ${ZD_FASTMATH_FLAG} ) + + # Supress C4244: 'initializing': conversion from '__int64' to 'unsigned int', possible loss of data + # For some reason using #pragma warning(disable: 4244) is not working.. + set_source_files_properties( ${PCH_SOURCES} PROPERTIES COMPILE_FLAGS /wd4244 ) endif() diff --git a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp index 4594e2290..67d801162 100644 --- a/src/r_compiler/fixedfunction/drawcolumncodegen.cpp +++ b/src/r_compiler/fixedfunction/drawcolumncodegen.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawcolumncodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" diff --git a/src/r_compiler/fixedfunction/drawercodegen.cpp b/src/r_compiler/fixedfunction/drawercodegen.cpp index 2cba50121..822a81141 100644 --- a/src/r_compiler/fixedfunction/drawercodegen.cpp +++ b/src/r_compiler/fixedfunction/drawercodegen.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawercodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" @@ -17,17 +18,17 @@ SSABool DrawerCodegen::line_skipped_by_thread(SSAInt line, SSAWorkerThread threa SSAInt DrawerCodegen::skipped_by_thread(SSAInt first_line, SSAWorkerThread thread) { - SSAInt pass_skip = SSAInt::MAX(thread.pass_start_y - first_line, 0); + SSAInt pass_skip = SSAInt::MAX(thread.pass_start_y - first_line, SSAInt(0)); SSAInt core_skip = (thread.num_cores - (first_line + pass_skip - thread.core) % thread.num_cores) % thread.num_cores; return pass_skip + core_skip; } SSAInt DrawerCodegen::count_for_thread(SSAInt first_line, SSAInt count, SSAWorkerThread thread) { - SSAInt lines_until_pass_end = SSAInt::MAX(thread.pass_end_y - first_line, 0); + SSAInt lines_until_pass_end = SSAInt::MAX(thread.pass_end_y - first_line, SSAInt(0)); count = SSAInt::MIN(count, lines_until_pass_end); SSAInt c = (count - skipped_by_thread(first_line, thread) + thread.num_cores - 1) / thread.num_cores; - return SSAInt::MAX(c, 0); + return SSAInt::MAX(c, SSAInt(0)); } SSAUBytePtr DrawerCodegen::dest_for_thread(SSAInt first_line, SSAInt pitch, SSAUBytePtr dest, SSAWorkerThread thread) diff --git a/src/r_compiler/fixedfunction/drawspancodegen.cpp b/src/r_compiler/fixedfunction/drawspancodegen.cpp index 1623c38f2..70ecb0abd 100644 --- a/src/r_compiler/fixedfunction/drawspancodegen.cpp +++ b/src/r_compiler/fixedfunction/drawspancodegen.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawspancodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" @@ -49,9 +50,9 @@ void DrawSpanCodegen::Generate(DrawSpanVariant variant, SSAValue args) xmask = ((SSAInt(1) << xbits) - 1) << ybits; // 64x64 is the most common case by far, so special case it. - is_64x64 = xbits == 6 && ybits == 6; - is_simple_shade = (flags & DrawSpanArgs::simple_shade) == DrawSpanArgs::simple_shade; - is_nearest_filter = (flags & DrawSpanArgs::nearest_filter) == DrawSpanArgs::nearest_filter; + is_64x64 = xbits == SSAInt(6) && ybits == SSAInt(6); + is_simple_shade = (flags & DrawSpanArgs::simple_shade) == SSAInt(DrawSpanArgs::simple_shade); + is_nearest_filter = (flags & DrawSpanArgs::nearest_filter) == SSAInt(DrawSpanArgs::nearest_filter); SSAIfBlock branch; branch.if_block(is_simple_shade); @@ -90,7 +91,7 @@ void DrawSpanCodegen::LoopFilter(DrawSpanVariant variant, bool isSimpleShade, bo SSAInt DrawSpanCodegen::Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64) { SSAInt sseLength = count / 4; - stack_index.store(0); + stack_index.store(SSAInt(0)); { SSAForBlock loop; SSAInt index = stack_index.load(); @@ -165,7 +166,7 @@ SSAVec4i DrawSpanCodegen::Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilte { if (is64x64) { - return sample_linear(source, xfrac, yfrac, 26, 26); + return sample_linear(source, xfrac, yfrac, SSAInt(26), SSAInt(26)); } else { diff --git a/src/r_compiler/fixedfunction/drawwallcodegen.cpp b/src/r_compiler/fixedfunction/drawwallcodegen.cpp index 0ca537723..55b17dafe 100644 --- a/src/r_compiler/fixedfunction/drawwallcodegen.cpp +++ b/src/r_compiler/fixedfunction/drawwallcodegen.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawwallcodegen.h" #include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_scope.h" @@ -65,8 +66,8 @@ void DrawWallCodegen::Generate(DrawWallVariant variant, bool fourColumns, SSAVal thread.pass_start_y = thread_data[0][2].load(); thread.pass_end_y = thread_data[0][3].load(); - is_simple_shade = (flags & DrawWallArgs::simple_shade) == DrawWallArgs::simple_shade; - is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == DrawWallArgs::nearest_filter; + is_simple_shade = (flags & DrawWallArgs::simple_shade) == SSAInt(DrawWallArgs::simple_shade); + is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == SSAInt(DrawWallArgs::nearest_filter); count = count_for_thread(dest_y, count, thread); dest = dest_for_thread(dest_y, pitch, dest, thread); @@ -103,7 +104,7 @@ void DrawWallCodegen::Loop(DrawWallVariant variant, bool fourColumns, bool isSim { int numColumns = fourColumns ? 4 : 1; - stack_index.store(0); + stack_index.store(SSAInt(0)); { SSAForBlock loop; SSAInt index = stack_index.load(); diff --git a/src/r_compiler/llvm_include.h b/src/r_compiler/llvm_include.h index b916bad0e..d1550f38a 100644 --- a/src/r_compiler/llvm_include.h +++ b/src/r_compiler/llvm_include.h @@ -1,6 +1,8 @@ #pragma once +#ifdef _MSC_VER + #if defined(min) #define llvm_min_bug min #undef min @@ -18,6 +20,10 @@ #pragma warning(disable: 4244) // warning C4244: 'return' : conversion from 'uint64_t' to 'unsigned int', possible loss of data #pragma warning(disable: 4141) // warning C4141: 'inline': used more than once #pragma warning(disable: 4291) // warning C4291: 'void *llvm::User::operator new(std::size_t,unsigned int,unsigned int)': no matching operator delete found; memory will not be freed if initialization throws an exception +#pragma warning(disable: 4267) // warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data +#pragma warning(disable: 4244) // warning C4244: 'initializing': conversion from '__int64' to 'unsigned int', possible loss of data + +#endif #include #include @@ -39,6 +45,8 @@ #include #include +#ifdef _MSC_VER + #if defined(llvm_min_bug) #define min llvm_min_bug #undef llvm_min_bug @@ -47,3 +55,5 @@ #define max llvm_max_bug #undef llvm_max_bug #endif + +#endif diff --git a/src/r_compiler/llvmdrawers.cpp b/src/r_compiler/llvmdrawers.cpp index 4f59419ad..7691af35b 100644 --- a/src/r_compiler/llvmdrawers.cpp +++ b/src/r_compiler/llvmdrawers.cpp @@ -1,5 +1,6 @@ #include "i_system.h" +#include "r_compiler/llvm_include.h" #include "r_compiler/fixedfunction/drawspancodegen.h" #include "r_compiler/fixedfunction/drawwallcodegen.h" #include "r_compiler/fixedfunction/drawcolumncodegen.h" diff --git a/src/r_compiler/ssa/ssa_bool.cpp b/src/r_compiler/ssa/ssa_bool.cpp index 101323911..bfd9ba5ab 100644 --- a/src/r_compiler/ssa/ssa_bool.cpp +++ b/src/r_compiler/ssa/ssa_bool.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_bool.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSABool::SSABool() : v(0) diff --git a/src/r_compiler/ssa/ssa_float.cpp b/src/r_compiler/ssa/ssa_float.cpp index 87488af74..4ec5c516d 100644 --- a/src/r_compiler/ssa/ssa_float.cpp +++ b/src/r_compiler/ssa/ssa_float.cpp @@ -1,8 +1,8 @@ +#include "r_compiler/llvm_include.h" #include "ssa_float.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAFloat::SSAFloat() : v(0) diff --git a/src/r_compiler/ssa/ssa_float.h b/src/r_compiler/ssa/ssa_float.h index 2349ab877..0edbcfcba 100644 --- a/src/r_compiler/ssa/ssa_float.h +++ b/src/r_compiler/ssa/ssa_float.h @@ -11,7 +11,7 @@ class SSAFloat public: SSAFloat(); SSAFloat(SSAInt i); - SSAFloat(float constant); + explicit SSAFloat(float constant); explicit SSAFloat(llvm::Value *v); static SSAFloat from_llvm(llvm::Value *v) { return SSAFloat(v); } static llvm::Type *llvm_type(); diff --git a/src/r_compiler/ssa/ssa_float_ptr.cpp b/src/r_compiler/ssa/ssa_float_ptr.cpp index 6a1409271..582821ca0 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.cpp +++ b/src/r_compiler/ssa/ssa_float_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_float_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAFloatPtr::SSAFloatPtr() : v(0) diff --git a/src/r_compiler/ssa/ssa_float_ptr.h b/src/r_compiler/ssa/ssa_float_ptr.h index a4318e027..f29b2de3f 100644 --- a/src/r_compiler/ssa/ssa_float_ptr.h +++ b/src/r_compiler/ssa/ssa_float_ptr.h @@ -16,6 +16,7 @@ public: static SSAFloatPtr from_llvm(llvm::Value *v) { return SSAFloatPtr(v); } static llvm::Type *llvm_type(); SSAFloatPtr operator[](SSAInt index) const; + SSAFloatPtr operator[](int index) const { return (*this)[SSAInt(index)]; } SSAFloat load() const; SSAVec4f load_vec4f() const; SSAVec4f load_unaligned_vec4f() const; diff --git a/src/r_compiler/ssa/ssa_for_block.cpp b/src/r_compiler/ssa/ssa_for_block.cpp index ce9328607..f7cd6ad0b 100644 --- a/src/r_compiler/ssa/ssa_for_block.cpp +++ b/src/r_compiler/ssa/ssa_for_block.cpp @@ -1,4 +1,5 @@ +#include "r_compiler/llvm_include.h" #include "ssa_for_block.h" #include "ssa_scope.h" diff --git a/src/r_compiler/ssa/ssa_for_block.h b/src/r_compiler/ssa/ssa_for_block.h index 58803dee5..4c1952c14 100644 --- a/src/r_compiler/ssa/ssa_for_block.h +++ b/src/r_compiler/ssa/ssa_for_block.h @@ -2,7 +2,6 @@ #pragma once #include "ssa_bool.h" -#include "r_compiler/llvm_include.h" class SSAForBlock { diff --git a/src/r_compiler/ssa/ssa_function.cpp b/src/r_compiler/ssa/ssa_function.cpp index aee4de5a9..a326beaf7 100644 --- a/src/r_compiler/ssa/ssa_function.cpp +++ b/src/r_compiler/ssa/ssa_function.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_function.h" #include "ssa_int.h" #include "ssa_scope.h" #include "ssa_value.h" -#include "r_compiler/llvm_include.h" SSAFunction::SSAFunction(const std::string name) : name(name), return_type(llvm::Type::getVoidTy(SSAScope::context())), func() diff --git a/src/r_compiler/ssa/ssa_if_block.cpp b/src/r_compiler/ssa/ssa_if_block.cpp index e2de9ecad..7187a0759 100644 --- a/src/r_compiler/ssa/ssa_if_block.cpp +++ b/src/r_compiler/ssa/ssa_if_block.cpp @@ -1,4 +1,5 @@ +#include "r_compiler/llvm_include.h" #include "ssa_if_block.h" #include "ssa_scope.h" diff --git a/src/r_compiler/ssa/ssa_if_block.h b/src/r_compiler/ssa/ssa_if_block.h index 98c534a86..4f0c8a26b 100644 --- a/src/r_compiler/ssa/ssa_if_block.h +++ b/src/r_compiler/ssa/ssa_if_block.h @@ -3,7 +3,6 @@ #include "ssa_bool.h" #include "ssa_phi.h" -#include "r_compiler/llvm_include.h" class SSAIfBlock { diff --git a/src/r_compiler/ssa/ssa_int.cpp b/src/r_compiler/ssa/ssa_int.cpp index 8d5a32e4c..3d9cb22bd 100644 --- a/src/r_compiler/ssa/ssa_int.cpp +++ b/src/r_compiler/ssa/ssa_int.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_int.h" #include "ssa_float.h" #include "ssa_bool.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAInt::SSAInt() : v(0) diff --git a/src/r_compiler/ssa/ssa_int.h b/src/r_compiler/ssa/ssa_int.h index d928c41f2..c0f46e4b6 100644 --- a/src/r_compiler/ssa/ssa_int.h +++ b/src/r_compiler/ssa/ssa_int.h @@ -10,7 +10,7 @@ class SSAInt { public: SSAInt(); - SSAInt(int constant); + explicit SSAInt(int constant); SSAInt(SSAFloat f); explicit SSAInt(llvm::Value *v); static SSAInt from_llvm(llvm::Value *v) { return SSAInt(v); } diff --git a/src/r_compiler/ssa/ssa_int_ptr.cpp b/src/r_compiler/ssa/ssa_int_ptr.cpp index 3c2637073..974645d08 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.cpp +++ b/src/r_compiler/ssa/ssa_int_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_int_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAIntPtr::SSAIntPtr() : v(0) diff --git a/src/r_compiler/ssa/ssa_int_ptr.h b/src/r_compiler/ssa/ssa_int_ptr.h index 20e024a31..c75ed6a8d 100644 --- a/src/r_compiler/ssa/ssa_int_ptr.h +++ b/src/r_compiler/ssa/ssa_int_ptr.h @@ -16,6 +16,7 @@ public: static SSAIntPtr from_llvm(llvm::Value *v) { return SSAIntPtr(v); } static llvm::Type *llvm_type(); SSAIntPtr operator[](SSAInt index) const; + SSAIntPtr operator[](int index) const { return (*this)[SSAInt(index)]; } SSAInt load() const; SSAVec4i load_vec4i() const; SSAVec4i load_unaligned_vec4i() const; diff --git a/src/r_compiler/ssa/ssa_scope.cpp b/src/r_compiler/ssa/ssa_scope.cpp index f9d16f188..e5d34a203 100644 --- a/src/r_compiler/ssa/ssa_scope.cpp +++ b/src/r_compiler/ssa/ssa_scope.cpp @@ -1,4 +1,5 @@ +#include "r_compiler/llvm_include.h" #include "ssa_scope.h" #include "ssa_int.h" diff --git a/src/r_compiler/ssa/ssa_scope.h b/src/r_compiler/ssa/ssa_scope.h index d184643ad..ad080fde6 100644 --- a/src/r_compiler/ssa/ssa_scope.h +++ b/src/r_compiler/ssa/ssa_scope.h @@ -1,8 +1,6 @@ #pragma once -#include "r_compiler/llvm_include.h" - class SSAInt; class SSAScope diff --git a/src/r_compiler/ssa/ssa_short.cpp b/src/r_compiler/ssa/ssa_short.cpp index 3fa59b688..017f3002a 100644 --- a/src/r_compiler/ssa/ssa_short.cpp +++ b/src/r_compiler/ssa/ssa_short.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_short.h" #include "ssa_float.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAShort::SSAShort() : v(0) diff --git a/src/r_compiler/ssa/ssa_short.h b/src/r_compiler/ssa/ssa_short.h index 932aafc0e..4a5343402 100644 --- a/src/r_compiler/ssa/ssa_short.h +++ b/src/r_compiler/ssa/ssa_short.h @@ -11,7 +11,7 @@ class SSAShort { public: SSAShort(); - SSAShort(int constant); + explicit SSAShort(int constant); SSAShort(SSAFloat f); explicit SSAShort(llvm::Value *v); static SSAShort from_llvm(llvm::Value *v) { return SSAShort(v); } diff --git a/src/r_compiler/ssa/ssa_struct_type.cpp b/src/r_compiler/ssa/ssa_struct_type.cpp index 4a79768ce..d4ae2acb1 100644 --- a/src/r_compiler/ssa/ssa_struct_type.cpp +++ b/src/r_compiler/ssa/ssa_struct_type.cpp @@ -1,4 +1,5 @@ +#include "r_compiler/llvm_include.h" #include "ssa_struct_type.h" #include "ssa_scope.h" diff --git a/src/r_compiler/ssa/ssa_ubyte.cpp b/src/r_compiler/ssa/ssa_ubyte.cpp index 04db4fd28..3204d064d 100644 --- a/src/r_compiler/ssa/ssa_ubyte.cpp +++ b/src/r_compiler/ssa/ssa_ubyte.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_ubyte.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAUByte::SSAUByte() : v(0) diff --git a/src/r_compiler/ssa/ssa_ubyte.h b/src/r_compiler/ssa/ssa_ubyte.h index f1e12afba..ef878b325 100644 --- a/src/r_compiler/ssa/ssa_ubyte.h +++ b/src/r_compiler/ssa/ssa_ubyte.h @@ -8,7 +8,7 @@ class SSAUByte { public: SSAUByte(); - SSAUByte(unsigned char constant); + explicit SSAUByte(unsigned char constant); explicit SSAUByte(llvm::Value *v); static SSAUByte from_llvm(llvm::Value *v) { return SSAUByte(v); } static llvm::Type *llvm_type(); diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp index b2408066e..98bf27c46 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.cpp +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_ubyte_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAUBytePtr::SSAUBytePtr() : v(0) @@ -38,7 +38,7 @@ SSAVec4i SSAUBytePtr::load_vec4ub() const v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(3).v, SSAScope::hint()); SSAVec4i v4i = SSAVec4i::from_llvm(v); - SSAVec8s low = SSAVec8s::bitcast(SSAVec16ub::shuffle(SSAVec16ub::bitcast(v4i), 0, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 + SSAVec8s low = SSAVec8s::bitcast(SSAVec16ub::shuffle(SSAVec16ub::bitcast(v4i), SSAVec16ub((unsigned char)0), 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 return SSAVec4i::extendlo(low); // _mm_unpacklo_epi16 /* llvm::PointerType *m4xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 4)->getPointerTo(); diff --git a/src/r_compiler/ssa/ssa_ubyte_ptr.h b/src/r_compiler/ssa/ssa_ubyte_ptr.h index 5b68ee1ad..c084068bc 100644 --- a/src/r_compiler/ssa/ssa_ubyte_ptr.h +++ b/src/r_compiler/ssa/ssa_ubyte_ptr.h @@ -18,6 +18,7 @@ public: static SSAUBytePtr from_llvm(llvm::Value *v) { return SSAUBytePtr(v); } static llvm::Type *llvm_type(); SSAUBytePtr operator[](SSAInt index) const; + SSAUBytePtr operator[](int index) const { return (*this)[SSAInt(index)]; } SSAUByte load() const; SSAVec4i load_vec4ub() const; SSAVec8s load_vec8s() const; diff --git a/src/r_compiler/ssa/ssa_value.cpp b/src/r_compiler/ssa/ssa_value.cpp index 877420fc5..c37b7f4c1 100644 --- a/src/r_compiler/ssa/ssa_value.cpp +++ b/src/r_compiler/ssa/ssa_value.cpp @@ -1,8 +1,8 @@ +#include "r_compiler/llvm_include.h" #include "ssa_value.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAValue SSAValue::load() { diff --git a/src/r_compiler/ssa/ssa_vec16ub.cpp b/src/r_compiler/ssa/ssa_vec16ub.cpp index f18d68718..4a077382e 100644 --- a/src/r_compiler/ssa/ssa_vec16ub.cpp +++ b/src/r_compiler/ssa/ssa_vec16ub.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec16ub.h" #include "ssa_vec8s.h" #include "ssa_vec4i.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec16ub::SSAVec16ub() : v(0) diff --git a/src/r_compiler/ssa/ssa_vec16ub.h b/src/r_compiler/ssa/ssa_vec16ub.h index e4cfcdc87..8f48c0c49 100644 --- a/src/r_compiler/ssa/ssa_vec16ub.h +++ b/src/r_compiler/ssa/ssa_vec16ub.h @@ -11,8 +11,8 @@ class SSAVec16ub { public: SSAVec16ub(); - SSAVec16ub(unsigned char constant); - SSAVec16ub( + explicit SSAVec16ub(unsigned char constant); + explicit SSAVec16ub( unsigned char constant0, unsigned char constant1, unsigned char constant2, unsigned char constant3, unsigned char constant4, unsigned char constant5, unsigned char constant6, unsigned char constant7, unsigned char constant8, unsigned char constant9, unsigned char constant10, unsigned char constant11, unsigned char constant12, unsigned char constant13, unsigned char constant14, unsigned char constant15); explicit SSAVec16ub(llvm::Value *v); diff --git a/src/r_compiler/ssa/ssa_vec4f.cpp b/src/r_compiler/ssa/ssa_vec4f.cpp index e002018fe..dc6f9a716 100644 --- a/src/r_compiler/ssa/ssa_vec4f.cpp +++ b/src/r_compiler/ssa/ssa_vec4f.cpp @@ -1,10 +1,10 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec4f.h" #include "ssa_vec4i.h" #include "ssa_float.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec4f::SSAVec4f() : v(0) @@ -75,6 +75,11 @@ SSAFloat SSAVec4f::operator[](SSAInt index) const return SSAFloat::from_llvm(SSAScope::builder().CreateExtractElement(v, index.v, SSAScope::hint())); } +SSAFloat SSAVec4f::operator[](int index) const +{ + return (*this)[SSAInt(index)]; +} + SSAVec4f SSAVec4f::insert_element(SSAVec4f vec4f, SSAFloat value, int index) { return from_llvm(SSAScope::builder().CreateInsertElement(vec4f.v, value.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)index)))); diff --git a/src/r_compiler/ssa/ssa_vec4f.h b/src/r_compiler/ssa/ssa_vec4f.h index 5e3397e58..6d4ae6335 100644 --- a/src/r_compiler/ssa/ssa_vec4f.h +++ b/src/r_compiler/ssa/ssa_vec4f.h @@ -12,13 +12,14 @@ class SSAVec4f { public: SSAVec4f(); - SSAVec4f(float constant); - SSAVec4f(float constant0, float constant1, float constant2, float constant3); + explicit SSAVec4f(float constant); + explicit SSAVec4f(float constant0, float constant1, float constant2, float constant3); SSAVec4f(SSAFloat f); SSAVec4f(SSAFloat f0, SSAFloat f1, SSAFloat f2, SSAFloat f3); explicit SSAVec4f(llvm::Value *v); SSAVec4f(SSAVec4i i32); SSAFloat operator[](SSAInt index) const; + SSAFloat operator[](int index) const; static SSAVec4f insert_element(SSAVec4f vec4f, SSAFloat value, int index); static SSAVec4f bitcast(SSAVec4i i32); static SSAVec4f sqrt(SSAVec4f f); diff --git a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp index 6a197ec90..e0ed8bc86 100644 --- a/src/r_compiler/ssa/ssa_vec4f_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4f_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec4f_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec4fPtr::SSAVec4fPtr() : v(0) diff --git a/src/r_compiler/ssa/ssa_vec4i.cpp b/src/r_compiler/ssa/ssa_vec4i.cpp index 1eed7b269..3b508412f 100644 --- a/src/r_compiler/ssa/ssa_vec4i.cpp +++ b/src/r_compiler/ssa/ssa_vec4i.cpp @@ -1,11 +1,11 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec4i.h" #include "ssa_vec4f.h" #include "ssa_vec8s.h" #include "ssa_vec16ub.h" #include "ssa_int.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec4i::SSAVec4i() : v(0) @@ -67,11 +67,16 @@ SSAVec4i::SSAVec4i(SSAVec4f f32) v = SSAScope::builder().CreateCall(SSAScope::intrinsic(llvm::Intrinsic::x86_sse2_cvttps2dq), f32.v, SSAScope::hint()); } -SSAInt SSAVec4i::operator[](SSAInt index) +SSAInt SSAVec4i::operator[](SSAInt index) const { return SSAInt::from_llvm(SSAScope::builder().CreateExtractElement(v, index.v, SSAScope::hint())); } +SSAInt SSAVec4i::operator[](int index) const +{ + return (*this)[SSAInt(index)]; +} + SSAVec4i SSAVec4i::insert(SSAInt index, SSAInt value) { return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, index.v, SSAScope::hint())); @@ -82,6 +87,11 @@ SSAVec4i SSAVec4i::insert(int index, SSAInt value) return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, index, SSAScope::hint())); } +SSAVec4i SSAVec4i::insert(int index, int value) +{ + return insert(index, SSAInt(value)); +} + llvm::Type *SSAVec4i::llvm_type() { return llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4); @@ -125,12 +135,12 @@ void SSAVec4i::extend(SSAVec16ub a, SSAVec4i &out0, SSAVec4i &out1, SSAVec4i &ou SSAVec4i SSAVec4i::extendhi(SSAVec8s i16) { - return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, 0, 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7)); // _mm_unpackhi_epi16 + return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, SSAVec8s((short)0), 4, 8+4, 5, 8+5, 6, 8+6, 7, 8+7)); // _mm_unpackhi_epi16 } SSAVec4i SSAVec4i::extendlo(SSAVec8s i16) { - return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, 0, 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3)); // _mm_unpacklo_epi16 + return SSAVec4i::bitcast(SSAVec8s::shuffle(i16, SSAVec8s((short)0), 0, 8+0, 1, 8+1, 2, 8+2, 3, 8+3)); // _mm_unpacklo_epi16 } SSAVec4i SSAVec4i::combinehi(SSAVec8s a, SSAVec8s b) diff --git a/src/r_compiler/ssa/ssa_vec4i.h b/src/r_compiler/ssa/ssa_vec4i.h index c1c9140d7..89cda1646 100644 --- a/src/r_compiler/ssa/ssa_vec4i.h +++ b/src/r_compiler/ssa/ssa_vec4i.h @@ -13,15 +13,17 @@ class SSAVec4i { public: SSAVec4i(); - SSAVec4i(int constant); - SSAVec4i(int constant0, int constant1, int constant2, int constant3); + explicit SSAVec4i(int constant); + explicit SSAVec4i(int constant0, int constant1, int constant2, int constant3); SSAVec4i(SSAInt i); SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3); explicit SSAVec4i(llvm::Value *v); SSAVec4i(SSAVec4f f32); - SSAInt operator[](SSAInt index); + SSAInt operator[](SSAInt index) const; + SSAInt operator[](int index) const; SSAVec4i insert(SSAInt index, SSAInt value); SSAVec4i insert(int index, SSAInt value); + SSAVec4i insert(int index, int value); static SSAVec4i bitcast(SSAVec4f f32); static SSAVec4i bitcast(SSAVec8s i16); static SSAVec4i shuffle(const SSAVec4i &f0, int index0, int index1, int index2, int index3); diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp index 7138c30d2..f75ccd43f 100644 --- a/src/r_compiler/ssa/ssa_vec4i_ptr.cpp +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.cpp @@ -1,7 +1,7 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec4i_ptr.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec4iPtr::SSAVec4iPtr() : v(0) diff --git a/src/r_compiler/ssa/ssa_vec4i_ptr.h b/src/r_compiler/ssa/ssa_vec4i_ptr.h index 56937b1cc..257b4e34f 100644 --- a/src/r_compiler/ssa/ssa_vec4i_ptr.h +++ b/src/r_compiler/ssa/ssa_vec4i_ptr.h @@ -15,6 +15,7 @@ public: static SSAVec4iPtr from_llvm(llvm::Value *v) { return SSAVec4iPtr(v); } static llvm::Type *llvm_type(); SSAVec4iPtr operator[](SSAInt index) const; + SSAVec4iPtr operator[](int index) const { return (*this)[SSAInt(index)]; } SSAVec4i load() const; SSAVec4i load_unaligned() const; void store(const SSAVec4i &new_value); diff --git a/src/r_compiler/ssa/ssa_vec8s.cpp b/src/r_compiler/ssa/ssa_vec8s.cpp index d61a4c4a9..6016b551f 100644 --- a/src/r_compiler/ssa/ssa_vec8s.cpp +++ b/src/r_compiler/ssa/ssa_vec8s.cpp @@ -1,9 +1,9 @@ +#include "r_compiler/llvm_include.h" #include "ssa_vec8s.h" #include "ssa_vec4i.h" #include "ssa_vec16ub.h" #include "ssa_scope.h" -#include "r_compiler/llvm_include.h" SSAVec8s::SSAVec8s() : v(0) @@ -77,12 +77,12 @@ SSAVec8s SSAVec8s::shuffle(const SSAVec8s &i0, const SSAVec8s &i1, int index0, i SSAVec8s SSAVec8s::extendhi(SSAVec16ub a) { - return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, 0, 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15)); // _mm_unpackhi_epi8 + return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, SSAVec16ub((unsigned char)0), 8, 16+8, 9, 16+9, 10, 16+10, 11, 16+11, 12, 16+12, 13, 16+13, 14, 16+14, 15, 16+15)); // _mm_unpackhi_epi8 } SSAVec8s SSAVec8s::extendlo(SSAVec16ub a) { - return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, 0, 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 + return SSAVec8s::bitcast(SSAVec16ub::shuffle(a, SSAVec16ub((unsigned char)0), 0, 16+0, 1, 16+1, 2, 16+2, 3, 16+3, 4, 16+4, 5, 16+5, 6, 16+6, 7, 16+7)); // _mm_unpacklo_epi8 } /* diff --git a/src/r_compiler/ssa/ssa_vec8s.h b/src/r_compiler/ssa/ssa_vec8s.h index aded358dd..40263773b 100644 --- a/src/r_compiler/ssa/ssa_vec8s.h +++ b/src/r_compiler/ssa/ssa_vec8s.h @@ -11,8 +11,8 @@ class SSAVec8s { public: SSAVec8s(); - SSAVec8s(short constant); - SSAVec8s(short constant0, short constant1, short constant2, short constant3, short constant4, short constant5, short constant6, short constant7); + explicit SSAVec8s(short constant); + explicit SSAVec8s(short constant0, short constant1, short constant2, short constant3, short constant4, short constant5, short constant6, short constant7); explicit SSAVec8s(llvm::Value *v); SSAVec8s(SSAVec4i i0, SSAVec4i i1); static SSAVec8s bitcast(SSAVec16ub i8);