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

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

Initial work on adding types to PabloAST and mutable Var objects.

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 <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 * k, PabloFunction * function);
51    Type * initializeKernelData();
52    void compile(Function * doBlockFunction);
53
54private:
55
56    void verifyParameter(const Var * var, const Value * param);
57
58    void Examine(const PabloFunction * const function);
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    PabloFunction *  const              mPabloFunction;
76
77    PabloKernel *                       mKernelBuilder;
78    Value *                             mSelf;
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.