1 //===------ OrcTestCommon.h - Utilities for Orc Unit Tests ------*- C++ -*-===//
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 // Common utilities for the Orc unit tests.
12 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_UNITTESTS_EXECUTIONENGINE_ORC_ORCTESTCOMMON_H
16 #define LLVM_UNITTESTS_EXECUTIONENGINE_ORC_ORCTESTCOMMON_H
18 #include "llvm/IR/Function.h"
19 #include "llvm/IR/IRBuilder.h"
20 #include "llvm/IR/LLVMContext.h"
21 #include "llvm/IR/Module.h"
22 #include "llvm/IR/TypeBuilder.h"
29 ModuleBuilder(LLVMContext &Context, StringRef Triple,
32 template <typename FuncType>
33 Function* createFunctionDecl(Module *M, StringRef Name) {
34 return Function::Create(
35 TypeBuilder<FuncType, false>::get(M->getContext()),
36 GlobalValue::ExternalLinkage, Name, M);
39 Module* getModule() { return M.get(); }
40 const Module* getModule() const { return M.get(); }
41 std::unique_ptr<Module> takeModule() { return std::move(M); }
44 std::unique_ptr<Module> M;
53 // TypeBuilder specialization for DummyStruct.
54 template <bool XCompile>
55 class TypeBuilder<DummyStruct, XCompile> {
57 static StructType *get(LLVMContext &Context) {
58 return StructType::get(TypeBuilder<types::i<32>[256], XCompile>::get(Context), NULL);