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

Last change on this file since 5082 was 5063, checked in by cameron, 3 years ago

New kernel infrastructure

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//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 *>;
49    using LookaheadOffsetMap = std::unordered_map<const PabloAST *, IntSet>;
50public:
51    PabloCompiler(IDISA::IDISA_Builder * b, PabloKernel * k, PabloFunction * function);
52    Type * initializeCarryData();
53    void compile(Function * doBlockFunction);
54
55private:
56
57    void Examine(const PabloFunction * const function);
58    void Examine(const PabloBlock * const block, LookaheadOffsetMap & offsetMap);
59
60    void compileBlock(const PabloBlock * const block);
61    void compileStatement(const Statement * stmt);
62    void compileIf(const If * ifStmt);
63    void compileWhile(const While * whileStmt);
64    Value * compileExpression(const PabloAST * expr);
65    void GenerateKernel(PabloFunction * const function);
66
67    MarkerMap                           mMarkerMap;
68    IntSet                              mInputStreamOffset;
69    Module *                            mMod;
70    IDISA::IDISA_Builder *              iBuilder;
71    Type* const                         mBitBlockType;
72
73    std::unique_ptr<CarryManager>       mCarryManager;
74
75    PabloFunction *  const             mPabloFunction;
76    const PabloBlock *                  mPabloBlock;
77
78    PabloKernel *                       mKernelBuilder;
79    Value *                             mSelf;
80
81    unsigned                            mWhileDepth;
82    unsigned                            mIfDepth;
83
84    llvm::Function *                    mFunction;
85
86    unsigned                            mMaxWhileDepth;
87};
88
89}
90
91#endif // PABLO_COMPILER_H
Note: See TracBrowser for help on using the repository browser.