Skip to content

Commit

Permalink
update JoltPhysics to compile for e2k (Elbrus2000) arch
Browse files Browse the repository at this point in the history
  • Loading branch information
NicSavichev committed Jan 11, 2024
1 parent 70c1d92 commit e7194f8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions prog/3rdPartyLibs/phys/joltPhysics/Jolt/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@
#define JPH_VECTOR_ALIGNMENT 16
#define JPH_DVECTOR_ALIGNMENT 32
#define JPH_DISABLE_CUSTOM_ALLOCATOR
#elif defined(__e2k__)
// Elbrus e2k architecture
#define JPH_CPU_E2K
#define JPH_CPU_ADDRESS_BITS 64
#define JPH_USE_SSE
#define JPH_VECTOR_ALIGNMENT 16
#define JPH_DVECTOR_ALIGNMENT 32
#else
#error Unsupported CPU architecture
#endif
Expand Down Expand Up @@ -334,6 +341,8 @@
#define JPH_BREAKPOINT __asm volatile ("int $0x3")
#elif defined(JPH_CPU_ARM)
#define JPH_BREAKPOINT __builtin_trap()
#elif defined(JPH_CPU_E2K)
#define JPH_BREAKPOINT __builtin_trap()
#endif
#elif defined(JPH_PLATFORM_WASM)
#define JPH_BREAKPOINT do { } while (false) // Not supported
Expand Down
4 changes: 4 additions & 0 deletions prog/3rdPartyLibs/phys/joltPhysics/Jolt/Core/TickCounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <intrin.h>
#elif defined(JPH_CPU_X86) && defined(JPH_COMPILER_GCC)
#include <x86intrin.h>
#elif defined(JPH_CPU_E2K)
#include <x86intrin.h>
#endif

JPH_NAMESPACE_BEGIN
Expand All @@ -27,6 +29,8 @@ JPH_INLINE uint64 GetProcessorTickCount()
return JPH_PLATFORM_BLUE_GET_TICKS();
#elif defined(JPH_CPU_X86)
return __rdtsc();
#elif defined(JPH_CPU_E2K)
return __rdtsc();
#elif defined(JPH_CPU_ARM) && defined(JPH_USE_NEON)
uint64 val;
asm volatile("mrs %0, cntvct_el0" : "=r" (val));
Expand Down
4 changes: 4 additions & 0 deletions prog/3rdPartyLibs/phys/joltPhysics/Jolt/Math/Math.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ inline uint CountTrailingZeros(uint32 inValue)
#else
return __builtin_clz(__builtin_bitreverse32(inValue));
#endif
#elif defined(JPH_CPU_E2K)
return inValue ? __builtin_ctz(inValue) : 32;
#else
#error Undefined
#endif
Expand Down Expand Up @@ -146,6 +148,8 @@ inline uint CountLeadingZeros(uint32 inValue)
#else
return __builtin_clz(inValue);
#endif
#elif defined(JPH_CPU_E2K)
return inValue ? __builtin_clz(inValue) : 32;
#else
#error Undefined
#endif
Expand Down
1 change: 1 addition & 0 deletions prog/3rdPartyLibs/phys/joltPhysics/setup.jam
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ if ! $(Platform) in iOS tvOS nswitch android && ( $(Platform) != macosx || $(Mac
if $(Sanitize) = address { CPPopt += -DJPH_DISABLE_TEMP_ALLOCATOR -DJPH_DISABLE_CUSTOM_ALLOCATOR ; }
if $(Platform) = nswitch { CPPopt += -DJPH_PLATFORM_LINUX ; }
if $(Platform) in ps4 ps5 { CPPopt += -DJPH_PLATFORM_LINUX ; }
if $(Platform) = linux64 && $(LinuxArch) = e2k { CPPopt += -w2810 ; }

0 comments on commit e7194f8

Please sign in to comment.