Skip to content

Commit c2ce681

Browse files
committed
Add builtin_test_helpers.h header to share comparison code
1 parent 38bd7c7 commit c2ce681

File tree

4 files changed

+28
-36
lines changed

4 files changed

+28
-36
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* Helper methods for builtin intrinsic tests */
2+
3+
#include <immintrin.h>
4+
5+
#if defined(__cplusplus) && (__cplusplus >= 201103L)
6+
7+
constexpr bool match_m128(__m128 v, float x, float y, float z, float w) {
8+
return v[0] == x && v[1] == y && v[2] == z && v[3] == w;
9+
}
10+
11+
constexpr bool match_m128d(__m128d v, double x, double y) {
12+
return v[0] == x && v[1] == y;
13+
}
14+
15+
constexpr bool match_m128i(__m128i v, unsigned long long x, unsigned long long y) {
16+
return v[0] == x && v[1] == y;
17+
}
18+
19+
#define TEST_CONSTEXPR(...) static_assert(__VA_ARGS__)
20+
21+
#else
22+
23+
#define TEST_CONSTEXPR(...)
24+
25+
#endif

clang/test/CodeGen/X86/sse-builtins.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@
55

66

77
#include <immintrin.h>
8-
9-
#if defined(__cplusplus) && (__cplusplus >= 201103L)
10-
constexpr bool match_m128(__m128 v, float x, float y, float z, float w) {
11-
return v[0] == x && v[1] == y && v[2] == z && v[3] == w;
12-
}
13-
#define TEST_CONSTEXPR(...) static_assert(__VA_ARGS__)
14-
#else
15-
#define TEST_CONSTEXPR(...)
16-
#endif
8+
#include "builtin_test_helpers.h"
179

1810
// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse-intrinsics-fast-isel.ll
1911

clang/test/CodeGen/X86/sse2-builtins.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,7 @@
1111

1212

1313
#include <immintrin.h>
14-
15-
#if defined(__cplusplus) && (__cplusplus >= 201103L)
16-
constexpr bool match_m128(__m128 v, float x, float y, float z, float w) {
17-
return v[0] == x && v[1] == y && v[2] == z && v[3] == w;
18-
}
19-
constexpr bool match_m128d(__m128d v, double x, double y) {
20-
return v[0] == x && v[1] == y;
21-
}
22-
constexpr bool match_m128i(__m128i v, unsigned long long x, unsigned long long y) {
23-
return v[0] == x && v[1] == y;
24-
}
25-
#define TEST_CONSTEXPR(...) static_assert(__VA_ARGS__)
26-
#else
27-
#define TEST_CONSTEXPR(...)
28-
#endif
14+
#include "builtin_test_helpers.h"
2915

3016
// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
3117

clang/test/CodeGen/X86/sse3-builtins.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,7 @@
55

66

77
#include <immintrin.h>
8-
9-
#if defined(__cplusplus) && (__cplusplus >= 201103L)
10-
constexpr bool match_m128(__m128 v, float x, float y, float z, float w) {
11-
return v[0] == x && v[1] == y && v[2] == z && v[3] == w;
12-
}
13-
constexpr bool match_m128d(__m128d v, double x, double y) {
14-
return v[0] == x && v[1] == y;
15-
}
16-
#define TEST_CONSTEXPR(...) static_assert(__VA_ARGS__)
17-
#else
18-
#define TEST_CONSTEXPR(...)
19-
#endif
8+
#include "builtin_test_helpers.h"
209

2110
// NOTE: This should match the tests in llvm/test/CodeGen/X86/sse3-intrinsics-fast-isel.ll
2211

0 commit comments

Comments
 (0)