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

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

Merged PabloFunction? and PabloKernel? classes. Updated projects where necessary.

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//Pablo Expressions
11#include <string>
12#include <vector>
13#include <unordered_map>
14#include <pablo/carry_manager.h>
15#include <pablo/pablo_kernel.h>
16#include <llvm/ADT/Twine.h>
17#include <llvm/IR/IRBuilder.h>
18#include <IDISA/idisa_builder.h>
19#include <kernels/kernel.h>
20#include <boost/container/flat_set.hpp>
21
22namespace llvm {
23    class Value;
24    class Module;
25    class ExecutionEngine;
26    class VectorType;
27    class PointerType;
28    class Constant;
29    class FunctionType;
30    class Function;
31    class BasicBlock;
32}
33
34namespace pablo {
35
36class PabloAST;
37class PabloBlock;
38class PabloFunction;
39class String;
40class Var;
41class Statement;
42class StatementList;
43class If;
44class While;
45
46class PabloCompiler {
47    using IntSet = boost::container::flat_set<unsigned>;
48    using MarkerMap = std::unordered_map<const PabloAST *, Value *>;
49public:
50    PabloCompiler(PabloKernel * kernel);
51    Type * initializeKernelData();
52    void compile(Value * const self, Function * doBlockFunction);
53
54private:
55
56    void verifyParameter(const Var * var, const Value * param);
57
58    void Examine();
59    void Examine(const PabloBlock * const block);
60
61    void compileBlock(const PabloBlock * const block);
62    void compileStatement(const Statement * stmt);
63    void compileIf(const If * ifStmt);
64    void compileWhile(const While * whileStmt);
65    Value * compileExpression(const PabloAST * expr, const bool ensureLoaded = true) const;
66    void GenerateKernel(PabloFunction * const function);
67
68    MarkerMap                           mMarkerMap;
69    IntSet                              mInputStreamOffset;
70    IDISA::IDISA_Builder *              iBuilder;
71    Type* const                         mBitBlockType;
72
73    std::unique_ptr<CarryManager>       mCarryManager;
74
75    PabloKernel * const                 mKernel;
76    Value *                             mSelf;
77
78    unsigned                            mWhileDepth;
79    unsigned                            mIfDepth;
80
81    llvm::Function *                    mFunction;
82
83    unsigned                            mMaxWhileDepth;
84};
85
86}
87
88#endif // PABLO_COMPILER_H
Note: See TracBrowser for help on using the repository browser.