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

Last change on this file since 4602 was 4602, checked in by nmedfort, 4 years ago

Fixed PabloBuilder? and intergrated it into CC Compiler.

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