Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ define_target_architecture(${CMAKE_UPPER_WORKSPACE_NAME} ${CMAKE_TARGET_ARCHITEC
define_target_endianness(${CMAKE_UPPER_WORKSPACE_NAME} ${CMAKE_TARGET_ARCHITECTURE})
define_target_platform_features(${CMAKE_UPPER_WORKSPACE_NAME})

define_target_platform_size(${CMAKE_UPPER_WORKSPACE_NAME} ${CMAKE_TARGET_ARCHITECTURE})

check_sse()
check_avx()

Expand Down
41 changes: 0 additions & 41 deletions cmake/PlatformConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,47 +57,6 @@ function(define_target_endianness prefix_name target_architecture)
endif()
endfunction()

function(define_target_platform_size prefix_name target_architecture)
string(TOUPPER ${target_architecture} UPPER_TARGET_ARCHITECTURE)
string(TOUPPER ${prefix_name} UPPER_PREFIX_NAME)

if(${CMAKE_TARGET_ARCHITECTURE} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
# check_type_size(int CMAKE_TARGET_INTEGER_SIZE_BYTE)
# math(EXPR CMAKE_TARGET_INTEGER_SIZE_BITS "${CMAKE_TARGET_INTEGER_SIZE_BYTE} * 8")
# add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=${CMAKE_TARGET_INTEGER_SIZE_BITS})

if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ALPHA" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC64" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390X")
add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=64)
add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_HAS_NATIVE_64BIT)
else()
add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=32)
endif()
else()
if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "ALPHA" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "ARM64" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "SPARC64" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "PPC64" OR
${UPPER_TARGET_ARCHITECTURE} STREQUAL "S390X")
add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=64)
add_definitions(-D${UPPER_PREFIX_NAME}_TARGET_CPU_HAS_NATIVE_64BIT)
else()
add_definitions(-D${UPPER_PREFIX_NAME}_MP_WORD_BITS=32)
endif()
endif()

if(${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86_64")
add_definitions(-D${UPPER_PREFIX_NAME}_MP_USE_X86_64_ASM)
elseif(${UPPER_TARGET_ARCHITECTURE} STREQUAL "X86")
add_definitions(-D${UPPER_PREFIX_NAME}_MP_USE_X86_32_ASM)
endif()
endfunction()

function(define_target_platform_features prefix_name)
include(CheckSymbolExists)

Expand Down
9 changes: 5 additions & 4 deletions include/nil/crypto3/detail/pack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <boost/static_assert.hpp>
#include <boost/predef/other/endian.h>
#include <boost/predef/architecture.h>

#include <algorithm>
#include <climits>
Expand Down Expand Up @@ -573,11 +574,11 @@ namespace nil {
InputType, OutputType>
packer_type;
#elif defined(BOOST_ENDIAN_BIG_WORD_AVAILABLE)
typedef packer<stream_endian::big_unit_big_bit<CRYPTO3_MP_WORD_BITS>, OutputEndianness, InputValueBits,
typedef packer<stream_endian::big_unit_big_bit<BOOST_ARCH_CURRENT_WORD_BITS>, OutputEndianness, InputValueBits,
OutputValueBits, InputType, OutputType>
packer_type;
#elif defined(BOOST_ENDIAN_LITTLE_WORD_AVAILABLE)
typedef packer<stream_endian::little_unit_big_bit<CRYPTO3_MP_WORD_BITS>, OutputEndianness,
typedef packer<stream_endian::little_unit_big_bit<BOOST_ARCH_CURRENT_WORD_BITS>, OutputEndianness,
InputValueBits, OutputValueBits, InputType, OutputType>
packer_type;
#else
Expand Down Expand Up @@ -621,11 +622,11 @@ namespace nil {
InputType, OutputType>
packer_type;
#elif defined(BOOST_ENDIAN_BIG_WORD_AVAILABLE)
typedef packer<InputEndianness, stream_endian::big_unit_big_bit<CRYPTO3_MP_WORD_BITS>, InputValueBits,
typedef packer<InputEndianness, stream_endian::big_unit_big_bit<BOOST_ARCH_CURRENT_WORD_BITS>, InputValueBits,
OutputValueBits, InputType, OutputType>
packer_type;
#elif defined(BOOST_ENDIAN_LITTLE_WORD_AVAILABLE)
typedef packer<InputEndianness, stream_endian::little_unit_big_bit<CRYPTO3_MP_WORD_BITS>,
typedef packer<InputEndianness, stream_endian::little_unit_big_bit<BOOST_ARCH_CURRENT_WORD_BITS>,
InputValueBits, OutputValueBits, InputType, OutputType>
packer_type;
#else
Expand Down
9 changes: 4 additions & 5 deletions include/nil/crypto3/detail/reverser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#include <boost/integer.hpp>
#include <boost/static_assert.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/predef/architecture.h>

#include <nil/crypto3/detail/unbounded_shift.hpp>
#include <nil/crypto3/detail/stream_endian.hpp>
Expand Down Expand Up @@ -46,12 +45,12 @@ namespace nil {
*/
inline void reverse_byte(byte_type &b) {

#if (CRYPTO3_MP_WORD_BITS == 32)
#if (BOOST_ARCH_CURRENT_WORD_BITS == 32)
b = unbounded_shr<16>(((b * 0x0802LU & 0x22110LU) | (b * 0x8020LU & 0x88440LU)) * 0x10101LU);
#elif (CRYPTO3_MP_WORD_BITS == 64)
#elif (BOOST_ARCH_CURRENT_WORD_BITS == 64)
b = (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
#else
#warning "CRYPTO3_MP_WORD_BITS not set"
#warning "BOOST_ARCH_CURRENT_WORD_BITS not set"
#endif
}

Expand Down