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

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

Initial attempt to improve debugging capabilities with compilation stack traces on error.

File size: 2.1 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
44    void releaseKernelData(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder);
45
46private:
47
48    void examineBlock(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const PabloBlock * const block);
49
50    void compileBlock(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const PabloBlock * const block);
51
52    void compileStatement(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const Statement * stmt);
53
54    void compileIf(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const If * ifStmt);
55
56    void compileWhile(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const While * whileStmt);
57
58    llvm::Value * compileExpression(const std::unique_ptr<kernel::KernelBuilder> &  iBuilder, const PabloAST * expr, const bool ensureLoaded = true) const;
59
60private:
61
62    PabloKernel * const             mKernel;
63    CarryManager * const            mCarryManager;
64    TranslationMap                  mMarker;
65    TranslationMap                  mAccumulator;
66
67};
68
69}
70
71#endif // PABLO_COMPILER_H
Note: See TracBrowser for help on using the repository browser.