Skip to content

Commit 0d5f7a1

Browse files
committed
E2K: added initial support of MCST Elbrus 2000 CPU architecture
1 parent 5a4d0b7 commit 0d5f7a1

File tree

13 files changed

+41
-22
lines changed

13 files changed

+41
-22
lines changed

mathlib/mathlib_base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3281,7 +3281,7 @@ void MathLib_Init( float gamma, float texGamma, float brightness, int overbright
32813281
{
32823282
s_bSSEEnabled = true;
32833283

3284-
#ifndef PLATFORM_WINDOWS_PC64
3284+
#if !defined(PLATFORM_WINDOWS_PC64) && (defined(__i386__) || defined(__amd64__))
32853285
// These are not yet available.
32863286
// Select the SSE specific routines if available
32873287
pfVectorNormalize = _VectorNormalize;

mathlib/sse.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include "sse2neon.h"
1616
#endif
1717

18+
#if !defined(__e2k__)
19+
1820
#include "sse.h"
1921

2022
// memdbgon must be the last include file in a .cpp file!!!
@@ -1127,3 +1129,5 @@ vec_t DotProduct (const vec_t *a, const vec_t *c)
11271129
*/
11281130

11291131
#endif // COMPILER_MSVC64
1132+
1133+
#endif // !defined(__e2k__)

public/materialsystem/imesh.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ inline void CVertexBuilder::FastAdvanceNVertices( int n )
11521152
//-----------------------------------------------------------------------------
11531153
inline void CVertexBuilder::FastVertex( const ModelVertexDX7_t &vertex )
11541154
{
1155-
#if defined(__arm__) || defined(__aarch64__) || defined(PLATFORM_WINDOWS_PC64)
1155+
#if defined(__arm__) || defined(__aarch64__) || defined(__e2k__) || defined(PLATFORM_WINDOWS_PC64)
11561156
FastVertexSSE( vertex );
11571157
#else
11581158
Assert( m_CompressionType == VERTEX_COMPRESSION_NONE ); // FIXME: support compressed verts if needed
@@ -1354,7 +1354,7 @@ inline void CVertexBuilder::Fast4VerticesSSE(
13541354

13551355
inline void CVertexBuilder::FastVertex( const ModelVertexDX8_t &vertex )
13561356
{
1357-
#if defined(__arm__) || defined(__aarch64__) || defined(PLATFORM_WINDOWS_PC64)
1357+
#if defined(__arm__) || defined(__aarch64__) || defined(__e2k__) || defined(PLATFORM_WINDOWS_PC64)
13581358
FastVertexSSE( vertex );
13591359
#else
13601360
Assert( m_CompressionType == VERTEX_COMPRESSION_NONE ); // FIXME: support compressed verts if needed

public/mathlib/mathlib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ FORCEINLINE int RoundFloatToInt(float f)
12011201
};
12021202
flResult = __fctiw( f );
12031203
return pResult[1];
1204-
#elif defined (__arm__) || defined (__aarch64__)
1204+
#elif defined (__arm__) || defined (__aarch64__) || defined(__e2k__)
12051205
return (int)(f + 0.5f);
12061206
#else
12071207
#error Unknown architecture
@@ -1233,7 +1233,7 @@ FORCEINLINE unsigned long RoundFloatToUnsignedLong(float f)
12331233
Assert( pIntResult[1] >= 0 );
12341234
return pResult[1];
12351235
#else // !X360
1236-
#if defined(__arm__) || defined(__aarch64__)
1236+
#if defined(__arm__) || defined(__aarch64__) || defined(__e2k__)
12371237
return (unsigned long)(f + 0.5f);
12381238
#elif defined( PLATFORM_WINDOWS_PC64 )
12391239
uint nRet = ( uint ) f;

public/steam/steamtypes.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ typedef unsigned char uint8;
2424
#define POSIX 1
2525
#endif
2626

27-
#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__)
28-
#define X64BITS
29-
#endif
30-
3127
// Make sure VALVE_BIG_ENDIAN gets set on PS3, may already be set previously in Valve internal code.
3228
#if !defined(VALVE_BIG_ENDIAN) && defined(_PS3)
3329
#define VALVE_BIG_ENDIAN
@@ -48,7 +44,7 @@ typedef unsigned __int64 uint64;
4844
typedef int64 lint64;
4945
typedef uint64 ulint64;
5046

51-
#ifdef X64BITS
47+
#ifdef PLATFORM_64BITS
5248
typedef __int64 intp; // intp is an integer that can accomodate a pointer
5349
typedef unsigned __int64 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *)
5450
#else
@@ -74,7 +70,7 @@ typedef unsigned long long uint64;
7470
typedef long int lint64;
7571
typedef unsigned long int ulint64;
7672

77-
#ifdef X64BITS
73+
#ifdef PLATFORM_64BITS
7874
typedef long long intp;
7975
typedef unsigned long long uintp;
8076
#else

public/tier0/platform.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@
99
#ifndef PLATFORM_H
1010
#define PLATFORM_H
1111

12-
#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__)
12+
#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) || defined(__e2k__)
1313
#define PLATFORM_64BITS 1
1414
#endif
1515

1616
#if defined(__GCC__) || defined(__GNUC__)
1717
#define COMPILER_GCC 1
1818
#endif
1919

20+
#if defined(__LCC__) && defined(__MCST__)
21+
// MCST LCC (eLbrus Compiler Collection)
22+
#define COMPILER_MCST_LCC 1
23+
#endif
24+
2025
#ifdef __GLIBC__
2126
#define PLATFORM_GLIBC 1
2227
#endif
@@ -898,7 +903,7 @@ static FORCEINLINE double fsel(double fComparand, double fValGE, double fLT)
898903

899904
#endif
900905
#endif
901-
#elif defined (__arm__) || defined (__aarch64__)
906+
#elif defined (__arm__) || defined (__aarch64__) || defined(__e2k__)
902907
inline void SetupFPUControlWord() {}
903908
#else
904909
inline void SetupFPUControlWord()
@@ -1069,7 +1074,7 @@ inline T QWordSwapC( T dw )
10691074
// The typically used methods.
10701075
//-------------------------------------
10711076

1072-
#if (defined(__i386__) || defined(__amd64__) || defined(__arm__) || defined(__aarch64__)) && !defined(VALVE_LITTLE_ENDIAN)
1077+
#if (defined(__i386__) || defined(__amd64__) || defined(__arm__) || defined(__aarch64__) || defined(__e2k__)) && !defined(VALVE_LITTLE_ENDIAN)
10731078
#define VALVE_LITTLE_ENDIAN 1
10741079
#endif
10751080

@@ -1235,7 +1240,7 @@ PLATFORM_INTERFACE struct tm * Plat_localtime( const time_t *timep, struct tm *
12351240

12361241
inline uint64 Plat_Rdtsc()
12371242
{
1238-
#if (defined( __arm__ ) || defined( __aarch64__ )) && defined (POSIX)
1243+
#if (defined( __arm__ ) || defined( __aarch64__ ) || defined(__e2k__)) && defined (POSIX)
12391244
struct timespec t;
12401245
clock_gettime( CLOCK_REALTIME, &t);
12411246
return t.tv_sec * 1000000000ULL + t.tv_nsec;

scripts/waifulib/compiler_optimizations.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
}
3131
'''
3232

33-
VALID_BUILD_TYPES = ['fastnative', 'fast', 'release', 'debug', 'nooptimize', 'sanitize', 'none']
33+
VALID_BUILD_TYPES = ['native','fastnative', 'fast', 'release', 'debug', 'nooptimize', 'sanitize', 'none']
3434

3535
LINKFLAGS = {
3636
'common': {
@@ -65,6 +65,12 @@
6565
'clang': ['-O2', '-march=native'],
6666
'default': ['-O3']
6767
},
68+
'native': {
69+
'msvc': ['/O2', '/Oy', '/MT'],
70+
'gcc': ['-O2', '-march=native'],
71+
'clang': ['-O2', '-march=native'],
72+
'default': ['-O3']
73+
},
6874
'release': {
6975
'msvc': ['/O2', '/MT'],
7076
'owcc': ['-O3', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-finline-functions', '-finline-limit=512'],

tier0/cpu.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const tchar* GetProcessorVendorId();
2222

2323
static bool cpuid(uint32 function, uint32& out_eax, uint32& out_ebx, uint32& out_ecx, uint32& out_edx)
2424
{
25-
#if defined (__arm__) || defined (__aarch64__) || defined( _X360 )
25+
#if defined (__arm__) || defined (__aarch64__) || defined(__e2k__) || defined( _X360 )
2626
return false;
2727
#elif defined(GNUC)
2828

@@ -376,6 +376,8 @@ const tchar* GetProcessorArchName()
376376
return "aarch64";
377377
#elif defined __arm__ || defined _M_ARM
378378
return "arm";
379+
#elif defined(__e2k__)
380+
return "e2k";
379381
#else
380382
#error "Unknown architecture"
381383
#endif

tier0/cpu_posix.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ uint64 CalculateCPUFreq()
124124
}
125125
}
126126

127-
#if !defined(__arm__) && !defined(__aarch64__)
127+
#if defined(__i386__) || defined(_M_IX86)
128128
// fallback mechanism to calculate when failed
129129
// Compute the period. Loop until we get 3 consecutive periods that
130130
// are the same to within a small error. The error is chosen
@@ -178,7 +178,6 @@ uint64 CalculateCPUFreq()
178178
#else
179179
// ARM hard-coded frequency
180180
return (uint64)2000000000;
181-
#endif // if !ARM
181+
#endif // if i386
182182
#endif // if APPLE
183183
}
184-

tier1/processor_detect_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bool CheckMMXTechnology(void) { return false; }
1313
bool CheckSSETechnology(void) { return false; }
1414
bool CheckSSE2Technology(void) { return false; }
1515
bool Check3DNowTechnology(void) { return false; }
16-
#elif defined (__arm__) || defined (__aarch64__)
16+
#elif defined (__arm__) || defined (__aarch64__) || defined(__e2k__)
1717
bool CheckMMXTechnology(void) { return false; }
1818
bool CheckSSETechnology(void) { return false; }
1919
bool CheckSSE2Technology(void) { return false; }

0 commit comments

Comments
 (0)