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

Last change on this file since 5792 was 5620, checked in by nmedfort, 23 months ago

Bug fixes for multigrep mode. Optional PabloKernel? branch hit counter added. Minor optimizations.

File size: 2.3 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 <vector>
12#include <memory>
13namespace IDISA { class IDISA_Builder; }
14namespace llvm { class BasicBlock; }
15namespace llvm { class Function; }
16namespace llvm { class Value; }
17namespace pablo { class CarryManager; }
18namespace pablo { class If; }
19namespace pablo { class PabloAST; }
20namespace pablo { class PabloBlock; }
21namespace pablo { class PabloKernel; }
22namespace pablo { class Statement; }
23namespace pablo { class While; }
24namespace kernel { class KernelBuilder; }
25
26namespace pablo {
27
28class PabloCompiler {
29
30    friend class PabloKernel;
31
32    using TranslationMap = std::unordered_map<const PabloAST *, llvm::Value *>;
33
34public:
35
36    PabloCompiler(PabloKernel * kernel);
37
38    ~PabloCompiler();
39
40protected:
41
42    void initializeKernelData(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
43
44    void compile(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
45
46    void releaseKernelData(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
47
48private:
49
50    void examineBlock(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const PabloBlock * const block);
51
52    void compileBlock(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const PabloBlock * const block);
53
54    void compileStatement(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const Statement * stmt);
55
56    void compileIf(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const If * ifStmt);
57
58    void compileWhile(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const While * whileStmt);
59
60    void addBranchCounter(const std::unique_ptr<kernel::KernelBuilder> & iBuilder);
61
62    llvm::Value * compileExpression(const std::unique_ptr<kernel::KernelBuilder> & iBuilder, const PabloAST * expr, const bool ensureLoaded = true) const;
63
64private:
65
66    PabloKernel * const             mKernel;
67    CarryManager * const            mCarryManager;
68    TranslationMap                  mMarker;
69    TranslationMap                  mAccumulator;
70    unsigned                        mBranchCount;
71    std::vector<llvm::BasicBlock *> mBasicBlock;
72};
73
74}
75
76#endif // PABLO_COMPILER_H
Note: See TracBrowser for help on using the repository browser.