1 #include <stdio.h>
2
3 #if defined(__clang__) && defined(__aarch64__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ <= 4))
4 /* Disable test for clang3.4/aarch64 because it cause the following error:
5 ..../lib/clang/3.4/include/arm_neon.h:65:24: error: 'neon_vector_type' attribute is not
6 supported for this target
7 */
main()8 int main()
9 {
10 return 0;
11 }
12
13 #else
14
15 #if defined(__arm__) || defined(__aarch64__)
16 #include <arm_neon.h>
17 #define SP "sp"
18 #elif defined(__i386__) || defined(__x86_64__)
19 #include <xmmintrin.h>
20 #define SP "esp"
21 typedef __m128 float32x4_t;
22 #elif defined(__mips__) // mipsel64- defines __mips__ too
23 #define SP "sp"
24 typedef float float32x4_t __attribute__ ((__vector_size__ (16)));
25 #elif !defined(__le32__) && !defined(__le64__)
26 #error unknown arch for type float32x4_t
27 #endif
28
29 #if !defined(__le32__) && !defined(__le64__)
30 class Vector4
31 {
32 public:
33 inline Vector4(float a, float b, float c, float d);
Vector4()34 inline Vector4() {}
35 inline float32x4_t Set(float a, float b, float c, float d);
36 private:
37 float32x4_t m_floatVector;
38 } __attribute__((aligned(16)));
39
Vector4(float a,float b,float c,float d)40 inline Vector4::Vector4(float a, float b, float c, float d)
41 {
42 m_floatVector = Set(a, b, c, d);
43 }
44
Set(float a,float b,float c,float d)45 inline float32x4_t Vector4::Set(float a, float b, float c, float d)
46 {
47 float32x4_t value = { a, b, c, d };
48 return value;
49 }
50
51 #if 1
initVector4(float a,float b,float c,float d)52 Vector4 initVector4(float a, float b, float c, float d)
53 {
54 return Vector4(a, b, c, d);
55 }
56 #else
initVector4(Vector4 * v,float a,float b,float c,float d)57 void initVector4(Vector4 *v, float a, float b, float c, float d)
58 {
59 v->Set(a, b, c, d);
60 }
61 #endif
62
63 float f;
64 Vector4 v;
65
main()66 int main()
67 {
68 register void *sp __asm(SP);
69 printf("sp = %p\n", sp);
70 #if 1
71 v = initVector4(f, f, f, f);
72 #else
73 Vector4 v4;
74 initVector4(&v4, f, f, f, f);
75 v = v4;
76 #endif
77 return 0;
78 }
79
80 #else // __le32__ || __le64__
81
main()82 int main()
83 {
84 return 0; // Skip this test (Should not assume vector4 type on le32 triple)
85 }
86
87 #endif
88 #endif
89