Changeset 4459


Ignore:
Timestamp:
Feb 5, 2015, 10:48:21 AM (4 years ago)
Author:
cameron
Message:

Command-line options to control RE compilation optimizations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_compiler.cpp

    r4442 r4459  
    2424#include <assert.h>
    2525#include <stdexcept>
     26
     27#include "llvm/Support/CommandLine.h"
     28cl::OptionCategory fREcompilationOptions("Regex Compilation Options",
     29                                      "These options control the compilation of regular expressions to Pablo.");
     30
     31static cl::opt<bool> DisableLog2BoundedRepetition("disable-log2-bounded-repetition", cl::init(false),
     32                     cl::desc("disable log2 optimizations for bounded repetition of bytes"), cl::cat(fREcompilationOptions));
     33static cl::opt<int> IfInsertionGap("if-insertion-gap", cl::init(3), cl::desc("minimum number of nonempty elements between inserted if short-circuit tests"), cl::cat(fREcompilationOptions));
     34static cl::opt<bool> DisableMatchStar("disable-matchstar", cl::init(false),
     35                     cl::desc("disable MatchStar optimization"), cl::cat(fREcompilationOptions));
     36static cl::opt<bool> DisableUnicodeMatchStar("disable-Unicode-matchstar", cl::init(false),
     37                     cl::desc("disable Unicode MatchStar optimization"), cl::cat(fREcompilationOptions));
     38
    2639
    2740using namespace pablo;
     
    256269}
    257270
    258 #define matchLengthBetweenIfs 2
    259    
    260271MarkerType RE_Compiler::processSeqTail(Seq::iterator current, Seq::iterator end, int matchLenSoFar, MarkerType marker, PabloBlock & pb) {
    261272    if (current == end) return marker;
    262     if (matchLenSoFar < matchLengthBetweenIfs) {
     273    if (matchLenSoFar < IfInsertionGap) {
    263274        RE * r = *current;
    264275        marker = process(r, marker, pb);
     
    409420
    410421MarkerType RE_Compiler::processLowerBound(RE * repeated, int lb, MarkerType marker, PabloBlock & pb) {
    411     if (isByteLength(repeated)) {
     422    if (isByteLength(repeated) && !DisableLog2BoundedRepetition) {
    412423        PabloAST * cc = markerVar(compile(repeated, pb));
    413424        PabloAST * cc_lb = consecutive1(cc, 1, lb, pb);
     
    425436
    426437MarkerType RE_Compiler::processBoundedRep(RE * repeated, int ub, MarkerType marker, PabloBlock & pb) {
    427     if (isByteLength(repeated) && ub > 1) {
     438    if (isByteLength(repeated) && ub > 1 && !DisableLog2BoundedRepetition) {
    428439        // log2 upper bound for fixed length (=1) class
    429440        // Create a mask of positions reachable within ub from current marker.
     
    451462    PabloAST * base = markerVar(AdvanceMarker(marker, InitialPostPositionByte, pb));
    452463   
    453     if (isByteLength(repeated)) {
     464    if (isByteLength(repeated)  && !DisableMatchStar) {
    454465        PabloAST * cc = markerVar(compile(repeated, pb)); 
    455466        return makeMarker(InitialPostPositionByte, pb.createMatchStar(base, cc, "unbounded"));
    456467    }
    457     else if (isUnicodeUnitLength(repeated)) {
     468    else if (isUnicodeUnitLength(repeated) && !DisableMatchStar && !DisableUnicodeMatchStar) {
    458469        PabloAST * cc = markerVar(compile(repeated, pb));
    459470        return makeMarker(InitialPostPositionByte, pb.createAnd(pb.createMatchStar(base, pb.createOr(mNonFinal, cc)), mInitial, "unbounded"));
Note: See TracChangeset for help on using the changeset viewer.