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

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

Restructuring step

File size: 1.9 KB
Line 
1#ifndef CPUDRIVER_H
2#define CPUDRIVER_H
3#include "driver.h"
4#include <llvm/IR/LegacyPassManager.h>             // for PassManager
5
6namespace llvm { class ExecutionEngine; }
7namespace llvm { class TargetMachine; }
8namespace llvm { class raw_fd_ostream; }
9
10class ParabixObjectCache;
11
12class ParabixDriver final : public Driver {
13    friend class CBuilder;
14public:
15    ParabixDriver(std::string && moduleName);
16
17    ~ParabixDriver();
18
19    void generatePipelineIR() override;
20
21    void makeKernelCall(kernel::Kernel * kb, const std::vector<parabix::StreamSetBuffer *> & inputs, const std::vector<parabix::StreamSetBuffer *> & outputs) override;
22
23    void finalizeObject() override;
24
25    bool hasExternalFunction(const llvm::StringRef functionName) const override;
26
27    void * getMain() override; // "main" exists until the driver is deleted
28   
29    void performIncrementalCacheCleanupStep() override;
30
31private:
32    void preparePassManager();
33
34    llvm::Function * addLinkFunction(llvm::Module * mod, llvm::StringRef name, llvm::FunctionType * type, void * functionPtr) const override;
35
36private:
37    llvm::TargetMachine *                                   mTarget;
38    llvm::legacy::PassManager                               mPassManager;
39    llvm::ExecutionEngine *                                 mEngine;
40    ParabixObjectCache *                                    mCache;
41    std::vector<kernel::Kernel *>                           mUncachedKernel;
42    // NOTE: when printing the IR/ASM, we cannot assume they're completely finished after finalizeObject is executed. Instead we store a
43    // pointer and delete them once the driver (and any processing) is complete. This prevents us from reclaiming the memory early but
44    // also avoids a potential segmentation fault when writing large files.
45    llvm::raw_fd_ostream *                                  mIROutputStream;
46    llvm::raw_fd_ostream *                                  mASMOutputStream;
47};
48
49#endif // CPUDRIVER_H
Note: See TracBrowser for help on using the repository browser.