source: icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.h @ 5454

Last change on this file since 5454 was 5440, checked in by nmedfort, 2 years ago

Large refactoring step. Removed IR generation code from Kernel (formally KernelBuilder?) and moved it into the new KernelBuilder? class.

File size: 2.0 KB
Line 
1/*
2 *  Copyright (c) 2016 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef PABLO_COMPILER_H
8#define PABLO_COMPILER_H
9
10#include <unordered_map>
11#include <memory>
12namespace IDISA { class IDISA_Builder; }
13namespace llvm { class Function; }
14namespace llvm { class Value; }
15namespace pablo { class CarryManager; }
16namespace pablo { class If; }
17namespace pablo { class PabloAST; }
18namespace pablo { class PabloBlock; }
19namespace pablo { class PabloKernel; }
20namespace pablo { class Statement; }
21namespace pablo { class While; }
22namespace kernel { class KernelBuilder; }
23
24namespace pablo {
25
26class PabloCompiler {
27
28    friend class PabloKernel;
29
30    using TranslationMap = std::unordered_map<const PabloAST *, llvm::Value *>;
31
32public:
33
34    PabloCompiler(PabloKernel * kernel);
35
36    ~PabloCompiler();
37
38protected:
39
40    void initializeKernelData(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder);
41
42    void compile(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder);
43
44private:
45
46    void examineBlock(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const PabloBlock * const block);
47
48    void compileBlock(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const PabloBlock * const block);
49
50    void compileStatement(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const Statement * stmt);
51
52    void compileIf(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const If * ifStmt);
53
54    void compileWhile(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const While * whileStmt);
55
56    llvm::Value * compileExpression(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const PabloAST * expr, const bool ensureLoaded = true) const;
57
58private:
59
60    PabloKernel * const             mKernel;
61    CarryManager * const            mCarryManager;
62    TranslationMap                  mMarker;
63    TranslationMap                  mAccumulator;
64
65};
66
67}
68
69#endif // PABLO_COMPILER_H
Note: See TracBrowser for help on using the repository browser.