source: icGREP/icgrep-devel/icgrep/toolchain/cpudriver.h @ 5932

Last change on this file since 5932 was 5932, checked in by cameron, 19 months ago

Avoid segfault issue with -ShowASM

File size: 2.6 KB
Line 
1#ifndef CPUDRIVER_H
2#define CPUDRIVER_H
3#include "driver.h"
4#include <toolchain/toolchain.h>
5namespace llvm { class ExecutionEngine; }
6namespace llvm { class TargetMachine; }
7namespace llvm { class raw_fd_ostream; }
8
9#include <llvm/IR/LegacyPassManager.h>
10#if LLVM_VERSION_INTEGER >= LLVM_VERSION_CODE(4, 0, 0)
11#define ORCJIT
12#endif
13
14#ifdef ORCJIT
15#include <llvm/ExecutionEngine/Orc/CompileUtils.h>
16
17#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
18#include <llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h>
19#else
20#include <llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h>
21#endif
22#include <llvm/ExecutionEngine/Orc/IRCompileLayer.h>
23#include <llvm/ExecutionEngine/Orc/IRTransformLayer.h>
24
25#if LLVM_VERSION_INTEGER < LLVM_VERSION_CODE(5, 0, 0)
26typedef llvm::orc::ObjectLinkingLayer<> ObjectLayerT;
27typedef llvm::orc::IRCompileLayer<ObjectLayerT> CompileLayerT;
28#else
29typedef llvm::orc::RTDyldObjectLinkingLayer ObjectLayerT;
30typedef llvm::orc::IRCompileLayer<ObjectLayerT, llvm::orc::SimpleCompiler> CompileLayerT;
31#endif
32
33#endif
34
35class ParabixObjectCache;
36
37class ParabixDriver final : public Driver {
38    friend class CBuilder;
39public:
40    ParabixDriver(std::string && moduleName);
41
42    ~ParabixDriver();
43
44    void generatePipelineIR() override;
45
46    void makeKernelCall(kernel::Kernel * kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs) override;
47
48    void finalizeObject() override;
49
50    bool hasExternalFunction(const llvm::StringRef functionName) const override;
51
52    void * getMain() override; // "main" exists until the driver is deleted
53   
54    void performIncrementalCacheCleanupStep() override;
55
56private:
57    std::string getMangledName(std::string s);
58   
59    void preparePassManager();
60
61    llvm::Function * addLinkFunction(llvm::Module * mod, llvm::StringRef name, llvm::FunctionType * type, void * functionPtr) const override;
62
63    llvm::TargetMachine *                                   mTarget;
64
65#ifdef ORCJIT
66    ObjectLayerT mObjectLayer;
67    std::unique_ptr<CompileLayerT> mCompileLayer;
68
69#else
70    llvm::ExecutionEngine *                                 mEngine;
71#endif
72    ParabixObjectCache *                                    mCache;
73    std::vector<kernel::Kernel *>                           mUncachedKernel;
74    std::unique_ptr<llvm::raw_fd_ostream>                   mUnoptimizedIROutputStream;
75    std::unique_ptr<llvm::raw_fd_ostream>                   mIROutputStream;
76    std::unique_ptr<llvm::raw_fd_ostream>                   mASMOutputStream;
77    llvm::legacy::PassManager                               mPassManager;
78};
79
80#endif // CPUDRIVER_H
Note: See TracBrowser for help on using the repository browser.