1/**************************************************************************** 2 * Copyright (C) 2017-2018 Intel Corporation. All Rights Reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 * 23 * @file jit_pch.hpp 24 * 25 * @brief Pre-compiled header for jitter 26 * 27 * Notes: 28 * 29 ******************************************************************************/ 30 31#pragma once 32 33#if defined(_WIN32) 34#pragma warning(disable : 4146 4244 4267 4800 4996) 35#endif 36 37// llvm 3.7+ reuses "DEBUG" as an enum value 38#pragma push_macro("DEBUG") 39#undef DEBUG 40 41#include "llvm/IR/DataLayout.h" 42#include "llvm/IR/Instructions.h" 43#include "llvm/IR/LLVMContext.h" 44#include "llvm/IR/Module.h" 45#include "llvm/IR/Type.h" 46#include "llvm/IR/IRBuilder.h" 47#include "llvm/IR/IntrinsicInst.h" 48#include "llvm/ExecutionEngine/ObjectCache.h" 49 50#include "llvm/Config/llvm-config.h" 51 52#include "llvm/IR/Verifier.h" 53#include "llvm/ExecutionEngine/MCJIT.h" 54#include "llvm/Support/FileSystem.h" 55#define LLVM_F_NONE sys::fs::F_None 56 57#include "llvm/Analysis/Passes.h" 58 59#include "llvm/IR/LegacyPassManager.h" 60using FunctionPassManager = llvm::legacy::FunctionPassManager; 61using PassManager = llvm::legacy::PassManager; 62 63#include "llvm/CodeGen/Passes.h" 64#include "llvm/ExecutionEngine/ExecutionEngine.h" 65#include "llvm/Support/raw_ostream.h" 66#include "llvm/Support/TargetSelect.h" 67#include "llvm/Support/DynamicLibrary.h" 68#include "llvm/Transforms/IPO.h" 69#include "llvm/Transforms/Scalar.h" 70#if LLVM_VERSION_MAJOR >= 7 71#include "llvm/Transforms/Utils.h" 72#include "llvm/Transforms/InstCombine/InstCombine.h" 73#endif 74#include "llvm/Support/Host.h" 75#include "llvm/Support/DynamicLibrary.h" 76 77#include "llvm/IR/DIBuilder.h" 78#include "llvm/IR/Function.h" 79#include "llvm/IR/Constants.h" 80#include "llvm/IR/Type.h" 81#include "llvm/IR/Value.h" 82#include "llvm/IR/Instructions.h" 83#include "llvm/Pass.h" 84#include "llvm/Transforms/Utils/BasicBlockUtils.h" 85#include "llvm/Transforms/Utils/Cloning.h" 86#include "llvm/IR/InstIterator.h" 87#include "llvm/ADT/PostOrderIterator.h" 88#include "llvm/ADT/SCCIterator.h" 89#include "llvm/IR/Dominators.h" 90#include "llvm/Analysis/PostDominators.h" 91#include "llvm/Analysis/LoopInfo.h" 92 93#include "llvm/Transforms/Utils/Cloning.h" 94 95#if defined(_WIN32) 96#include "llvm/ADT/Triple.h" 97#endif 98#include "llvm/IR/Function.h" 99 100#include "llvm/Support/MemoryBuffer.h" 101#include "llvm/Support/SourceMgr.h" 102 103#include "llvm/Analysis/CFGPrinter.h" 104#include "llvm/IRReader/IRReader.h" 105#include "llvm/Target/TargetMachine.h" 106#include "llvm/Support/FormattedStream.h" 107#include "llvm/Support/Path.h" 108#include "llvm/Support/MemoryBuffer.h" 109#include "llvm/Config/llvm-config.h" 110 111#include "llvm/Bitcode/BitcodeWriter.h" 112#include "llvm/Bitcode/BitcodeReader.h" 113 114#if LLVM_USE_INTEL_JITEVENTS 115#include "llvm/ExecutionEngine/JITEventListener.h" 116#endif 117 118#if LLVM_VERSION_MAJOR >= 5 119static const auto Sync_CrossThread = llvm::SyncScope::System; 120static const auto Attrib_FunctionIndex = llvm::AttributeList::FunctionIndex; 121static inline llvm::AttributeSet GetFuncAttribSet(llvm::LLVMContext& ctx, 122 const llvm::AttrBuilder& b) 123{ 124 return llvm::AttributeSet::get(ctx, b); 125} 126#else 127static const auto Sync_CrossThread = llvm::SynchronizationScope::CrossThread; 128static const auto Attrib_FunctionIndex = llvm::AttributeSet::FunctionIndex; 129static inline llvm::AttributeSet GetFuncAttribSet(llvm::LLVMContext& ctx, 130 const llvm::AttrBuilder& b) 131{ 132 return llvm::AttributeSet::get(ctx, Attrib_FunctionIndex, b); 133} 134#endif 135 136#pragma pop_macro("DEBUG") 137 138#include <deque> 139#include <list> 140#include <unordered_map> 141#include <unordered_set> 142#include <iostream> 143#include <sstream> 144#include <type_traits> 145#include <cstdint> 146#include <vector> 147#include <tuple> 148#include <mutex> 149 150#include "common/os.h" 151 152#if defined(_WIN32) 153#define JIT_OBJ_EXT ".obj" 154#else 155#define JIT_OBJ_EXT ".o" 156#endif // _WIN32 157