Skip to content

Commit ac078e2

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

16 files changed

+69
-51
lines changed

engine/baseclient.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,13 @@ bool CBaseClient::SendServerInfo( void )
706706

707707
serverinfo.WriteToBuffer( msg );
708708

709+
#ifndef SWDS
709710
if ( IsX360() && serverinfo.m_nMaxClients > 1 )
710711
{
711712
Msg( "Telling clients to connect" );
712713
g_pMatchmaking->TellClientsToConnect();
713714
}
715+
#endif
714716

715717
// send first tick
716718
m_nSignonTick = m_Server->m_nTickCount;

engine/common.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ COM_ExplainDisconnection
9797
*/
9898
void COM_ExplainDisconnection( bool bPrint, const char *fmt, ... )
9999
{
100+
#ifndef SWDS
100101
if ( IsX360() )
101102
{
102103
g_pMatchmaking->SessionNotification( SESSION_NOTIFY_LOST_SERVER );
103104
}
104105
else
106+
#endif
105107
{
106108
va_list argptr;
107109
char string[1024];
@@ -146,11 +148,13 @@ COM_ExtendedExplainDisconnection
146148
*/
147149
void COM_ExtendedExplainDisconnection( bool bPrint, const char *fmt, ... )
148150
{
151+
#ifndef SWDS
149152
if ( IsX360() )
150153
{
151154
g_pMatchmaking->SessionNotification( SESSION_NOTIFY_LOST_SERVER );
152155
}
153156
else
157+
#endif
154158
{
155159
va_list argptr;
156160
char string[1024];

engine/l_studio.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -4360,13 +4360,14 @@ ModelInstanceHandle_t CModelRender::CreateInstance( IClientRenderable *pRenderab
43604360
// builds out color meshes or loads disk colors, now at load/create time
43614361
RecomputeStaticLighting( handle );
43624362
}
4363-
else
4364-
if ( r_decalstaticprops.GetBool() && instance.m_LightCacheHandle )
4365-
{
4366-
instance.m_AmbientLightingState = *(LightcacheGetStatic( *pCache, NULL, LIGHTCACHEFLAGS_STATIC ));
4367-
}
4363+
#ifndef SWDS
4364+
else if ( r_decalstaticprops.GetBool() && instance.m_LightCacheHandle )
4365+
{
4366+
instance.m_AmbientLightingState = *(LightcacheGetStatic( *pCache, NULL, LIGHTCACHEFLAGS_STATIC ));
4367+
}
4368+
#endif
43684369
}
4369-
4370+
43704371
return handle;
43714372
}
43724373

mathlib/mathlib_base.cpp

+1-1
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

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
#include "tier0/dbg.h"
1212
#include "mathlib/mathlib.h"
1313
#include "mathlib/vector.h"
14-
#if defined(__arm__) || defined(__aarch64__)
15-
#include "sse2neon.h"
16-
#endif
14+
15+
#if !defined(__arm__) && !defined(__aarch64__) && !defined(__e2k__)
1716

1817
#include "sse.h"
1918

@@ -1127,3 +1126,5 @@ vec_t DotProduct (const vec_t *a, const vec_t *c)
11271126
*/
11281127

11291128
#endif // COMPILER_MSVC64
1129+
1130+
#endif

public/materialsystem/imesh.h

+2-2
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

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

public/steam/steamtypes.h

+2-6
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

+9-4
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

+7-1
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

+17-5
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

@@ -337,6 +337,8 @@ const tchar* GetProcessorVendorId()
337337
return "PPC";
338338
#elif defined ( __arm__ )
339339
return "ARM";
340+
#elif defined (__e2k__)
341+
return "MCST";
340342
#else
341343
uint32 unused, VendorIDRegisters[3];
342344

@@ -372,10 +374,12 @@ const tchar* GetProcessorArchName()
372374
return "amd64";
373375
#elif defined(__i386__) || defined(_X86_) || defined(_M_IX86)
374376
return "i386";
375-
#elif defined __aarch64__
376-
return "aarch64";
377-
#elif defined __arm__ || defined _M_ARM
378-
return "arm";
377+
#elif defined(__aarch64__)
378+
return "aarch64";
379+
#elif defined(__arm__) || defined(_M_ARM)
380+
return "arm";
381+
#elif defined(__e2k__)
382+
return "e2k";
379383
#else
380384
#error "Unknown architecture"
381385
#endif
@@ -528,6 +532,13 @@ const CPUInformation* GetCPUInformation()
528532
pi.m_nPhysicalProcessors = 3;
529533
pi.m_nLogicalProcessors = 6;
530534
#elif defined(_LINUX)
535+
#if defined(__e2k__) // MCST Elbrus 2000
536+
// e2k CPU don't have "core id" and "physical id" in "/proc/cpuinfo" (but have "processor")
537+
// and don't have Hyper-Threading (HT) technology
538+
// used sysconf() to count CPU cores
539+
pi.m_nLogicalProcessors = sysconf( _SC_NPROCESSORS_CONF ); // _SC_NPROCESSORS_ONLN may not be reliable on ARM/Android
540+
pi.m_nPhysicalProcessors = pi.m_nLogicalProcessors; // hack for CPU without Hyper-Threading (HT) technology
541+
#else
531542
// TODO: poll /dev/cpuinfo when we have some benefits from multithreading
532543
FILE *fpCpuInfo = fopen( "/proc/cpuinfo", "r" );
533544
if ( fpCpuInfo )
@@ -584,6 +595,7 @@ const CPUInformation* GetCPUInformation()
584595
pi.m_nLogicalProcessors = 1;
585596
Assert( !"couldn't read cpu information from /proc/cpuinfo" );
586597
}
598+
#endif // if e2k
587599
#elif defined(OSX) || defined(PLATFORM_BSD)
588600
int mib[2], num_cpu = 1;
589601
size_t len;

tier0/cpu_posix.cpp

+2-3
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

+1-1
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; }

