Changeset 5814


Ignore:
Timestamp:
Dec 30, 2017, 4:43:19 PM (6 months ago)
Author:
cameron
Message:

Parsing of byte CCs

Location:
icGREP/icgrep-devel/icgrep
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r5748 r5814  
    142142
    143143    if ((n2 < n1) || (diff_count > mEncodingBits)) {
    144         throw std::runtime_error("Bad Range: [" + std::to_string(n1) + "," +
     144        llvm::report_fatal_error("Bad Range: [" + std::to_string(n1) + "," +
    145145                                 std::to_string(n2) + "] for " +
    146146                                 std::to_string(mEncodingBits) + "-bit encoding");
     
    218218        return make_range(lo, hi, pb);
    219219    }
    220     throw std::runtime_error(std::string("Invalid Character Set Range: [") + std::to_string(lo) + "," + std::to_string(hi) + "]");
     220    llvm::report_fatal_error(std::string("Invalid Character Set Range: [") + std::to_string(lo) + "," + std::to_string(hi) + "]");
    221221}
    222222
  • icGREP/icgrep-devel/icgrep/re/re_memoizer.hpp

    r5630 r5814  
    2121    }
    2222
    23     Name * memoize(CC * const cc) {
    24         auto f = find(cc);
    25         if (f != end()) {
    26             return llvm::cast<Name>(*f);
    27         } else {
    28             return memoize(makeName(cc));
    29         }
     23    CC * memoize(CC * const cc) {
     24        return llvm::cast<CC>(memoize(llvm::cast<RE>(cc)));
    3025    }
    3126};
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r5805 r5814  
    348348    else if (atany("xo0")) {
    349349        codepoint_t cp = parse_escaped_codepoint();
    350         if ((cp >= 0x80) && (cp <= 0xFF)) {
     350        if ((cp <= 0xFF)) {
    351351            return makeByte(cp);
    352352        }
     
    715715RE * RE_Parser::parse_escaped_char_item() {
    716716    if (accept('N')) return parseNamePatternExpression();
     717    else if (atany("xo0")) {
     718        codepoint_t cp = parse_escaped_codepoint();
     719        if ((cp <= 0xFF)) {
     720            return makeByte(cp);
     721        }
     722        else return createCC(cp);
     723    }
    717724    else return makeCC(parse_escaped_codepoint());
    718725}
     
    811818}
    812819
    813 Name * RE_Parser::createCC(const codepoint_t cp) {
    814     CC * cc = makeCC(cp);
    815     return mMemoizer.memoize(cc);
    816 }
    817 
    818 void RE_Parser::insert(CC * cc, const codepoint_t cp) {
    819     cc->insert(cp);
    820 }
    821 
    822 void RE_Parser::insert_range(CC * cc, const codepoint_t lo, const codepoint_t hi) {
    823     cc->insert_range(lo, hi);
     820CC * RE_Parser::createCC(const codepoint_t cp) {
     821    CC * cc = mMemoizer.memoize(makeCC(cp));
     822    return cc;
    824823}
    825824
     
    828827}
    829828
    830            
    831 
    832                            
    833829RE * RE_Parser::makeWordBoundary() {
    834830    Name * wordC = makeWordSet();
  • icGREP/icgrep-devel/icgrep/re/re_parser.h

    r5792 r5814  
    233233    codepoint_t parse_octal_codepoint(int mindigits, int maxdigits);
    234234
    235     // CC insertion dependent on case-insensitive flag.
    236     Name * createCC(const codepoint_t cp);
    237     void insert(CC * cc, const codepoint_t cp);
    238     void insert_range(CC * cc, const codepoint_t lo, const codepoint_t hi);
     235    CC * createCC(const codepoint_t cp);
    239236
    240237    static std::string canonicalize(const cursor_t begin, const cursor_t end);
  • icGREP/icgrep-devel/icgrep/re/re_range.cpp

    r5792 r5814  
    2121        auto lo_val = dyn_cast<CC>(lo)->front().first;
    2222        auto hi_val = dyn_cast<CC>(hi)->front().first;
    23         if (hi_val < lo_val) llvm::report_fatal_error("illegal range");
    24         return makeCC(lo_val, hi_val);
     23        return makeCC(lo_val, hi_val, dyn_cast<CC>(hi)->getAlphabet());
    2524    }
    2625    else if (isa<Name>(lo) && (cast<Name>(lo)->getDefinition() != nullptr)) {
  • icGREP/icgrep-devel/icgrep/wc.cpp

    r5755 r5814  
    9292WordCountKernel::WordCountKernel (const std::unique_ptr<kernel::KernelBuilder> & b)
    9393: PabloKernel(b, "wc",
    94     {Binding{b->getStreamSetTy(8, 1), "u8bit"}},
    95     {},
     94    {Binding{b->getStreamSetTy(8, 1), "u8bit"}, Binding{b->getStreamSetTy(1, 8), "u8byte"}},
     95    {Binding{b->getStreamSetTy(1, 8), "dblbyte"}},
    9696    {},
    9797    {Binding{b->getSizeTy(), "lineCount"}, Binding{b->getSizeTy(), "wordCount"}, Binding{b->getSizeTy(), "charCount"}}) {
     
    103103    //  input: 8 basis bit streams
    104104    const auto u8bitSet = getInputStreamVar("u8bit");
     105    const auto u8byteSet = getInputStreamVar("u8byte");
     106    const auto dblbyteSet = getOutputStreamVar("dblbyte");
    105107    //  output: 3 counters
    106108
     
    109111    PabloBuilder & pb = ccc.getBuilder();
    110112
     113    PabloAST * bytes = pb.createExtract(u8byteSet, pb.getInteger(0));
     114    PabloAST * dbl = pb.createAdd(bytes, bytes);
     115    pb.createAssign(pb.createExtract(dblbyteSet, pb.getInteger(0)), dbl);
     116   
    111117    Var * lc = getOutputScalarVar("lineCount");
    112118    Var * wc = getOutputScalarVar("wordCount");
     
    164170
    165171    StreamSetBuffer * const ByteStream = pxDriver.addBuffer<SourceBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8));
     172    StreamSetBuffer * const ByteOut = pxDriver.addBuffer<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(1, 8), segmentSize * bufferSegments);
    166173
    167174    StreamSetBuffer * const BasisBits = pxDriver.addBuffer<CircularBuffer>(iBuilder, iBuilder->getStreamSetTy(8, 1), segmentSize * bufferSegments);
     
    175182   
    176183    Kernel * wck = pxDriver.addKernelInstance<WordCountKernel>(iBuilder);
    177     pxDriver.makeKernelCall(wck, {BasisBits}, {});
     184    pxDriver.makeKernelCall(wck, {BasisBits,ByteStream}, {ByteOut});
    178185
    179186    pxDriver.generatePipelineIR();
Note: See TracChangeset for help on using the changeset viewer.