Skip to content

Commit 283fe97

Browse files
r-a-sattarovsdottaka
authored andcommitted
E2K: fixed build by MCST lcc compiler (#10)
backport from OpenEXR Ref: AcademySoftwareFoundation/openexr#862 (cherry picked from commit 81a8fcd)
1 parent 63d5672 commit 283fe97

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed

Source/OpenEXR/IlmImf/ImfFastHuf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ FastHufDecoder::enabled()
307307
// Enabled for ICC, GCC:
308308
// __i386__ -> x86
309309
// __x86_64__ -> 64-bit x86
310-
//
310+
// __e2k__ -> e2k (MCST Elbrus 2000)
311311

312-
#if defined (__i386__) || defined(__x86_64__)
312+
#if defined (__i386__) || defined(__x86_64__) || defined(__e2k__)
313313
return true;
314314
#else
315315
return false;

Source/OpenEXR/IlmImf/ImfSimd.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@
4848
#define IMF_HAVE_SSE2 1
4949
#endif
5050

51+
// Compiler flags on e2k (MCST Elbrus 2000) architecture
52+
#if defined(__SSE3__) && defined(__e2k__)
53+
#define IMF_HAVE_SSE3 1
54+
#endif
55+
56+
#if defined(__SSSE3__) && defined(__e2k__)
57+
#define IMF_HAVE_SSSE3 1
58+
#endif
59+
60+
#if defined(__SSE4_2__) && defined(__e2k__)
61+
#define IMF_HAVE_SSE4_2 1
62+
#endif
63+
64+
#if defined(__AVX__) && defined(__e2k__)
65+
#define IMF_HAVE_AVX 1
66+
#endif
67+
68+
#if defined(__F16C__) && defined(__e2k__)
69+
#define IMF_HAVE_F16C 1
70+
#endif
71+
5172
extern "C"
5273
{
5374
#if IMF_HAVE_SSE2

Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,27 @@
3939
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER
4040

4141
namespace {
42-
#if defined(IMF_HAVE_SSE2) && defined(__GNUC__)
42+
#if defined(IMF_HAVE_SSE2) && defined(__GNUC__) && !defined(__e2k__)
4343

4444
// Helper functions for gcc + SSE enabled
4545
void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
4646
{
4747
__asm__ __volatile__ (
4848
"cpuid"
49-
: /* Output */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
49+
: /* Output */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
5050
: /* Input */ "a"(n)
5151
: /* Clobber */);
5252
}
5353

54-
#else // IMF_HAVE_SSE2 && __GNUC__
54+
#else // IMF_HAVE_SSE2 && __GNUC__ && !__e2k__
5555

5656
// Helper functions for generic compiler - all disabled
5757
void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
5858
{
5959
eax = ebx = ecx = edx = 0;
6060
}
6161

62-
#endif // IMF_HAVE_SSE2 && __GNUC__
62+
#endif // IMF_HAVE_SSE2 && __GNUC__ && !__e2k__
6363

6464

6565
#ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
@@ -68,7 +68,7 @@ namespace {
6868
{
6969
__asm__ __volatile__ (
7070
"xgetbv"
71-
: /* Output */ "=a"(eax), "=d"(edx)
71+
: /* Output */ "=a"(eax), "=d"(edx)
7272
: /* Input */ "c"(n)
7373
: /* Clobber */);
7474
}
@@ -82,7 +82,7 @@ namespace {
8282

8383
#endif // OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
8484

85-
} // namespace
85+
} // namespace
8686

8787
CpuId::CpuId():
8888
sse2(false),
@@ -93,6 +93,30 @@ CpuId::CpuId():
9393
avx(false),
9494
f16c(false)
9595
{
96+
#if defined(__e2k__) // e2k - MCST Elbrus 2000 architecture
97+
// Use IMF_HAVE definitions to determine e2k CPU features
98+
# if defined(IMF_HAVE_SSE2)
99+
sse2 = true;
100+
# endif
101+
# if defined(IMF_HAVE_SSE3)
102+
sse3 = true;
103+
# endif
104+
# if defined(IMF_HAVE_SSSE3)
105+
ssse3 = true;
106+
# endif
107+
# if defined(IMF_HAVE_SSE4_1)
108+
sse4_1 = true;
109+
# endif
110+
# if defined(IMF_HAVE_SSE4_2)
111+
sse4_2 = true;
112+
# endif
113+
# if defined(IMF_HAVE_AVX)
114+
avx = true;
115+
# endif
116+
# if defined(IMF_HAVE_F16C)
117+
f16c = true;
118+
# endif
119+
#else // x86/x86_64
96120
bool osxsave = false;
97121
int max = 0;
98122
int eax, ebx, ecx, edx;
@@ -124,6 +148,7 @@ CpuId::CpuId():
124148
}
125149
}
126150
}
151+
#endif
127152
}
128153

129154
OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT

0 commit comments

Comments
 (0)