source: icGREP/icgrep-devel/icgrep/pablo/builder.hpp @ 4443

Last change on this file since 4443 was 4443, checked in by nmedfort, 5 years ago

Temporary check in.

File size: 2.3 KB
RevLine 
[4432]1#ifndef BUILDER_HPP
2#define BUILDER_HPP
3
4#include "codegenstate.h"
5#include "expression_map.hpp"
6
7namespace pablo {
8
[4443]9class PabloBuilder {
[4432]10public:
11
[4443]12    inline static PabloBlock & Create() {
13        return *(new PabloBlock());
14    }
15
16    inline static PabloBlock & Create(PabloBlock & predecessor) {
17        return *(new PabloBlock(&predecessor));
18    }
19
20
[4432]21    inline Zeroes * createZeroes() const {
22        return mPb->createZeroes();
23    }
24
25    inline Ones * createOnes() const {
26        return mPb->createOnes();
27    }
28
[4443]29    Var * createVar(const std::string name) {
30        return createVar(mPb->getName(name));
31    }
32
33    Var * createVar(String * name);
34
35    PabloAST * createVar(const PabloAST * const) {
36        throw std::runtime_error("Var objects should only refer to external Vars (i.e., input basis bit streams). Use Assign objects directly.");
37    }
38
[4432]39    inline Call * createCall(const std::string name) {
40        return createCall(mPb->getName(name));
41    }
42
43    Call * createCall(String * name);
44
45    Assign * createAssign(const std::string prefix, PabloAST * expr, const int outputIndex = -1);
46
[4443]47    inline PabloAST * createAdvance(PabloAST * expr, const int shiftAmount) {
48        if (shiftAmount == 0) {
49            return expr;
50        }
51        return createAdvance(expr, mPb->getInteger(shiftAmount));
[4432]52    }
53
[4443]54    PabloAST * createAdvance(PabloAST * expr, PabloAST * shiftAmount);
[4432]55
56    Next * createNext(Assign * assign, PabloAST * expr);
57
58    PabloAST * createAnd(PabloAST * expr1, PabloAST * expr2);
59
60    PabloAST * createNot(PabloAST * expr);
61
62    PabloAST * createOr(PabloAST * expr1, PabloAST * expr2);
63
64    PabloAST * createXor(PabloAST * expr1, PabloAST * expr2);
65
66    PabloAST * createMatchStar(PabloAST * marker, PabloAST * charclass);
67
68    PabloAST * createScanThru(PabloAST * from, PabloAST * thru);
69
70    PabloAST * createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr);
71
[4443]72    inline If * createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body) {
73        mPb->createIf(condition, std::move(definedVars), body);
74    }
[4432]75
[4443]76    inline While * createWhile(PabloAST * condition, PabloBlock & body) {
77        mPb->createWhile(condition, body);
78    }
[4432]79
80private:
81
[4443]82    PabloBlock *        mPb;
83    ExpressionTable     mExprTable;
[4432]84};
85
86
87}
88
89
90#endif // BUILDER_HPP
Note: See TracBrowser for help on using the repository browser.