tier1/reliabletimer.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,7 @@ int64 CReliableTimer::GetPerformanceCountNow()
8282
CycleCount.Sample();
8383
return CycleCount.GetLongCycles();
8484
}
85-
#elif defined( _PS3 )
86-
// use handy macro to grab tb
87-
uint64 ulNow;
88-
SYS_TIMEBASE_GET( ulNow );
89-
return ulNow;
90-
#elif (defined( __arm__ ) || defined( __aarch64__ )) && defined (POSIX)
91-
struct timespec ts;
92-
clock_gettime(CLOCK_REALTIME, &ts);
93-
return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
9485
#else
95-
uint64 un64;
96-
__asm__ __volatile__ (
97-
"rdtsc\n\t"
98-
: "=A" (un64) );
99-
return (int64)un64;
86+
return (int64)Plat_Rdtsc();
10087
#endif
10188
}

vtf/vtf.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,8 @@ static bool ReadHeaderFromBufferPastBaseHeader( CUtlBuffer &buf, VTFFileHeader_t
951951

952952
bool CVTFTexture::ReadHeader( CUtlBuffer &buf, VTFFileHeader_t &header )
953953
{
954-
if ( IsX360() && SetupByteSwap( buf ) )
954+
#ifdef _X360
955+
if ( SetupByteSwap( buf ) )
955956
{
956957
VTFFileBaseHeader_t baseHeader;
957958
m_Swap.SwapFieldsToTargetEndian( &baseHeader, (VTFFileBaseHeader_t*)buf.PeekGet() );
@@ -979,6 +980,7 @@ bool CVTFTexture::ReadHeader( CUtlBuffer &buf, VTFFileHeader_t &header )
979980
}
980981
}
981982
}
983+
#endif
982984

983985
memset( &header, 0, sizeof(VTFFileHeader_t) );
984986
buf.Get( &header, sizeof(VTFFileBaseHeader_t) );

wscript

+3
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,9 @@ def configure(conf):
502502
if conf.env.DEST_OS == 'freebsd':
503503
linkflags += ['-lexecinfo']
504504

505+
if conf.env.DEST_OS != 'darwin':
506+
linkflags += ['-latomic']
507+
505508
if conf.env.DEST_OS != 'win32':
506509
cflags += flags
507510
linkflags += flags

0 commit comments

Comments
 (0)