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

Last change on this file since 5828 was 5828, checked in by nmedfort, 12 months ago

Pablo support for byte comparisions; LineFeed? kernel processes byte streams directly. Some clean up of PabloBuilder? functionality.

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