Changeset 4438
- Timestamp:
- Jan 23, 2015, 1:52:33 PM (4 years ago)
- Location:
- icGREP/icgrep-devel/icgrep
- Files:
-
- 5 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
icGREP/icgrep-devel/icgrep/CMakeLists.txt
r4436 r4438 53 53 find_package(Boost) 54 54 55 add_library(PabloADT pablo/p e_and.cpp pablo/pe_not.cpp pablo/pe_or.cpp pablo/pabloAST.cpp pablo/pe_sel.cpp pablo/pe_xor.cpp pablo/ps_assign.cpp pablo/ps_if.cpp pablo/ps_while.cpp pablo/codegenstate.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_compiler.cpp pablo/optimizers/pablo_simplifier.cpp)55 add_library(PabloADT pablo/pabloAST.cpp pablo/ps_assign.cpp pablo/ps_if.cpp pablo/ps_while.cpp pablo/codegenstate.cpp pablo/symbol_generator.cpp pablo/printer_pablos.cpp pablo/pablo_compiler.cpp pablo/optimizers/pablo_simplifier.cpp) 56 56 add_library(RegExpADT re/re_re.cpp re/re_cc.cpp re/re_parser.cpp re/re_rep.cpp re/parsefailure.cpp re/re_nullable.cpp re/re_simplifier.cpp re/re_compiler.cpp re/printer_re.cpp re/re_diff.cpp re/re_intersect.cpp re/re_analysis.cpp) 57 57 add_library(CCADT cc/cc_namemap.cpp cc/cc_compiler.cpp utf8_encoder.cpp UCD/CaseFolding_txt.cpp) -
icGREP/icgrep-devel/icgrep/compiler.cpp
r4431 r4438 130 130 } 131 131 132 RE_Compiler re_compiler(main , nameMap);132 RE_Compiler re_compiler(main); 133 133 re_compiler.initializeRequiredStreams(cc_compiler); 134 134 re_compiler.finalizeMatchResult(re_compiler.compile(re_ast)); -
icGREP/icgrep-devel/icgrep/pablo/codegenstate.cpp
r4437 r4438 9 9 namespace pablo { 10 10 11 inline PabloAST * PabloBlock::renameNonNamedNode(PabloAST * expr, const std::string && prefix) { 12 if (Statement * stmt = dyn_cast<Statement>(expr)) { 13 if (stmt->getName()->isGenerated()) { 14 stmt->setName(makeName(prefix, false)); 15 } 16 } 17 return expr; 18 } 19 11 20 /// UNARY CREATE FUNCTIONS 12 21 … … 19 28 return expr; 20 29 } 21 return insertAtInsertionPoint(new Advance(expr, shiftAmount, mSymbolGenerator, this)); 30 return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName("advance"), this)); 31 } 32 33 PabloAST * PabloBlock::createAdvance(PabloAST * expr, PabloAST * shiftAmount, const std::string prefix) { 34 if (isa<Zeroes>(expr) || cast<Integer>(shiftAmount)->value() == 0) { 35 return expr; 36 } 37 return insertAtInsertionPoint(new Advance(expr, shiftAmount, makeName(prefix, false), this)); 22 38 } 23 39 … … 25 41 if (isa<Zeroes>(expr) || shiftAmount == 0) { 26 42 return expr; 43 } 44 return insertAtInsertionPoint(new Advance(expr, mSymbolGenerator->getInteger(shiftAmount), makeName("advance"), this)); 45 } 46 47 PabloAST * PabloBlock::createAdvance(PabloAST * expr, const int shiftAmount, const std::string prefix) { 48 if (isa<Zeroes>(expr) || shiftAmount == 0) { 49 return renameNonNamedNode(expr, std::move(prefix)); 27 50 } 28 return insertAtInsertionPoint(new Advance(expr, mSymbolGenerator->getInteger(shiftAmount), m SymbolGenerator, this));51 return insertAtInsertionPoint(new Advance(expr, mSymbolGenerator->getInteger(shiftAmount), makeName(prefix, false), this)); 29 52 } 30 53 … … 45 68 return not1->getExpr(); 46 69 } 47 return insertAtInsertionPoint(new Not(expr, this)); 70 return insertAtInsertionPoint(new Not(expr, makeName("not"), this)); 71 } 72 73 PabloAST * PabloBlock::createNot(PabloAST * expr, const std::string prefix) { 74 assert (expr); 75 if (isa<Ones>(expr)) { 76 return createZeroes(); 77 } 78 else if (isa<Zeroes>(expr)){ 79 return createOnes(); 80 } 81 else if (Not * not1 = dyn_cast<Not>(expr)) { 82 return renameNonNamedNode(not1->getExpr(), std::move(prefix)); 83 } 84 return insertAtInsertionPoint(new Not(expr, makeName(prefix, false), this)); 48 85 } 49 86 … … 65 102 return marker; 66 103 } 67 return insertAtInsertionPoint(new MatchStar(marker, charclass, mSymbolGenerator, this)); 104 return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName("matchstar"), this)); 105 } 106 107 PabloAST * PabloBlock::createMatchStar(PabloAST * marker, PabloAST * charclass, const std::string prefix) { 108 assert (marker && charclass); 109 if (isa<Zeroes>(marker) || isa<Zeroes>(charclass)) { 110 return renameNonNamedNode(marker, std::move(prefix)); 111 } 112 return insertAtInsertionPoint(new MatchStar(marker, charclass, makeName(prefix, false), this)); 68 113 } 69 114 … … 73 118 return from; 74 119 } 75 return insertAtInsertionPoint(new ScanThru(from, thru, mSymbolGenerator, this)); 120 return insertAtInsertionPoint(new ScanThru(from, thru, makeName("scanthru"), this)); 121 } 122 123 PabloAST * PabloBlock::createScanThru(PabloAST * from, PabloAST * thru, const std::string prefix) { 124 assert (from && thru); 125 if (isa<Zeroes>(from) || isa<Zeroes>(thru)) { 126 return renameNonNamedNode(from, std::move(prefix)); 127 } 128 return insertAtInsertionPoint(new ScanThru(from, thru, makeName(prefix, false), this)); 76 129 } 77 130 … … 81 134 return expr2; 82 135 } 83 else if (isa<Zeroes>(expr1) || isa<Ones>(expr2)){ 84 return expr1; 85 } 86 else if (equals(expr1, expr2)) { 136 else if (isa<Zeroes>(expr1) || isa<Ones>(expr2) || equals(expr1, expr2)){ 87 137 return expr1; 88 138 } … … 103 153 std::swap(expr1, expr2); 104 154 } 105 return insertAtInsertionPoint(new And(expr1, expr2, this)); 106 } 107 155 return insertAtInsertionPoint(new And(expr1, expr2, makeName("and"), this)); 156 } 157 158 159 PabloAST * PabloBlock::createAnd(PabloAST * expr1, PabloAST * expr2, const std::string prefix) { 160 assert (expr1 && expr2); 161 if (isa<Zeroes>(expr2) || isa<Ones>(expr1)) { 162 return renameNonNamedNode(expr2, std::move(prefix)); 163 } 164 else if (isa<Zeroes>(expr1) || isa<Ones>(expr2) || equals(expr1, expr2)){ 165 return renameNonNamedNode(expr1, std::move(prefix)); 166 } 167 else if (Not * not1 = dyn_cast<Not>(expr1)) { 168 if (Not * not2 = dyn_cast<Not>(expr2)) { 169 return createNot(createOr(not1->getExpr(), not2->getExpr()), prefix); 170 } 171 else if (equals(not1->getExpr(), expr2)) { 172 return createZeroes(); 173 } 174 } 175 else if (Not * not2 = dyn_cast<Not>(expr2)) { 176 if (equals(expr1, not2->getExpr())) { 177 return createZeroes(); 178 } 179 } 180 if (isa<Not>(expr1)) { 181 std::swap(expr1, expr2); 182 } 183 return insertAtInsertionPoint(new And(expr1, expr2, makeName(prefix, false), this)); 184 } 108 185 109 186 PabloAST * PabloBlock::createOr(PabloAST * expr1, PabloAST * expr2) { 110 187 assert (expr1 && expr2); 111 if (isa<Zeroes>(expr2) || isa<Ones>(expr1)) { 112 return expr1; 113 } 114 else if (isa<Zeroes>(expr1) || isa<Ones>(expr2)){ 188 if (isa<Zeroes>(expr1) || isa<Ones>(expr2)){ 115 189 return expr2; 116 190 } 117 else if (equals(expr1, expr2)) {191 if (isa<Zeroes>(expr2) || isa<Ones>(expr1) || equals(expr1, expr2)) { 118 192 return expr1; 119 193 } … … 151 225 } 152 226 } 153 return insertAtInsertionPoint(new Or(expr1, expr2, this)); 227 return insertAtInsertionPoint(new Or(expr1, expr2, makeName("or"), this)); 228 } 229 230 PabloAST * PabloBlock::createOr(PabloAST * expr1, PabloAST * expr2, const std::string prefix) { 231 assert (expr1 && expr2); 232 if (isa<Zeroes>(expr1) || isa<Ones>(expr2)){ 233 return renameNonNamedNode(expr2, std::move(prefix)); 234 } 235 if (isa<Zeroes>(expr2) || isa<Ones>(expr1) || equals(expr1, expr2)) { 236 return renameNonNamedNode(expr1, std::move(prefix)); 237 } 238 else if (Not * not1 = dyn_cast<Not>(expr1)) { 239 // ¬aâšb = ¬¬(¬aâšb) = ¬(a ⧠¬b) 240 return createNot(createAnd(not1->getExpr(), createNot(expr2)), prefix); 241 } 242 else if (Not * not2 = dyn_cast<Not>(expr2)) { 243 // aâšÂ¬b = ¬¬(¬bâša) = ¬(b ⧠¬a) 244 return createNot(createAnd(not2->getExpr(), createNot(expr1)), prefix); 245 } 246 else if (And * and_expr1 = dyn_cast<And>(expr1)) { 247 if (And * and_expr2 = dyn_cast<And>(expr2)) { 248 PabloAST * const expr1a = and_expr1->getExpr1(); 249 PabloAST * const expr1b = and_expr1->getExpr2(); 250 PabloAST * const expr2a = and_expr2->getExpr1(); 251 PabloAST * const expr2b = and_expr2->getExpr2(); 252 //These optimizations factor out common components that can occur when sets are formed by union 253 //(e.g., union of [a-z] and [A-Z]. 254 if (equals(expr1a, expr2a)) { 255 return createAnd(expr1a, createOr(expr1b, expr2b), prefix); 256 } 257 else if (equals(expr1b, expr2b)) { 258 return createAnd(expr1b, createOr(expr1a, expr2a), prefix); 259 } 260 else if (equals(expr1a, expr2b)) { 261 return createAnd(expr1a, createOr(expr1b, expr2a), prefix); 262 } 263 else if (equals(expr1b, expr2a)) { 264 return createAnd(expr1b, createOr(expr1a, expr2b), prefix); 265 } 266 } 267 } 268 return insertAtInsertionPoint(new Or(expr1, expr2, makeName(prefix, false), this)); 154 269 } 155 270 … … 173 288 } 174 289 } 175 return insertAtInsertionPoint(new Xor(expr1, expr2, this)); 290 return insertAtInsertionPoint(new Xor(expr1, expr2, makeName("xor"), this)); 291 } 292 293 PabloAST * PabloBlock::createXor(PabloAST * expr1, PabloAST * expr2, const std::string prefix) { 294 assert (expr1 && expr2); 295 if (isa<Ones>(expr1)) { 296 return createNot(expr2, prefix); 297 } 298 else if (isa<Zeroes>(expr1)){ 299 return expr2; 300 } 301 else if (isa<Ones>(expr2)) { 302 return createNot(expr1, prefix); 303 } 304 else if (isa<Zeroes>(expr2)){ 305 return expr1; 306 } 307 else if (Not * not1 = dyn_cast<Not>(expr1)) { 308 if (Not * not2 = dyn_cast<Not>(expr2)) { 309 return createXor(not1->getExpr(), not2->getExpr(), prefix); 310 } 311 } 312 return insertAtInsertionPoint(new Xor(expr1, expr2, makeName(prefix, false), this)); 176 313 } 177 314 … … 208 345 return createXor(condition, falseExpr); 209 346 } 210 return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, this)); 347 return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName("sel"), this)); 348 } 349 350 PabloAST * PabloBlock::createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr, const std::string prefix) { 351 assert (condition && trueExpr && falseExpr); 352 353 if (isa<Zeroes>(condition)){ 354 return renameNonNamedNode(falseExpr, std::move(prefix)); 355 } 356 else if (isa<Ones>(condition) || equals(trueExpr, falseExpr)) { 357 return renameNonNamedNode(trueExpr, std::move(prefix)); 358 } 359 else if (isa<Ones>(trueExpr)) { 360 return createOr(condition, falseExpr, prefix); 361 } 362 else if (isa<Zeroes>(trueExpr)){ 363 return createAnd(createNot(condition), falseExpr, prefix); 364 } 365 else if (isa<Ones>(falseExpr)) { 366 return createOr(createNot(condition), trueExpr, prefix); 367 } 368 else if (isa<Zeroes>(falseExpr)){ 369 return createAnd(condition, trueExpr, prefix); 370 } 371 else if (isa<Not>(trueExpr) && equals(cast<Not>(trueExpr)->getExpr(), falseExpr)) { 372 return createXor(condition, falseExpr, prefix); 373 } 374 else if (isa<Not>(falseExpr) && equals(trueExpr, cast<Not>(falseExpr)->getExpr())){ 375 return createXor(condition, falseExpr, prefix); 376 } 377 return insertAtInsertionPoint(new Sel(condition, trueExpr, falseExpr, makeName(prefix, false), this)); 211 378 } 212 379 -
icGREP/icgrep-devel/icgrep/pablo/codegenstate.h
r4433 r4438 82 82 PabloAST * createAdvance(PabloAST * expr, PabloAST * shiftAmount); 83 83 84 PabloAST * createAdvance(PabloAST * expr, const int shiftAmount, const std::string prefix); 85 86 PabloAST * createAdvance(PabloAST * expr, PabloAST * shiftAmount, const std::string prefix); 87 84 88 inline Zeroes * createZeroes() const { 85 89 return mZeroes; … … 112 116 PabloAST * createAnd(PabloAST * expr1, PabloAST * expr2); 113 117 118 PabloAST * createAnd(PabloAST * expr1, PabloAST * expr2, const std::string prefix); 119 114 120 PabloAST * createNot(PabloAST * expr); 121 122 PabloAST * createNot(PabloAST * expr, const std::string prefix); 115 123 116 124 PabloAST * createOr(PabloAST * expr1, PabloAST * expr2); 117 125 126 PabloAST * createOr(PabloAST * expr1, PabloAST * expr2, const std::string prefix); 127 118 128 PabloAST * createXor(PabloAST * expr1, PabloAST * expr2); 129 130 PabloAST * createXor(PabloAST * expr1, PabloAST * expr2, const std::string prefix); 119 131 120 132 PabloAST * createMatchStar(PabloAST * marker, PabloAST * charclass); 121 133 134 PabloAST * createMatchStar(PabloAST * marker, PabloAST * charclass, const std::string prefix); 135 122 136 PabloAST * createScanThru(PabloAST * from, PabloAST * thru); 123 137 138 PabloAST * createScanThru(PabloAST * from, PabloAST * thru, const std::string prefix); 139 124 140 PabloAST * createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr); 141 142 PabloAST * createSel(PabloAST * condition, PabloAST * trueExpr, PabloAST * falseExpr, const std::string prefix); 125 143 126 144 If * createIf(PabloAST * condition, std::vector<Assign *> && definedVars, PabloBlock & body); … … 151 169 PabloBlock(PabloBlock * predecessor); 152 170 171 PabloAST * renameNonNamedNode(PabloAST * expr, const std::string && prefix); 172 153 173 template<typename Type> 154 174 inline Type * insertAtInsertionPoint(Type * expr) { -
icGREP/icgrep-devel/icgrep/pablo/pabloAST.h
r4433 r4438 20 20 21 21 class PabloBlock; 22 class String; 22 23 23 24 class PabloAST { -
icGREP/icgrep-devel/icgrep/pablo/pablo_compiler.cpp
r4433 r4438 58 58 #include <llvm/Support/MemoryBuffer.h> 59 59 #include <llvm/IR/IRBuilder.h> 60 61 60 #include "llvm/Support/CommandLine.h" 62 61 #include <iostream> 63 62 64 63 cl::OptionCategory eIRDumpOptions("LLVM IR Dump Options", "These options control dumping of LLVM IR."); -
icGREP/icgrep-devel/icgrep/pablo/pe_advance.h
r4432 r4438 32 32 } 33 33 protected: 34 Advance(PabloAST * expr, PabloAST * shiftAmount, S ymbolGenerator * sg, PabloBlock * parent)35 : Statement(ClassTypeId::Advance, {expr, shiftAmount}, sg->make("advance"), parent)34 Advance(PabloAST * expr, PabloAST * shiftAmount, String * name, PabloBlock * parent) 35 : Statement(ClassTypeId::Advance, {expr, shiftAmount}, name, parent) 36 36 { 37 37 assert(isa<Integer>(shiftAmount)); -
icGREP/icgrep-devel/icgrep/pablo/pe_and.h
r4432 r4438 9 9 10 10 #include <pablo/pabloAST.h> 11 #include <array>12 11 13 12 namespace pablo { 14 15 class PabloBlock;16 13 17 14 class And : public Statement { … … 33 30 } 34 31 protected: 35 And(PabloAST * expr1, PabloAST * expr2, PabloBlock * parent); 32 And(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent) 33 : Statement(ClassTypeId::And, {expr1, expr2}, name, parent) 34 { 35 36 } 36 37 }; 37 38 -
icGREP/icgrep-devel/icgrep/pablo/pe_call.h
r4432 r4438 4 4 #include <pablo/pabloAST.h> 5 5 #include <pablo/pe_string.h> 6 #include <iostream>7 6 8 7 namespace pablo { -
icGREP/icgrep-devel/icgrep/pablo/pe_matchstar.h
r4432 r4438 8 8 #define PE_MATCHSTAR_H 9 9 10 #include "pabloAST.h" 11 #include <pablo/symbol_generator.h> 12 #include <array> 10 #include <pablo/pabloAST.h> 13 11 14 12 namespace pablo { … … 31 29 virtual ~MatchStar() {} 32 30 protected: 33 MatchStar(PabloAST * marker, PabloAST * cc, S ymbolGenerator * sg, PabloBlock * parent)34 : Statement(ClassTypeId::MatchStar, {marker, cc}, sg->make("matchstar"), parent)31 MatchStar(PabloAST * marker, PabloAST * cc, String * name, PabloBlock * parent) 32 : Statement(ClassTypeId::MatchStar, {marker, cc}, name, parent) 35 33 { 36 34 -
icGREP/icgrep-devel/icgrep/pablo/pe_not.h
r4432 r4438 11 11 12 12 namespace pablo { 13 14 class PabloBlock;15 13 16 14 class Not : public Statement { … … 29 27 } 30 28 protected: 31 Not(PabloAST * expr, PabloBlock * parent); 29 Not(PabloAST * expr, String * name, PabloBlock * parent) 30 : Statement(ClassTypeId::Not, {expr}, name, parent) 31 { 32 33 } 32 34 }; 33 35 -
icGREP/icgrep-devel/icgrep/pablo/pe_or.h
r4419 r4438 9 9 10 10 #include <pablo/pabloAST.h> 11 #include <array>12 11 13 12 namespace pablo { 14 15 class PabloBlock;16 13 17 14 class Or : public Statement { … … 33 30 } 34 31 protected: 35 Or(PabloAST * expr1, PabloAST * expr2, PabloBlock * parent); 32 Or(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent) 33 : Statement(ClassTypeId::Or, {expr1, expr2}, name, parent) 34 { 35 36 } 36 37 }; 37 38 -
icGREP/icgrep-devel/icgrep/pablo/pe_scanthru.h
r4432 r4438 9 9 10 10 #include <pablo/pabloAST.h> 11 #include <pablo/symbol_generator.h>12 #include <array>13 11 14 12 namespace pablo { … … 32 30 } 33 31 protected: 34 ScanThru(PabloAST * from, PabloAST * thru, S ymbolGenerator * sg, PabloBlock * parent)35 : Statement(ClassTypeId::ScanThru, {from, thru}, sg->make("scanthru"), parent)32 ScanThru(PabloAST * from, PabloAST * thru, String * name, PabloBlock * parent) 33 : Statement(ClassTypeId::ScanThru, {from, thru}, name, parent) 36 34 { 37 35 -
icGREP/icgrep-devel/icgrep/pablo/pe_sel.h
r4432 r4438 9 9 10 10 #include <pablo/pabloAST.h> 11 #include <array>12 11 13 12 namespace pablo { 14 15 class PabloBlock;16 13 17 14 class Sel : public Statement { … … 36 33 } 37 34 protected: 38 Sel(PabloAST* if_expr, PabloAST* t_expr, PabloAST* f_expr, PabloBlock * parent); 35 Sel(PabloAST* if_expr, PabloAST* t_expr, PabloAST* f_expr, String * name, PabloBlock * parent) 36 : Statement(ClassTypeId::Sel, {if_expr, t_expr, f_expr}, name, parent) 37 { 38 39 } 39 40 }; 40 41 -
icGREP/icgrep-devel/icgrep/pablo/pe_xor.h
r4432 r4438 12 12 13 13 namespace pablo { 14 15 class PabloBlock;16 14 17 15 class Xor : public Statement { … … 33 31 } 34 32 protected: 35 Xor(PabloAST * expr1, PabloAST * expr2, PabloBlock * parent); 33 Xor(PabloAST * expr1, PabloAST * expr2, String * name, PabloBlock * parent) 34 : Statement(ClassTypeId::Xor, {expr1, expr2}, name, parent) 35 { 36 37 } 36 38 }; 37 39 -
icGREP/icgrep-devel/icgrep/re/re_compiler.cpp
r4437 r4438 30 30 31 31 32 RE_Compiler::RE_Compiler(PabloBlock & baseCG , const cc::CC_NameMap & nameMap)33 : m CG(baseCG)32 RE_Compiler::RE_Compiler(PabloBlock & baseCG) 33 : mPB(baseCG) 34 34 , mLineFeed(nullptr) 35 35 , mInitial(nullptr) … … 43 43 if (m.pos == newpos) return m; 44 44 if (m.pos > newpos) throw std::runtime_error("icgrep internal error: attempt to AdvanceMarker backwards"); 45 Assign* a = m.stream;45 PabloAST * a = m.stream; 46 46 if (m.pos == FinalMatchByte) { 47 47 // Must advance at least to InitialPostPositionByte … … 77 77 const std::string nonfinal = "nonfinal"; 78 78 79 Assign * LF = m CG.createAssign("LF", ccc.compileCC(makeCC(0x0A)));79 Assign * LF = mPB.createAssign("LF", ccc.compileCC(makeCC(0x0A))); 80 80 mLineFeed = LF; 81 81 PabloAST * CR = ccc.compileCC(makeCC(0x0D)); … … 84 84 mCRLF = mCG.createAnd(mCG.createAdvance(CR, 1), mLineFeed); 85 85 #else 86 PabloBlock & crb = PabloBlock::Create(m CG);86 PabloBlock & crb = PabloBlock::Create(mPB); 87 87 Assign * cr1 = crb.createAssign("cr1", crb.createAdvance(CR, 1)); 88 88 Assign * acrlf = crb.createAssign("crlf", crb.createAnd(cr1, LF)); 89 m CG.createIf(CR, std::move(std::vector<Assign *>{acrlf}), crb);89 mPB.createIf(CR, std::move(std::vector<Assign *>{acrlf}), crb); 90 90 mCRLF = acrlf; 91 91 #endif … … 112 112 #ifdef USE_IF_FOR_NONFINAL 113 113 PabloAST * u8pfx = ccc.compileCC(makeCC(0xC0, 0xFF)); 114 PabloBlock & it = PabloBlock::Create(m CG);114 PabloBlock & it = PabloBlock::Create(mPB); 115 115 PabloAST * u8pfx2 = ccc.compileCC(makeCC(0xC2, 0xDF), it); 116 116 PabloAST * u8pfx3 = ccc.compileCC(makeCC(0xE0, 0xEF), it); … … 125 125 PabloAST * LS_PS = it.createAnd(it.createAdvance(E2_80, 1), ccc.compileCC(makeCC(0xA8,0xA9), it)); 126 126 Assign * NEL_LS_PS = it.createAssign("NEL_LS_PS", it.createOr(NEL, LS_PS)); 127 m CG.createIf(u8pfx, std::move(std::vector<Assign *>{valid_pfx, mNonFinal, NEL_LS_PS}), it);128 PabloAST * LB_chars = m CG.createOr(LF_VT_FF_CR, NEL_LS_PS);127 mPB.createIf(u8pfx, std::move(std::vector<Assign *>{valid_pfx, mNonFinal, NEL_LS_PS}), it); 128 PabloAST * LB_chars = mPB.createOr(LF_VT_FF_CR, NEL_LS_PS); 129 129 130 130 PabloAST * u8single = ccc.compileCC(makeCC(0x00, 0x7F)); 131 mInitial = m CG.createAssign(initial, mCG.createOr(u8single, valid_pfx));132 mUnicodeLineBreak = m CG.createAnd(LB_chars, mCG.createNot(mCRLF)); // count the CR, but not CRLF131 mInitial = mPB.createAssign(initial, mPB.createOr(u8single, valid_pfx)); 132 mUnicodeLineBreak = mPB.createAnd(LB_chars, mPB.createNot(mCRLF)); // count the CR, but not CRLF 133 133 #endif 134 134 } … … 137 137 //These three lines are specifically for grep. 138 138 PabloAST * lb = UNICODE_LINE_BREAK ? mUnicodeLineBreak : mLineFeed; 139 Assign* v = markerVar(match_result);140 m CG.createAssign("matches", mCG.createAnd(mCG.createMatchStar(v, mCG.createNot(lb)), lb), 0);141 m CG.createAssign("lf", mCG.createAnd(lb, mCG.createNot(mCRLF)), 1);139 PabloAST * v = markerVar(match_result); 140 mPB.createAssign("matches", mPB.createAnd(mPB.createMatchStar(v, mPB.createNot(lb)), lb), 0); 141 mPB.createAssign("lf", mPB.createAnd(lb, mPB.createNot(mCRLF)), 1); 142 142 } 143 143 … … 147 147 148 148 PabloAST * RE_Compiler::character_class_strm(Name * name, PabloBlock & pb) { 149 Assign* var = name->getCompiled();149 PabloAST * var = name->getCompiled(); 150 150 if (var) { 151 151 return var; … … 154 154 RE * def = name->getDefinition(); 155 155 if (def != nullptr) { 156 MarkerType m = compile(def, m CG);156 MarkerType m = compile(def, mPB); 157 157 assert(markerPos(m) == FinalMatchByte); 158 Assign* v = markerVar(m);158 PabloAST * v = markerVar(m); 159 159 name->setCompiled(v); 160 160 return v; … … 177 177 } 178 178 else { 179 //return pb.createAdvanceThenScanThru(pb.createVar(markerVar(m), pb), mNonFinal);180 179 return pb.createScanThru(pb.createAnd(mInitial, pb.createAdvance(markerVar(m), 1)), mNonFinal); 181 180 } … … 212 211 MarkerType m = AdvanceMarker(marker, InitialPostPositionByte, pb); 213 212 if (UNICODE_LINE_BREAK) { 214 PabloAST * line_end = m CG.createOr(mUnicodeLineBreak, mCRLF);213 PabloAST * line_end = mPB.createOr(mUnicodeLineBreak, mCRLF); 215 214 PabloAST * sol = pb.createNot(pb.createOr(pb.createAdvance(pb.createNot(line_end), 1), mCRLF)); 216 215 return makeMarker(InitialPostPositionByte, pb.createAssign("sol", pb.createAnd(markerVar(m), sol))); … … 279 278 MarkerType lookback = compile(asserted, pb); 280 279 AlignMarkers(m, lookback, pb); 281 Assign* lb = markerVar(lookback);280 PabloAST * lb = markerVar(lookback); 282 281 if (a->getSense() == Assertion::Sense::Negative) { 283 282 lb = pb.createAssign("not", pb.createNot(lb)); … … 288 287 MarkerType lookahead = compile(asserted, pb); 289 288 assert(markerPos(lookahead) == FinalMatchByte); 290 Assign* la = markerVar(lookahead);289 PabloAST * la = markerVar(lookahead); 291 290 if (a->getSense() == Assertion::Sense::Negative) { 292 291 la = pb.createAssign("not", pb.createNot(la)); … … 347 346 */ 348 347 349 inline Assign * RE_Compiler::consecutive1(Assign* repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb) {348 inline PabloAST * RE_Compiler::consecutive1(PabloAST * repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb) { 350 349 int i = repeated_lgth; 351 350 int total_lgth = repeat_count * repeated_lgth; 352 Assign* consecutive_i = repeated;351 PabloAST * consecutive_i = repeated; 353 352 while (i * 2 <= total_lgth) { 354 353 PabloAST * v = consecutive_i; … … 364 363 } 365 364 366 inline Assign * RE_Compiler::reachable(Assign *repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb) {365 inline PabloAST * RE_Compiler::reachable(PabloAST *repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb) { 367 366 int i = repeated_lgth; 368 367 int total_lgth = repeat_count * repeated_lgth; … … 370 369 return repeated; 371 370 } 372 Assign* reachable_i = pb.createAssign("within1", pb.createOr(repeated, pb.createAdvance(repeated, 1)));371 PabloAST * reachable_i = pb.createAssign("within1", pb.createOr(repeated, pb.createAdvance(repeated, 1))); 373 372 while (i * 2 < total_lgth) { 374 373 PabloAST * v = reachable_i; … … 386 385 MarkerType RE_Compiler::processLowerBound(RE * repeated, int lb, MarkerType marker, PabloBlock & pb) { 387 386 if (isByteLength(repeated)) { 388 Assign* cc = markerVar(compile(repeated, pb));389 Assign* cc_lb = consecutive1(cc, 1, lb, pb);387 PabloAST * cc = markerVar(compile(repeated, pb)); 388 PabloAST * cc_lb = consecutive1(cc, 1, lb, pb); 390 389 PabloAST * marker_fwd = pb.createAdvance(markerVar(marker), markerPos(marker) == FinalMatchByte ? lb : lb-1); 391 390 return makeMarker(FinalMatchByte, pb.createAssign("lowerbound", pb.createAnd(marker_fwd, cc_lb))); … … 403 402 // Create a mask of positions reachable within ub from current marker. 404 403 // Use matchstar, then apply filter. 405 Assign* match = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb));406 Assign* upperLimitMask = reachable(match, 1, ub, pb);404 PabloAST * match = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb)); 405 PabloAST * upperLimitMask = reachable(match, 1, ub, pb); 407 406 PabloAST * cursor = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb)); 408 407 PabloAST * rep_class_var = markerVar(compile(repeated, pb)); -
icGREP/icgrep-devel/icgrep/re/re_compiler.h
r4437 r4438 44 44 struct MarkerType { 45 45 MarkerPosition pos; 46 pablo:: Assign* stream;46 pablo::PabloAST * stream; 47 47 }; 48 48 49 49 inline MarkerPosition markerPos(MarkerType m) {return m.pos;} 50 50 51 inline pablo:: Assign* markerVar(MarkerType m) {return m.stream;}51 inline pablo::PabloAST * markerVar(MarkerType m) {return m.stream;} 52 52 53 53 inline MarkerType makeMarker(MarkerPosition newpos, pablo::Assign * strm) {return {newpos, strm};} … … 57 57 public: 58 58 59 RE_Compiler(pablo::PabloBlock & baseCG , const cc::CC_NameMap & nameMap);59 RE_Compiler(pablo::PabloBlock & baseCG); 60 60 void initializeRequiredStreams(cc::CC_Compiler & ccc); 61 61 void finalizeMatchResult(MarkerType match_result); 62 62 MarkerType compile(RE * re) { 63 return compile(re, m CG);63 return compile(re, mPB); 64 64 } 65 65 … … 81 81 MarkerType process(Diff * diff, MarkerType marker, pablo::PabloBlock & cg); 82 82 MarkerType process(Intersect * x, MarkerType marker, pablo::PabloBlock & cg); 83 pablo:: Assign * consecutive1(pablo::Assign *repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb);84 pablo:: Assign * reachable(pablo::Assign* repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb);83 pablo::PabloAST *consecutive1(pablo::PabloAST *repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb); 84 pablo::PabloAST * reachable(pablo::PabloAST * repeated, int repeated_lgth, int repeat_count, pablo::PabloBlock & pb); 85 85 static bool isFixedLength(RE * regexp); 86 86 MarkerType processLowerBound(RE * repeated, int lb, MarkerType marker, pablo::PabloBlock & pb); … … 88 88 MarkerType processBoundedRep(RE * repeated, int ub, MarkerType marker, pablo::PabloBlock & pb); 89 89 90 pablo::PabloBlock & m CG;90 pablo::PabloBlock & mPB; 91 91 pablo::Assign * mLineFeed; 92 92 pablo::PabloAST * mCRLF; -
icGREP/icgrep-devel/icgrep/re/re_name.h
r4410 r4438 5 5 #include <re/re_cc.h> 6 6 #include <string> 7 #include <iostream>8 7 #include <re/printer_re.h> 9 8 10 9 namespace pablo { 11 class Assign;10 class PabloAST; 12 11 } 13 12 … … 34 33 Type getType() const; 35 34 RE *getDefinition() const; 36 pablo:: Assign* getCompiled() const {35 pablo::PabloAST * getCompiled() const { 37 36 return mCompiled; 38 37 } 39 void setCompiled(pablo:: Assign* var) {38 void setCompiled(pablo::PabloAST * var) { 40 39 mCompiled = var; 41 40 } … … 62 61 63 62 private: 64 std::string mNamespace;65 std::string mName;66 const Type mType;67 RE * mDefiningRE;68 pablo:: Assign *mCompiled;63 std::string mNamespace; 64 std::string mName; 65 const Type mType; 66 RE * mDefiningRE; 67 pablo::PabloAST * mCompiled; 69 68 }; 70 69
Note: See TracChangeset
for help on using the changeset viewer.