Apply things learned from making hsh to atdna

This commit is contained in:
Jack Andersen 2020-09-28 10:48:27 -10:00
parent aa07559839
commit 0a81594056
5 changed files with 56 additions and 36 deletions

View File

@ -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 $<TARGET_FILE:atdna> -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()

View File

@ -66,7 +66,7 @@ function(atdna out)
# Use Ninja's DEPFILE parser in cooperation with atdna
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
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 $<TARGET_FILE:atdna>
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}")

View File

@ -119,7 +119,7 @@ function(atdna out incdirs cdefs)
ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d
"$<$<BOOL:${incdirs}>:-I$<JOIN:${incdirs},;-I>>"
"$<$<BOOL:${cdefs}>:-D$<JOIN:${cdefs},;-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}
"$<$<BOOL:${incdirs}>:-I$<JOIN:${incdirs},;-I>>"
"$<$<BOOL:${cdefs}>:-D$<JOIN:${cdefs},;-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}"

View File

@ -1243,17 +1243,13 @@ int main(int argc, const char** argv) {
llvm::cl::PrintHelpMessage();
std::vector<std::string> 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) {

View File

@ -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 <class _Vp, class _Tp, class _Abi>
inline bool operator<(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a < _Vp(b); }
template <class _Vp, class _Tp, class _Abi>
inline bool operator<=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a <= _Vp(b); }
template <class _Vp, class _Tp, class _Abi>
inline bool operator>(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a > _Vp(b); }
template <class _Vp, class _Tp, class _Abi>
inline bool operator>=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a >= _Vp(b); }
template <class _Vp, class _Tp, class _Abi>
inline bool operator==(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a == _Vp(b); }
template <class _Vp, class _Tp, class _Abi>
inline bool operator!=(_Vp a, const __simd_reference<_Vp, _Tp, _Abi>& b) { return a != _Vp(b); }
template <class _Tp, class _Abi>
class __simd_mask_reference {