1 //===- MCJITTestBase.h - Common base class for MCJIT Unit tests ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class implements functionality shared by both MCJIT C API tests, and
13 //===----------------------------------------------------------------------===//
15 #ifndef MCJIT_TEST_API_COMMON_H
16 #define MCJIT_TEST_API_COMMON_H
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/Support/Host.h"
21 #include "llvm/Support/TargetSelect.h"
23 // Used to skip tests on unsupported architectures and operating systems.
24 // To skip a test, add this macro at the top of a test-case in a suite that
25 // inherits from MCJITTestBase. See MCJITTest.cpp for examples.
26 #define SKIP_UNSUPPORTED_PLATFORM \
28 if (!ArchSupportsMCJIT() || !OSSupportsMCJIT()) \
34 class MCJITTestAPICommon {
37 : HostTriple(sys::getProcessTriple())
39 InitializeNativeTarget();
40 InitializeNativeTargetAsmPrinter();
43 // On Windows, generate ELF objects by specifying "-elf" in triple
45 #endif // LLVM_ON_WIN32
46 HostTriple = Triple::normalize(HostTriple);
49 /// Returns true if the host architecture is known to support MCJIT
50 bool ArchSupportsMCJIT() {
51 Triple Host(HostTriple);
52 if (std::find(SupportedArchs.begin(), SupportedArchs.end(), Host.getArch())
53 == SupportedArchs.end()) {
59 /// Returns true if the host OS is known to support MCJIT
60 bool OSSupportsMCJIT() {
61 Triple Host(HostTriple);
62 if (std::find(UnsupportedOSs.begin(), UnsupportedOSs.end(), Host.getOS())
63 == UnsupportedOSs.end()) {
69 std::string HostTriple;
70 SmallVector<Triple::ArchType, 4> SupportedArchs;
71 SmallVector<Triple::OSType, 4> UnsupportedOSs;
76 #endif // MCJIT_TEST_API_COMMON_H