Fix 64 bit compile errors

This commit is contained in:
Magnus Norddahl 2016-10-01 11:47:21 +02:00
parent 8765cf2016
commit c960742dbd
42 changed files with 99 additions and 62 deletions

View file

@ -258,9 +258,7 @@ endif()
set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen passes ipo set( LLVM_COMPONENTS core support asmparser asmprinter bitreader codegen passes ipo
irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld irreader transformutils instrumentation profiledata debuginfocodeview runtimedyld
object instcombine linker analysis selectiondag scalaropts vectorize executionengine object instcombine linker analysis selectiondag scalaropts vectorize executionengine
mc mcdisassembler mcparser mcjit target ) mc mcdisassembler mcparser mcjit target x86asmprinter x86info x86desc x86utils x86codegen )
set( LLVM_COMPONENTS_X86 x86asmprinter x86info x86desc x86utils x86codegen )
set( LLVM_COMPONENTS_X64 aarch64asmprinter aarch64info aarch64desc aarch64utils aarch64codegen )
# Path where it looks for the LLVM compiled files on Windows # Path where it looks for the LLVM compiled files on Windows
set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" ) set( LLVM_PRECOMPILED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" )
@ -270,24 +268,22 @@ if( NOT WIN32 )
find_package(LLVM REQUIRED CONFIG) find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") 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} ) include_directories( ${LLVM_INCLUDE_DIRS} )
set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} ) set( ZDOOM_LIBS ${ZDOOM_LIBS} ${llvm_libs} )
else() else()
include_directories( "${LLVM_PRECOMPILED_DIR}/include" ) include_directories( "${LLVM_PRECOMPILED_DIR}/include" )
if( X64 ) if( X64 )
include_directories( "${LLVM_PRECOMPILED_DIR}/64bit/include" ) include_directories( "${LLVM_PRECOMPILED_DIR}/64bit-include" )
set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/llvm/64bit" ) set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/64bit-" )
set( LLVM_ALL_COMPONENTS ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X64} )
else() else()
include_directories( "${LLVM_PRECOMPILED_DIR}/32bit/include" ) include_directories( "${LLVM_PRECOMPILED_DIR}/32bit-include" )
set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit" ) set( llvm_libs_base "${LLVM_PRECOMPILED_DIR}/32bit-" )
set( LLVM_ALL_COMPONENTS ${LLVM_COMPONENTS} ${LLVM_COMPONENTS_X86} )
endif() endif()
foreach(buildtype IN ITEMS RELEASE DEBUG) 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 "" ) 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}} ) 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}} ) set( LLVM_${buildtype}_LIBS ${LLVM_${buildtype}_LIBS} ${LLVM_${llvm_module}_LIBRARY_${buildtype}} )
endforeach( llvm_module ) 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 ) set_source_files_properties( ${NOT_COMPILED_SOURCE_FILES} PROPERTIES HEADER_FILE_ONLY TRUE )
if ( WIN32 ) if ( WIN32 )
set_source_files_properties( win32/fb_d3d9.cpp win32/fb_d3d9_wipe.cpp PROPERTIES COMPILE_FLAGS ${ZD_FASTMATH_FLAG} ) 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() endif()

View file

@ -1,5 +1,6 @@
#include "i_system.h" #include "i_system.h"
#include "r_compiler/llvm_include.h"
#include "r_compiler/fixedfunction/drawcolumncodegen.h" #include "r_compiler/fixedfunction/drawcolumncodegen.h"
#include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_function.h"
#include "r_compiler/ssa/ssa_scope.h" #include "r_compiler/ssa/ssa_scope.h"

View file

