aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-30 10:27:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-30 10:27:02 -0700
commit82c96614ab469777da35013e698fa0c8873c231e (patch)
tree664adb0210c9c43e219fe54866dd0bf521f1bb9f
parentc45cd7c72a019f54b0f6ee873641200ecb043a25 (diff)
fix missing semicolons on simd load and store
-rw-r--r--src/jsifier.js4
-rw-r--r--tests/test_core.py47
2 files changed, 49 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index ec7ad1c2..adcb38ee 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -953,7 +953,7 @@ function JSify(data, functionsOnly, givenFunctions) {
return '(' + makeSetValue(item.ident, 0, value + '.x', native, 0, 0, item.align) + ',' +
makeSetValue(item.ident, 4, value + '.y', native, 0, 0, item.align) + ',' +
makeSetValue(item.ident, 8, value + '.z', native, 0, 0, item.align) + ',' +
- makeSetValue(item.ident, 12, value + '.w', native, 0, 0, item.align) + ')';
+ makeSetValue(item.ident, 12, value + '.w', native, 0, 0, item.align) + ');';
}
switch (impl) {
case VAR_NATIVIZED:
@@ -1329,7 +1329,7 @@ function JSify(data, functionsOnly, givenFunctions) {
return base + '32x4(' + makeGetValue(value, 0, native, 0, item.unsigned, 0, item.align) + ',' +
makeGetValue(value, 4, native, 0, item.unsigned, 0, item.align) + ',' +
makeGetValue(value, 8, native, 0, item.unsigned, 0, item.align) + ',' +
- makeGetValue(value, 12, native, 0, item.unsigned, 0, item.align) + ')';
+ makeGetValue(value, 12, native, 0, item.unsigned, 0, item.align) + ');';
}
var impl = item.ident ? getVarImpl(item.funcData, item.ident) : VAR_EMULATED;
switch (impl) {
diff --git a/tests/test_core.py b/tests/test_core.py
index 189da2bc..bed451dd 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -8660,6 +8660,53 @@ void*:16
main = main[:main.find('\n}')]
assert main.count('\n') == 7, 'must not emit too many postSets: %d' % main.count('\n')
+ def test_simd3(self):
+ if Settings.ASM_JS: Settings.ASM_JS = 2 # does not validate
+
+ self.do_run(r'''
+ #include <stdio.h>
+
+ typedef float __m128 __attribute__ ((__vector_size__ (16)));
+
+ static inline __m128 __attribute__((always_inline))
+ _mm_set_ps(const float __Z, const float __Y, const float __X, const float __W)
+ {
+ return (__m128){ __W, __X, __Y, __Z };
+ }
+
+ static inline void __attribute__((always_inline))
+ _mm_store_ps(float *__P, __m128 __A)
+ {
+ *(__m128 *)__P = __A;
+ }
+
+ static inline __m128 __attribute__((always_inline))
+ _mm_add_ps(__m128 __A, __m128 __B)
+ {
+ return __A + __B;
+ }
+
+ using namespace std;
+
+ int main(int argc, char ** argv) {
+ float __attribute__((__aligned__(16))) ar[4];
+ __m128 v1 = _mm_set_ps(9.0, 4.0, 0, -9.0);
+ __m128 v2 = _mm_set_ps(7.0, 3.0, 2.5, 1.0);
+ __m128 v3 = _mm_add_ps(v1, v2);
+ _mm_store_ps(ar, v3);
+
+ for (int i = 0; i < 4; i++) {
+ printf("%f\n", ar[i]);
+ }
+
+ return 0;
+ }
+ ''', '''-8.000000
+2.500000
+7.000000
+16.000000
+''')
+
def test_gcc_unmangler(self):
Settings.NAMED_GLOBALS = 1 # test coverage for this