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

Last change on this file since 6184 was 6184, checked in by nmedfort, 11 months ago

Initial version of PipelineKernel? + revised StreamSet? model.

File size: 2.2 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 ObjectCacheManager;
36
37class CPUDriver final : public BaseDriver {
38public:
39
40    CPUDriver(std::string && moduleName);
41
42    ~CPUDriver();
43
44    void generateUncachedKernels() override;
45
46    void * finalizeObject(llvm::Function * mainMethod) override;
47
48    bool hasExternalFunction(const llvm::StringRef functionName) const override;
49
50private:
51
52    std::string getMangledName(std::string s);
53   
54    void preparePassManager();
55
56    llvm::Function * addLinkFunction(llvm::Module * mod, llvm::StringRef name, llvm::FunctionType * type, void * functionPtr) const override;
57
58private:
59    llvm::TargetMachine *                                   mTarget;
60    #ifdef ORCJIT
61    ObjectLayerT                                            mObjectLayer;
62    std::unique_ptr<CompileLayerT>                          mCompileLayer;
63    #else
64    llvm::ExecutionEngine *                                 mEngine;
65    #endif
66    std::unique_ptr<llvm::raw_fd_ostream>                   mUnoptimizedIROutputStream;
67    std::unique_ptr<llvm::raw_fd_ostream>                   mIROutputStream;
68    std::unique_ptr<llvm::raw_fd_ostream>                   mASMOutputStream;
69    llvm::legacy::PassManager                               mPassManager;
70};
71
72#endif // CPUDRIVER_H
Note: See TracBrowser for help on using the repository browser.