From 0a815940568548595b6cdc46a4c6af14c14edec1 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 28 Sep 2020 10:48:27 -1000 Subject: [PATCH] Apply things learned from making hsh to atdna --- atdna/CMakeLists.txt | 12 ++-- atdna/atdnaConfig.cmake.in | 4 +- atdna/atdnaHelpers.cmake | 4 +- atdna/main.cpp | 8 +-- include/athena/simd/parallelism_v2_simd.hpp | 64 ++++++++++++++------- 5 files changed, 56 insertions(+), 36 deletions(-) diff --git a/atdna/CMakeLists.txt b/atdna/CMakeLists.txt index 09b7624..085bb9f 100644 --- a/atdna/CMakeLists.txt +++ b/atdna/CMakeLists.txt @@ -142,8 +142,11 @@ endif() # ATDNA target add_executable(atdna main.cpp test.hpp ${PLAT_SRCS}) target_link_libraries(atdna ${LLVM_LIBS} ${PLAT_LIBS}) -set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS - "INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR};__STDC_LIMIT_MACROS=1;__STDC_CONSTANT_MACROS=1") +target_compile_definitions(atdna PRIVATE + INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR} + __STDC_LIMIT_MACROS=1 + __STDC_CONSTANT_MACROS=1 + ATDNA_ARGV0=${LLVM_ROOT_DIR}/bin/clang-tool) target_include_directories(atdna PRIVATE ${LLVM_INCLUDE_DIRS}) target_link_directories(atdna PRIVATE ${LLVM_LIBRARY_DIRS}) if(MSVC) @@ -170,10 +173,8 @@ export(PACKAGE atdna) # Create the atdnaConfig.cmake # ... for the build tree -set(CONF_CLANG_INCLUDE_DIR "${CLANG_INCLUDE_DIR}") configure_file(atdnaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/atdnaConfig.cmake" @ONLY) # ... for the install tree -set(CONF_CLANG_INCLUDE_DIR "\${ATHENA_INCLUDE_DIR}/clang") configure_file(atdnaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/atdnaConfig.cmake" @ONLY) # ... for both configure_file(atdnaConfigVersion.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/atdnaConfigVersion.cmake" @ONLY) @@ -193,8 +194,7 @@ install(EXPORT atdnaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT atdna) enable_testing() add_test(NAME test-dna COMMAND $ -o test.cpp - "-I${ATHENA_INCLUDE_DIR}" -isystem "${CLANG_INCLUDE_DIR}" - ${CMAKE_SOURCE_DIR}/test.hpp) + "-I${ATHENA_INCLUDE_DIR}" ${CMAKE_SOURCE_DIR}/test.hpp) endif() diff --git a/atdna/atdnaConfig.cmake.in b/atdna/atdnaConfig.cmake.in index 50d24f1..1e77791 100644 --- a/atdna/atdnaConfig.cmake.in +++ b/atdna/atdnaConfig.cmake.in @@ -66,7 +66,7 @@ function(atdna out) # Use Ninja's DEPFILE parser in cooperation with atdna add_custom_command(OUTPUT ${out} COMMAND $ ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d ${cdefcli} ${inccli} - "-I${ATHENA_INCLUDE_DIR}" -isystem "@CONF_CLANG_INCLUDE_DIR@" ${ins} + "-I${ATHENA_INCLUDE_DIR}" ${ins} DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps} DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} @@ -75,7 +75,7 @@ function(atdna out) # Use CMake's built-in dependency scanner for makefile targets add_custom_command(OUTPUT ${out} COMMAND $ ARGS ${extraargs} -o ${out_rel} ${cdefcli} ${inccli} - "-I${ATHENA_INCLUDE_DIR}" -isystem "@CONF_CLANG_INCLUDE_DIR@" ${ins} + "-I${ATHENA_INCLUDE_DIR}" ${ins} DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Generating DNA ${out_rel}") diff --git a/atdna/atdnaHelpers.cmake b/atdna/atdnaHelpers.cmake index a86cb88..e4cab12 100644 --- a/atdna/atdnaHelpers.cmake +++ b/atdna/atdnaHelpers.cmake @@ -119,7 +119,7 @@ function(atdna out incdirs cdefs) ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d "$<$:-I$>" "$<$:-D$>" - "-I${athena_SOURCE_DIR}/include" -isystem "${CLANG_INCLUDE_DIR}" ${ins} + "-I${athena_SOURCE_DIR}/include" ${ins} DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps} DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} @@ -131,7 +131,7 @@ function(atdna out incdirs cdefs) ARGS ${extraargs} -o ${out_rel} "$<$:-I$>" "$<$:-D$>" - "-I${athena_SOURCE_DIR}/include" -isystem "${CLANG_INCLUDE_DIR}" ${ins} + "-I${athena_SOURCE_DIR}/include" ${ins} DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Generating DNA ${out_rel}" diff --git a/atdna/main.cpp b/atdna/main.cpp index b21eda3..b352155 100644 --- a/atdna/main.cpp +++ b/atdna/main.cpp @@ -1243,17 +1243,13 @@ int main(int argc, const char** argv) { llvm::cl::PrintHelpMessage(); std::vector args = { - "clang-tool", -#ifdef __linux__ - "--gcc-toolchain=/usr", -#endif + XSTR(ATDNA_ARGV0), "-fsyntax-only", - "-std=c++1z", + "-std=c++2a", "-D__atdna__=1", "-Wno-expansion-to-defined", "-Wno-nullability-completeness", "-Werror=shadow-field", - "-I" XSTR(INSTALL_PREFIX) "/lib/clang/" CLANG_VERSION_STRING "/include", "-I" XSTR(INSTALL_PREFIX) "/include/Athena", }; for (int a = 1; a < argc; ++a) { diff --git a/include/athena/simd/parallelism_v2_simd.hpp b/include/athena/simd/parallelism_v2_simd.hpp index c1424ce..804ca5b 100644 --- a/include/athena/simd/parallelism_v2_simd.hpp +++ b/include/athena/simd/parallelism_v2_simd.hpp @@ -718,54 +718,78 @@ public: return *this; } - __simd_reference operator++() && { return std::move(*this) = __ptr_->__get(__index_) + 1; } + __simd_reference operator++() && { return std::move(*this) = _Vp(*this) + 1; } _Vp operator++(int) && { - auto __val = __ptr_->__get(__index_); + auto __val = _Vp(*this); __ptr_->__set(__index_, __val + 1); return __val; } - __simd_reference operator--() && { return std::move(*this) = __ptr_->__get(__index_) - 1; } + __simd_reference operator--() && { return std::move(*this) = _Vp(*this) - 1; } _Vp operator--(int) && { - auto __val = __ptr_->__get(__index_); + auto __val = _Vp(*this); __ptr_->__set(__index_, __val - 1); return __val; } - __simd_reference operator+=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) + __value; } + __simd_reference operator+=(_Vp __value) && { return std::move(*this) = _Vp(*this) + __value; } - __simd_reference operator-=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) - __value; } + __simd_reference operator-=(_Vp __value) && { return std::move(*this) = _Vp(*this) - __value; } - __simd_reference operator*=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) * __value; } + __simd_reference operator*=(_Vp __value) && { return std::move(*this) = _Vp(*this) * __value; } - __simd_reference operator/=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) / __value; } + __simd_reference operator/=(_Vp __value) && { return std::move(*this) = _Vp(*this) / __value; } - __simd_reference operator%=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) % __value; } + __simd_reference operator%=(_Vp __value) && { return std::move(*this) = _Vp(*this) % __value; } - __simd_reference operator>>=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) >> __value; } + __simd_reference operator>>=(_Vp __value) && { return std::move(*this) = _Vp(*this) >> __value; } - __simd_reference operator<<=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) << __value; } + __simd_reference operator<<=(_Vp __value) && { return std::move(*this) = _Vp(*this) << __value; } - __simd_reference operator&=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) & __value; } + __simd_reference operator&=(_Vp __value) && { return std::move(*this) = _Vp(*this) & __value; } - __simd_reference operator|=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) | __value; } + __simd_reference operator|=(_Vp __value) && { return std::move(*this) = _Vp(*this) | __value; } - __simd_reference operator^=(_Vp __value) && { return std::move(*this) = __ptr_->__get(__index_) ^ __value; } + __simd_reference operator^=(_Vp __value) && { return std::move(*this) = _Vp(*this) ^ __value; } - bool operator<(_Vp __value) const { return __ptr_->__get(__index_) < __value; } + bool operator<(const __simd_reference& __value) const { return _Vp(*this) < _Vp(__value); } - bool operator<=(_Vp __value) const { return __ptr_->__get(__index_) <= __value; } + bool operator<=(const __simd_reference& __value) const { return _Vp(*this) <= _Vp(__value); } - bool operator>(_Vp __value) const { return __ptr_->__get(__index_) > __value; } + bool operator>(const __simd_reference& __value) const { return _Vp(*this) > _Vp(__value); } - bool operator>=(_Vp __value) const { return __ptr_->__get(__index_) >= __value; } + bool operator>=(const __simd_reference& __value) const { return _Vp(*this) >= _Vp(__value); } - bool operator==(_Vp __value) const { return __ptr_->__get(__index_) == __value; } + bool operator==(const __simd_reference& __value) const { return _Vp(*this) == _Vp(__value); } - bool operator!=(_Vp __value) const { return __ptr_->__get(__index_) != __value; } + bool operator!=(const __simd_reference& __value) const { return _Vp(*this) != _Vp(__value); } + + bool operator<(_Vp __value) const { return _Vp(*this) < __value; } + + bool operator<=(_Vp __value) const { return _Vp(*this) <= __value; } + + bool operator>(_Vp __value) const { return _Vp(*this) > __value; } + + bool operator>=(_Vp __value) const { return _Vp(*this) >= __value; } + + bool operator==(_Vp __value) const { return _Vp(*this) == __value; } + + bool operator!=(_Vp __value) const { return _Vp(*this) != __value; } }; +template +inline bool operator<(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a < _Vp(b); } +template +inline bool operator<=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a <= _Vp(b); } +template +inline bool operator>(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a > _Vp(b); } +template +inline bool operator>=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a >= _Vp(b); } +template +inline bool operator==(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a == _Vp(b); } +template +inline bool operator!=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a != _Vp(b); } template class __simd_mask_reference {