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