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

Last change on this file since 5000 was 5000, checked in by nmedfort, 3 years ago

Redesigned buffer system to allow the pipeline to control selection of the current input and output streams; DoBlock? functions containing lookahead now take multiple input stream arguments. Selection and passing occurs automatically. Some work on Symbol Table.

File size: 2.4 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 <llvm/ADT/Twine.h>
16#include <llvm/IR/IRBuilder.h>
17#include <IDISA/idisa_builder.h>
18#include <kernels/kernel.h>
19#include <boost/container/flat_set.hpp>
20
21namespace llvm {
22    class Value;
23    class Module;
24    class ExecutionEngine;
25    class VectorType;
26    class PointerType;
27    class Constant;
28    class FunctionType;
29    class Function;
30    class BasicBlock;
31}
32
33namespace pablo {
34
35class PabloAST;
36class PabloBlock;
37class PabloFunction;
38class String;
39class Var;
40class Statement;
41class StatementList;
42class If;
43class While;
44
45class PabloCompiler {
46    using IntSet = boost::container::flat_set<unsigned>;
47    using MarkerMap = std::unordered_map<const PabloAST *, Value *>;
48    using LookaheadOffsetMap = std::unordered_map<const PabloAST *, IntSet>;
49public:
50    PabloCompiler(Module * m, IDISA::IDISA_Builder * b);
51
52    llvm::Function * compile(PabloFunction * function);
53    void setKernel(kernel::KernelBuilder * kBuilder);
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    CarryManager *                      mCarryManager;
74
75    const PabloFunction *               mPabloFunction;
76    const PabloBlock *                  mPabloBlock;
77
78    kernel::KernelBuilder *             mKernelBuilder;
79
80    unsigned                            mWhileDepth;
81    unsigned                            mIfDepth;
82
83    llvm::Function *                    mFunction;
84
85    unsigned                            mMaxWhileDepth;
86};
87
88}
89
90#endif // PABLO_COMPILER_H
Note: See TracBrowser for help on using the repository browser.