@ -1,5 +1,6 @@
#include "i_system.h" #include "i_system.h"
#include "r_compiler/llvm_include.h"
#include "r_compiler/fixedfunction/drawercodegen.h" #include "r_compiler/fixedfunction/drawercodegen.h"
#include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_function.h"
#include "r_compiler/ssa/ssa_scope.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 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; SSAInt core_skip = (thread.num_cores - (first_line + pass_skip - thread.core) % thread.num_cores) % thread.num_cores;
return pass_skip + core_skip; return pass_skip + core_skip;
} }
SSAInt DrawerCodegen::count_for_thread(SSAInt first_line, SSAInt count, SSAWorkerThread thread) 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); count = SSAInt::MIN(count, lines_until_pass_end);
SSAInt c = (count - skipped_by_thread(first_line, thread) + thread.num_cores - 1) / thread.num_cores; 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) SSAUBytePtr DrawerCodegen::dest_for_thread(SSAInt first_line, SSAInt pitch, SSAUBytePtr dest, SSAWorkerThread thread)

View file

@ -1,5 +1,6 @@
#include "i_system.h" #include "i_system.h"
#include "r_compiler/llvm_include.h"
#include "r_compiler/fixedfunction/drawspancodegen.h" #include "r_compiler/fixedfunction/drawspancodegen.h"
#include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_function.h"
#include "r_compiler/ssa/ssa_scope.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; xmask = ((SSAInt(1) << xbits) - 1) << ybits;
// 64x64 is the most common case by far, so special case it. // 64x64 is the most common case by far, so special case it.
is_64x64 = xbits == 6 && ybits == 6; is_64x64 = xbits == SSAInt(6) && ybits == SSAInt(6);
is_simple_shade = (flags & DrawSpanArgs::simple_shade) == DrawSpanArgs::simple_shade; is_simple_shade = (flags & DrawSpanArgs::simple_shade) == SSAInt(DrawSpanArgs::simple_shade);
is_nearest_filter = (flags & DrawSpanArgs::nearest_filter) == DrawSpanArgs::nearest_filter; is_nearest_filter = (flags & DrawSpanArgs::nearest_filter) == SSAInt(DrawSpanArgs::nearest_filter);
SSAIfBlock branch; SSAIfBlock branch;
branch.if_block(is_simple_shade); 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 DrawSpanCodegen::Loop4x(DrawSpanVariant variant, bool isSimpleShade, bool isNearestFilter, bool is64x64)
{ {
SSAInt sseLength = count / 4; SSAInt sseLength = count / 4;
stack_index.store(0); stack_index.store(SSAInt(0));
{ {
SSAForBlock loop; SSAForBlock loop;
SSAInt index = stack_index.load(); SSAInt index = stack_index.load();
@ -165,7 +166,7 @@ SSAVec4i DrawSpanCodegen::Sample(SSAInt xfrac, SSAInt yfrac, bool isNearestFilte
{ {
if (is64x64) if (is64x64)
{ {
return sample_linear(source, xfrac, yfrac, 26, 26); return sample_linear(source, xfrac, yfrac, SSAInt(26), SSAInt(26));
} }
else else
{ {

View file

@ -1,5 +1,6 @@
#include "i_system.h" #include "i_system.h"
#include "r_compiler/llvm_include.h"
#include "r_compiler/fixedfunction/drawwallcodegen.h" #include "r_compiler/fixedfunction/drawwallcodegen.h"
#include "r_compiler/ssa/ssa_function.h" #include "r_compiler/ssa/ssa_function.h"
#include "r_compiler/ssa/ssa_scope.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_start_y = thread_data[0][2].load();
thread.pass_end_y = thread_data[0][3].load(); thread.pass_end_y = thread_data[0][3].load();
is_simple_shade = (flags & DrawWallArgs::simple_shade) == DrawWallArgs::simple_shade; is_simple_shade = (flags & DrawWallArgs::simple_shade) == SSAInt(DrawWallArgs::simple_shade);
is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == DrawWallArgs::nearest_filter; is_nearest_filter = (flags & DrawWallArgs::nearest_filter) == SSAInt(DrawWallArgs::nearest_filter);
count = count_for_thread(dest_y, count, thread); count = count_for_thread(dest_y, count, thread);
dest = dest_for_thread(dest_y, pitch, dest, 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; int numColumns = fourColumns ? 4 : 1;
stack_index.store(0); stack_index.store(SSAInt(0));
{ {
SSAForBlock loop; SSAForBlock loop;
SSAInt index = stack_index.load(); SSAInt index = stack_index.load();

View file

@ -1,6 +1,8 @@
#pragma once #pragma once
#ifdef _MSC_VER
#if defined(min) #if defined(min)
#define llvm_min_bug min #define llvm_min_bug min
#undef 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: 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: 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: 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 <llvm/IR/DerivedTypes.h> #include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/LLVMContext.h> #include <llvm/IR/LLVMContext.h>
@ -39,6 +45,8 @@
#include <llvm/CodeGen/AsmPrinter.h> #include <llvm/CodeGen/AsmPrinter.h>
#include <llvm/MC/MCAsmInfo.h> #include <llvm/MC/MCAsmInfo.h>
#ifdef _MSC_VER
#if defined(llvm_min_bug) #if defined(llvm_min_bug)
#define min llvm_min_bug #define min llvm_min_bug
#undef llvm_min_bug #undef llvm_min_bug
@ -47,3 +55,5 @@
#define max llvm_max_bug #define max llvm_max_bug
#undef llvm_max_bug #undef llvm_max_bug
#endif #endif
#endif

View file

@ -1,5 +1,6 @@
#include "i_system.h" #include "i_system.h"
#include "r_compiler/llvm_include.h"
#include "r_compiler/fixedfunction/drawspancodegen.h" #include "r_compiler/fixedfunction/drawspancodegen.h"
#include "r_compiler/fixedfunction/drawwallcodegen.h" #include "r_compiler/fixedfunction/drawwallcodegen.h"
#include "r_compiler/fixedfunction/drawcolumncodegen.h" #include "r_compiler/fixedfunction/drawcolumncodegen.h"

View file

@ -1,7 +1,7 @@
#include "r_compiler/llvm_include.h"
#include "ssa_bool.h" #include "ssa_bool.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSABool::SSABool() SSABool::SSABool()
: v(0) : v(0)

View file

@ -1,8 +1,8 @@
#include "r_compiler/llvm_include.h"
#include "ssa_float.h" #include "ssa_float.h"
#include "ssa_int.h" #include "ssa_int.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAFloat::SSAFloat() SSAFloat::SSAFloat()
: v(0) : v(0)

View file

@ -11,7 +11,7 @@ class SSAFloat
public: public:
SSAFloat(); SSAFloat();
SSAFloat(SSAInt i); SSAFloat(SSAInt i);
SSAFloat(float constant); explicit SSAFloat(float constant);
explicit SSAFloat(llvm::Value *v); explicit SSAFloat(llvm::Value *v);
static SSAFloat from_llvm(llvm::Value *v) { return SSAFloat(v); } static SSAFloat from_llvm(llvm::Value *v) { return SSAFloat(v); }
static llvm::Type *llvm_type(); static llvm::Type *llvm_type();

View file

@ -1,7 +1,7 @@
#include "r_compiler/llvm_include.h"
#include "ssa_float_ptr.h" #include "ssa_float_ptr.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAFloatPtr::SSAFloatPtr() SSAFloatPtr::SSAFloatPtr()
: v(0) : v(0)

View file

@ -16,6 +16,7 @@ public:
static SSAFloatPtr from_llvm(llvm::Value *v) { return SSAFloatPtr(v); } static SSAFloatPtr from_llvm(llvm::Value *v) { return SSAFloatPtr(v); }
static llvm::Type *llvm_type(); static llvm::Type *llvm_type();
SSAFloatPtr operator[](SSAInt index) const; SSAFloatPtr operator[](SSAInt index) const;
SSAFloatPtr operator[](int index) const { return (*this)[SSAInt(index)]; }
SSAFloat load() const; SSAFloat load() const;
SSAVec4f load_vec4f() const; SSAVec4f load_vec4f() const;
SSAVec4f load_unaligned_vec4f() const; SSAVec4f load_unaligned_vec4f() const;

View file

@ -1,4 +1,5 @@
#include "r_compiler/llvm_include.h"
#include "ssa_for_block.h" #include "ssa_for_block.h"
#include "ssa_scope.h" #include "ssa_scope.h"

View file

@ -2,7 +2,6 @@
#pragma once #pragma once
#include "ssa_bool.h" #include "ssa_bool.h"
#include "r_compiler/llvm_include.h"
class SSAForBlock class SSAForBlock
{ {

View file

@ -1,9 +1,9 @@
#include "r_compiler/llvm_include.h"
#include "ssa_function.h" #include "ssa_function.h"
#include "ssa_int.h" #include "ssa_int.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "ssa_value.h" #include "ssa_value.h"
#include "r_compiler/llvm_include.h"
SSAFunction::SSAFunction(const std::string name) SSAFunction::SSAFunction(const std::string name)
: name(name), return_type(llvm::Type::getVoidTy(SSAScope::context())), func() : name(name), return_type(llvm::Type::getVoidTy(SSAScope::context())), func()

View file

@ -1,4 +1,5 @@
#include "r_compiler/llvm_include.h"
#include "ssa_if_block.h" #include "ssa_if_block.h"
#include "ssa_scope.h" #include "ssa_scope.h"

View file

@ -3,7 +3,6 @@
#include "ssa_bool.h" #include "ssa_bool.h"
#include "ssa_phi.h" #include "ssa_phi.h"
#include "r_compiler/llvm_include.h"
class SSAIfBlock class SSAIfBlock
{ {

View file

@ -1,9 +1,9 @@
#include "r_compiler/llvm_include.h"
#include "ssa_int.h" #include "ssa_int.h"
#include "ssa_float.h" #include "ssa_float.h"
#include "ssa_bool.h" #include "ssa_bool.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAInt::SSAInt() SSAInt::SSAInt()
: v(0) : v(0)

View file

@ -10,7 +10,7 @@ class SSAInt
{ {
public: public:
SSAInt(); SSAInt();
SSAInt(int constant); explicit SSAInt(int constant);
SSAInt(SSAFloat f); SSAInt(SSAFloat f);
explicit SSAInt(llvm::Value *v); explicit SSAInt(llvm::Value *v);
static SSAInt from_llvm(llvm::Value *v) { return SSAInt(v); } static SSAInt from_llvm(llvm::Value *v) { return SSAInt(v); }

View file

@ -1,7 +1,7 @@
#include "r_compiler/llvm_include.h"
#include "ssa_int_ptr.h" #include "ssa_int_ptr.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAIntPtr::SSAIntPtr() SSAIntPtr::SSAIntPtr()
: v(0) : v(0)

View file

@ -16,6 +16,7 @@ public:
static SSAIntPtr from_llvm(llvm::Value *v) { return SSAIntPtr(v); } static SSAIntPtr from_llvm(llvm::Value *v) { return SSAIntPtr(v); }
static llvm::Type *llvm_type(); static llvm::Type *llvm_type();
SSAIntPtr operator[](SSAInt index) const; SSAIntPtr operator[](SSAInt index) const;
SSAIntPtr operator[](int index) const { return (*this)[SSAInt(index)]; }
SSAInt load() const; SSAInt load() const;
SSAVec4i load_vec4i() const; SSAVec4i load_vec4i() const;
SSAVec4i load_unaligned_vec4i() const; SSAVec4i load_unaligned_vec4i() const;

View file

@ -1,4 +1,5 @@
#include "r_compiler/llvm_include.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "ssa_int.h" #include "ssa_int.h"

View file

@ -1,8 +1,6 @@
#pragma once #pragma once
#include "r_compiler/llvm_include.h"
class SSAInt; class SSAInt;
class SSAScope class SSAScope

View file

@ -1,9 +1,9 @@
#include "r_compiler/llvm_include.h"
#include "ssa_short.h" #include "ssa_short.h"
#include "ssa_float.h" #include "ssa_float.h"
#include "ssa_int.h" #include "ssa_int.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAShort::SSAShort() SSAShort::SSAShort()
: v(0) : v(0)

View file

@ -11,7 +11,7 @@ class SSAShort
{ {
public: public:
SSAShort(); SSAShort();
SSAShort(int constant); explicit SSAShort(int constant);
SSAShort(SSAFloat f); SSAShort(SSAFloat f);
explicit SSAShort(llvm::Value *v); explicit SSAShort(llvm::Value *v);
static SSAShort from_llvm(llvm::Value *v) { return SSAShort(v); } static SSAShort from_llvm(llvm::Value *v) { return SSAShort(v); }

View file

@ -1,4 +1,5 @@
#include "r_compiler/llvm_include.h"
#include "ssa_struct_type.h" #include "ssa_struct_type.h"
#include "ssa_scope.h" #include "ssa_scope.h"

View file

@ -1,7 +1,7 @@
#include "r_compiler/llvm_include.h"
#include "ssa_ubyte.h" #include "ssa_ubyte.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAUByte::SSAUByte() SSAUByte::SSAUByte()
: v(0) : v(0)

View file

@ -8,7 +8,7 @@ class SSAUByte
{ {
public: public:
SSAUByte(); SSAUByte();
SSAUByte(unsigned char constant); explicit SSAUByte(unsigned char constant);
explicit SSAUByte(llvm::Value *v); explicit SSAUByte(llvm::Value *v);
static SSAUByte from_llvm(llvm::Value *v) { return SSAUByte(v); } static SSAUByte from_llvm(llvm::Value *v) { return SSAUByte(v); }
static llvm::Type *llvm_type(); static llvm::Type *llvm_type();

View file

@ -1,7 +1,7 @@
#include "r_compiler/llvm_include.h"
#include "ssa_ubyte_ptr.h" #include "ssa_ubyte_ptr.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAUBytePtr::SSAUBytePtr() SSAUBytePtr::SSAUBytePtr()
: v(0) : v(0)
@ -38,7 +38,7 @@ SSAVec4i SSAUBytePtr::load_vec4ub() const
v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(3).v, SSAScope::hint()); v = SSAScope::builder().CreateInsertElement(v, SSAInt(0).v, SSAInt(3).v, SSAScope::hint());
SSAVec4i v4i = SSAVec4i::from_llvm(v); 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 return SSAVec4i::extendlo(low); // _mm_unpacklo_epi16
/* /*
llvm::PointerType *m4xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 4)->getPointerTo(); llvm::PointerType *m4xint8typeptr = llvm::VectorType::get(llvm::Type::getInt8Ty(SSAScope::context()), 4)->getPointerTo();

View file

@ -18,6 +18,7 @@ public:
static SSAUBytePtr from_llvm(llvm::Value *v) { return SSAUBytePtr(v); } static SSAUBytePtr from_llvm(llvm::Value *v) { return SSAUBytePtr(v); }
static llvm::Type *llvm_type(); static llvm::Type *llvm_type();
SSAUBytePtr operator[](SSAInt index) const; SSAUBytePtr operator[](SSAInt index) const;
SSAUBytePtr operator[](int index) const { return (*this)[SSAInt(index)]; }
SSAUByte load() const; SSAUByte load() const;
SSAVec4i load_vec4ub() const; SSAVec4i load_vec4ub() const;
SSAVec8s load_vec8s() const; SSAVec8s load_vec8s() const;

View file

@ -1,8 +1,8 @@
#include "r_compiler/llvm_include.h"
#include "ssa_value.h" #include "ssa_value.h"
#include "ssa_int.h" #include "ssa_int.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAValue SSAValue::load() SSAValue SSAValue::load()
{ {

View file

@ -1,9 +1,9 @@
#include "r_compiler/llvm_include.h"
#include "ssa_vec16ub.h" #include "ssa_vec16ub.h"
#include "ssa_vec8s.h" #include "ssa_vec8s.h"
#include "ssa_vec4i.h" #include "ssa_vec4i.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAVec16ub::SSAVec16ub() SSAVec16ub::SSAVec16ub()
: v(0) : v(0)

View file

@ -11,8 +11,8 @@ class SSAVec16ub
{ {
public: public:
SSAVec16ub(); SSAVec16ub();
SSAVec16ub(unsigned char constant); explicit SSAVec16ub(unsigned char constant);
SSAVec16ub( 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 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); 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); explicit SSAVec16ub(llvm::Value *v);

View file

@ -1,10 +1,10 @@
#include "r_compiler/llvm_include.h"
#include "ssa_vec4f.h" #include "ssa_vec4f.h"
#include "ssa_vec4i.h" #include "ssa_vec4i.h"
#include "ssa_float.h" #include "ssa_float.h"
#include "ssa_int.h" #include "ssa_int.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAVec4f::SSAVec4f() SSAVec4f::SSAVec4f()
: v(0) : v(0)
@ -75,6 +75,11 @@ SSAFloat SSAVec4f::operator[](SSAInt index) const
return SSAFloat::from_llvm(SSAScope::builder().CreateExtractElement(v, index.v, SSAScope::hint())); 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) 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)))); return from_llvm(SSAScope::builder().CreateInsertElement(vec4f.v, value.v, llvm::ConstantInt::get(SSAScope::context(), llvm::APInt(32, (uint64_t)index))));

View file

@ -12,13 +12,14 @@ class SSAVec4f
{ {
public: public:
SSAVec4f(); SSAVec4f();
SSAVec4f(float constant); explicit SSAVec4f(float constant);
SSAVec4f(float constant0, float constant1, float constant2, float constant3); explicit SSAVec4f(float constant0, float constant1, float constant2, float constant3);
SSAVec4f(SSAFloat f); SSAVec4f(SSAFloat f);
SSAVec4f(SSAFloat f0, SSAFloat f1, SSAFloat f2, SSAFloat f3); SSAVec4f(SSAFloat f0, SSAFloat f1, SSAFloat f2, SSAFloat f3);
explicit SSAVec4f(llvm::Value *v); explicit SSAVec4f(llvm::Value *v);
SSAVec4f(SSAVec4i i32); SSAVec4f(SSAVec4i i32);
SSAFloat operator[](SSAInt index) const; SSAFloat operator[](SSAInt index) const;
SSAFloat operator[](int index) const;
static SSAVec4f insert_element(SSAVec4f vec4f, SSAFloat value, int index); static SSAVec4f insert_element(SSAVec4f vec4f, SSAFloat value, int index);
static SSAVec4f bitcast(SSAVec4i i32); static SSAVec4f bitcast(SSAVec4i i32);
static SSAVec4f sqrt(SSAVec4f f); static SSAVec4f sqrt(SSAVec4f f);

View file

@ -1,7 +1,7 @@
#include "r_compiler/llvm_include.h"
#include "ssa_vec4f_ptr.h" #include "ssa_vec4f_ptr.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAVec4fPtr::SSAVec4fPtr() SSAVec4fPtr::SSAVec4fPtr()
: v(0) : v(0)

View file

@ -1,11 +1,11 @@
#include "r_compiler/llvm_include.h"
#include "ssa_vec4i.h" #include "ssa_vec4i.h"
#include "ssa_vec4f.h" #include "ssa_vec4f.h"
#include "ssa_vec8s.h" #include "ssa_vec8s.h"
#include "ssa_vec16ub.h" #include "ssa_vec16ub.h"
#include "ssa_int.h" #include "ssa_int.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAVec4i::SSAVec4i() SSAVec4i::SSAVec4i()
: v(0) : 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()); 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())); 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) SSAVec4i SSAVec4i::insert(SSAInt index, SSAInt value)
{ {
return SSAVec4i::from_llvm(SSAScope::builder().CreateInsertElement(v, value.v, index.v, SSAScope::hint())); 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())); 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() llvm::Type *SSAVec4i::llvm_type()
{ {
return llvm::VectorType::get(llvm::Type::getInt32Ty(SSAScope::context()), 4); 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) 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) 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) SSAVec4i SSAVec4i::combinehi(SSAVec8s a, SSAVec8s b)

View file

@ -13,15 +13,17 @@ class SSAVec4i
{ {
public: public:
SSAVec4i(); SSAVec4i();
SSAVec4i(int constant); explicit SSAVec4i(int constant);
SSAVec4i(int constant0, int constant1, int constant2, int constant3); explicit SSAVec4i(int constant0, int constant1, int constant2, int constant3);
SSAVec4i(SSAInt i); SSAVec4i(SSAInt i);
SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3); SSAVec4i(SSAInt i0, SSAInt i1, SSAInt i2, SSAInt i3);
explicit SSAVec4i(llvm::Value *v); explicit SSAVec4i(llvm::Value *v);
SSAVec4i(SSAVec4f f32); 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(SSAInt index, SSAInt value);
SSAVec4i insert(int index, SSAInt value); SSAVec4i insert(int index, SSAInt value);
SSAVec4i insert(int index, int value);
static SSAVec4i bitcast(SSAVec4f f32); static SSAVec4i bitcast(SSAVec4f f32);
static SSAVec4i bitcast(SSAVec8s i16); static SSAVec4i bitcast(SSAVec8s i16);
static SSAVec4i shuffle(const SSAVec4i &f0, int index0, int index1, int index2, int index3); static SSAVec4i shuffle(const SSAVec4i &f0, int index0, int index1, int index2, int index3);

View file

@ -1,7 +1,7 @@
#include "r_compiler/llvm_include.h"
#include "ssa_vec4i_ptr.h" #include "ssa_vec4i_ptr.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAVec4iPtr::SSAVec4iPtr() SSAVec4iPtr::SSAVec4iPtr()
: v(0) : v(0)

View file

@ -15,6 +15,7 @@ public:
static SSAVec4iPtr from_llvm(llvm::Value *v) { return SSAVec4iPtr(v); } static SSAVec4iPtr from_llvm(llvm::Value *v) { return SSAVec4iPtr(v); }
static llvm::Type *llvm_type(); static llvm::Type *llvm_type();
SSAVec4iPtr operator[](SSAInt index) const; SSAVec4iPtr operator[](SSAInt index) const;
SSAVec4iPtr operator[](int index) const { return (*this)[SSAInt(index)]; }
SSAVec4i load() const; SSAVec4i load() const;
SSAVec4i load_unaligned() const; SSAVec4i load_unaligned() const;
void store(const SSAVec4i &new_value); void store(const SSAVec4i &new_value);

View file

@ -1,9 +1,9 @@
#include "r_compiler/llvm_include.h"
#include "ssa_vec8s.h" #include "ssa_vec8s.h"
#include "ssa_vec4i.h" #include "ssa_vec4i.h"
#include "ssa_vec16ub.h" #include "ssa_vec16ub.h"
#include "ssa_scope.h" #include "ssa_scope.h"
#include "r_compiler/llvm_include.h"
SSAVec8s::SSAVec8s() SSAVec8s::SSAVec8s()
: v(0) : v(0)
@ -77,12 +77,12 @@ SSAVec8s SSAVec8s::shuffle(const SSAVec8s &i0, const SSAVec8s &i1, int index0, i
SSAVec8s SSAVec8s::extendhi(SSAVec16ub a) 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) 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
} }
/* /*

View file

@ -11,8 +11,8 @@ class SSAVec8s
{ {
public: public:
SSAVec8s(); SSAVec8s();
SSAVec8s(short constant); explicit SSAVec8s(short constant);
SSAVec8s(short constant0, short constant1, short constant2, short constant3, short constant4, short constant5, short constant6, short constant7); explicit SSAVec8s(short constant0, short constant1, short constant2, short constant3, short constant4, short constant5, short constant6, short constant7);
explicit SSAVec8s(llvm::Value *v); explicit SSAVec8s(llvm::Value *v);
SSAVec8s(SSAVec4i i0, SSAVec4i i1); SSAVec8s(SSAVec4i i0, SSAVec4i i1);
static SSAVec8s bitcast(SSAVec16ub i8); static SSAVec8s bitcast(SSAVec16ub i8);