Ignore:
Timestamp:
Feb 23, 2016, 9:07:05 AM (3 years ago)
Author:
lindanl
Message:

new version using the kernels.

File:
1 edited

Legend:

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

    r4907 r4939  
    2222#include "utf_encoding.h"
    2323#include <llvm/IR/Type.h>
    24 #include <kernels/s2p_gen.h>
    2524#include <pablo/pablo_compiler.h>
    2625#include <do_grep.h>
    2726#include <sstream>
    2827#include <algorithm>
     28#include "../kernels/pipeline.h"
     29#include "../toolchain.h"
    2930
    3031
     
    512513    return createName(std::move(canonicalize(start, mCursor.pos())));
    513514}
    514 
     515/*
    515516Name * RE_Parser::parseNamePatternExpression(){
    516517
     
    570571    return nullptr;
    571572}
    572 
     573*/
     574Name * RE_Parser::parseNamePatternExpression(){
     575
     576    ModeFlagSet outerFlags = fModeFlagSet;
     577    fModeFlagSet = 1;
     578
     579    bool outerNested = fNested;
     580    fNested = true;
     581
     582    RE * nameRE = parse_RE();
     583
     584    // Reset outer parsing state.
     585    fModeFlagSet = outerFlags;
     586    fNested = outerNested;
     587
     588    // Embed the nameRE in ";.*$nameRE" to skip the codepoint field of Uname.txt
     589    RE * embedded = makeSeq({mMemoizer.memoize(makeCC(0x3B)), makeRep(makeAny(), 0, Rep::UNBOUNDED_REP), nameRE});
     590    Encoding encoding(Encoding::Type::UTF_8, 8);
     591    embedded = regular_expression_passes(encoding, embedded);
     592
     593    pablo::PabloFunction * const nameSearchFunction = re2pablo_compiler(encoding, embedded);
     594    pablo_function_passes(nameSearchFunction);
     595   
     596    Module * M = new Module("NamePattern", getGlobalContext());
     597    IDISA::IDISA_Builder * idb = GetNativeIDISA_Builder(M, VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE/64));
     598   
     599    PipelineBuilder pipelineBuilder(M, idb);
     600    pipelineBuilder.CreateKernels(nameSearchFunction, true);
     601    pipelineBuilder.ExecuteKernels();
     602
     603    llvm::Function * main_IR = M->getFunction("Main");
     604    llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(M);
     605   
     606    icgrep_Linking(M, engine);
     607
     608    engine->finalizeObject();
     609
     610    void * main_MCptr = engine->getPointerToFunction(main_IR);
     611
     612    CC * codepoints = nullptr;
     613    if(main_MCptr){
     614        GrepExecutor grepEngine(main_MCptr);
     615        setParsedCodePointSet();
     616        grepEngine.doGrep("../Uname.txt");
     617        codepoints = getParsedCodePointSet();
     618        assert (codepoints);
     619    }
     620       
     621    delete engine;
     622    if (codepoints) {
     623        Name * const result = mMemoizer.memoize(codepoints);
     624        assert (*cast<CC>(result->getDefinition()) == *codepoints);
     625        return result;
     626    }
     627    return nullptr;
     628}
    573629
    574630CharsetOperatorKind RE_Parser::getCharsetOperator() {
Note: See TracChangeset for help on using the changeset viewer.