]> git.karo-electronics.de Git - karo-tx-linux.git/blob - tools/perf/tests/clang.c
Merge tag 'perf-core-for-mingo-4.12-20170503' of git://git.kernel.org/pub/scm/linux...
[karo-tx-linux.git] / tools / perf / tests / clang.c
1 #include "tests.h"
2 #include "debug.h"
3 #include "util.h"
4 #include "c++/clang-c.h"
5 #include <linux/kernel.h>
6
7 static struct {
8         int (*func)(void);
9         const char *desc;
10 } clang_testcase_table[] = {
11 #ifdef HAVE_LIBCLANGLLVM_SUPPORT
12         {
13                 .func = test__clang_to_IR,
14                 .desc = "builtin clang compile C source to IR",
15         },
16         {
17                 .func = test__clang_to_obj,
18                 .desc = "builtin clang compile C source to ELF object",
19         },
20 #endif
21 };
22
23 int test__clang_subtest_get_nr(void)
24 {
25         return (int)ARRAY_SIZE(clang_testcase_table);
26 }
27
28 const char *test__clang_subtest_get_desc(int i)
29 {
30         if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
31                 return NULL;
32         return clang_testcase_table[i].desc;
33 }
34
35 #ifndef HAVE_LIBCLANGLLVM_SUPPORT
36 int test__clang(int i __maybe_unused)
37 {
38         return TEST_SKIP;
39 }
40 #else
41 int test__clang(int i)
42 {
43         if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
44                 return TEST_FAIL;
45         return clang_testcase_table[i].func();
46 }
47 #endif