brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · b088fa4 Raw
66 lines · c
1//===- unittests/Interpreter/InterpreterTestBase.h ------------------ C++ -===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H10#define LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H11 12#include "llvm/ExecutionEngine/Orc/LLJIT.h"13#include "llvm/Support/Error.h"14#include "llvm/Support/ManagedStatic.h"15#include "llvm/Support/TargetSelect.h"16 17#include "gtest/gtest.h"18 19#if defined(_AIX) || defined(__MVS__)20#define CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT21#endif22 23namespace clang {24 25class InterpreterTestBase : public ::testing::Test {26protected:27  static bool HostSupportsJIT() {28#ifdef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT29    return false;30#else31    if (auto JIT = llvm::orc::LLJITBuilder().create()) {32      return true;33    } else {34      llvm::consumeError(JIT.takeError());35      return false;36    }37#endif38  }39 40  void SetUp() override {41// FIXME : WebAssembly doesn't currently support Jit (see42// https: // github.com/llvm/llvm-project/pull/150977#discussion_r2237521095).43// so this check of HostSupportsJIT has been skipped44// over until support is added, and HostSupportsJIT can return true.45#ifndef __EMSCRIPTEN__46    if (!HostSupportsJIT())47      GTEST_SKIP();48#endif49  }50 51  void TearDown() override {}52 53  static void SetUpTestSuite() {54    llvm::InitializeNativeTarget();55    llvm::InitializeNativeTargetAsmPrinter();56  }57 58  static void TearDownTestSuite() { llvm::llvm_shutdown(); }59};60 61} // namespace clang62 63#undef CLANG_INTERPRETER_PLATFORM_CANNOT_CREATE_LLJIT64 65#endif // LLVM_CLANG_UNITTESTS_INTERPRETER_INTERPRETERTESTBASE_H66