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

Last change on this file was 6184, checked in by nmedfort, 7 months ago

Initial version of PipelineKernel? + revised StreamSet? model.

File size: 2.4 KB
RevLine 
[3850]1/*
[4951]2 *  Copyright (c) 2016 International Characters.
[3850]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
[4237]7#ifndef PABLO_COMPILER_H
8#define PABLO_COMPILER_H
9
[4510]10#include <unordered_map>
[5620]11#include <vector>
[5435]12#include <memory>
[5267]13namespace IDISA { class IDISA_Builder; }
[5620]14namespace llvm { class BasicBlock; }
[5267]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; }
[5828]23namespace pablo { class Var; }
[5267]24namespace pablo { class While; }
[5440]25namespace kernel { class KernelBuilder; }
[4237]26
[4416]27namespace pablo {
28
[4237]29class PabloCompiler {
[5227]30
[5340]31    friend class PabloKernel;
32
[5283]33    using TranslationMap = std::unordered_map<const PabloAST *, llvm::Value *>;
34
[4237]35public:
[5340]36
[5217]37    PabloCompiler(PabloKernel * kernel);
[5340]38
[5227]39    ~PabloCompiler();
[5340]40
41protected:
42
[5828]43    void initializeKernelData(const std::unique_ptr<kernel::KernelBuilder> & b);
[5340]44
[5828]45    void compile(const std::unique_ptr<kernel::KernelBuilder> & b);
[4959]46
[5828]47    void releaseKernelData(const std::unique_ptr<kernel::KernelBuilder> & b);
[5486]48
[5828]49    void clearCarryData(const std::unique_ptr<kernel::KernelBuilder> & b);
50
[4237]51private:
[4959]52
[5828]53    void examineBlock(const std::unique_ptr<kernel::KernelBuilder> & b, const PabloBlock * const block);
[5267]54
[5828]55    void compileBlock(const std::unique_ptr<kernel::KernelBuilder> & b, const PabloBlock * const block);
[5267]56
[5828]57    void compileStatement(const std::unique_ptr<kernel::KernelBuilder> & b, const Statement * stmt);
[5267]58
[5828]59    void compileIf(const std::unique_ptr<kernel::KernelBuilder> & b, const If * ifStmt);
[5267]60
[5828]61    void compileWhile(const std::unique_ptr<kernel::KernelBuilder> & b, const While * whileStmt);
[5227]62
[5828]63    void addBranchCounter(const std::unique_ptr<kernel::KernelBuilder> & b);
[4237]64
[5828]65    llvm::Value * getPointerToVar(const std::unique_ptr<kernel::KernelBuilder> & b, const Var * var, llvm::Value * index1, llvm::Value * index2 = nullptr);
[5620]66
[5828]67    llvm::Value * compileExpression(const std::unique_ptr<kernel::KernelBuilder> & b, const PabloAST * expr, const bool ensureLoaded = true);
68
[5227]69private:
[4663]70
[5283]71    PabloKernel * const             mKernel;
[5992]72    std::unique_ptr<CarryManager> const mCarryManager;
[5283]73    TranslationMap                  mMarker;
[5620]74    unsigned                        mBranchCount;
75    std::vector<llvm::BasicBlock *> mBasicBlock;
[4237]76};
77
78}
79
[4951]80#endif // PABLO_COMPILER_H
Note: See TracBrowser for help on using the repository browser.