Ignore:
Timestamp:
Sep 30, 2015, 12:26:23 PM (4 years ago)
Author:
nmedfort
Message:

Progress on multi-target UCD compilation

Location:
icGREP/icgrep-devel/icgrep/UCD
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/ucd_compiler.cpp

    r4804 r4808  
    99
    1010namespace UCD {
    11 
    12 /** ------------------------------------------------------------------------------------------------------------- *
    13  * @brief addTarget
    14  ** ------------------------------------------------------------------------------------------------------------- */
    15 inline void UCDCompiler::addTarget(const UnicodeSet & set) {
    16     mTargetMap.emplace(&set, PabloBlock::createZeroes());
    17 }
    1811
    1912/** ------------------------------------------------------------------------------------------------------------- *
     
    369362 * @return the output stream with a 1-bit in any position of a character in the unicode set
    370363 ** ------------------------------------------------------------------------------------------------------------- */
    371 PabloAST * UCDCompiler::generateWithDefaultIfHierarchy(const UnicodeSet & set, PabloBuilder & entry) {
     364std::vector<PabloAST *> UCDCompiler::generateWithDefaultIfHierarchy(const std::vector<UnicodeSet> & sets, PabloBuilder & entry) {
    372365
    373366    const RangeList defaultIfHierachy = {
     
    458451        {0x10000, 0x10FFFF}};
    459452
    460     addTarget(set);
     453    addTargets(sets);
    461454    generateRange(defaultIfHierachy, entry);
    462     return mTargetMap[&set];
     455    return std::move(returnMarkers(sets));
    463456}
    464457
     
    469462 * @return the output stream with a 1-bit in any position of a character in the unicode set
    470463 ** ------------------------------------------------------------------------------------------------------------- */
    471 PabloAST * UCDCompiler::generateWithoutIfHierarchy(const UnicodeSet & set, PabloBuilder & entry) {
    472     const RangeList defaultIfHierachy = {{0x10000, 0x10FFFF}};
    473     addTarget(set);
    474     generateRange(defaultIfHierachy, entry);
    475     return mTargetMap[&set];
     464std::vector<PabloAST *> UCDCompiler::generateWithoutIfHierarchy(const std::vector<UnicodeSet> & sets, PabloBuilder & entry) {
     465    const RangeList noIfHierachy = {{0x10000, 0x10FFFF}};
     466
     467    addTargets(sets);
     468    generateRange(noIfHierachy, entry);
     469    return std::move(returnMarkers(sets));
     470}
     471
     472/** ------------------------------------------------------------------------------------------------------------- *
     473 * @brief addTargets
     474 ** ------------------------------------------------------------------------------------------------------------- */
     475inline void UCDCompiler::addTargets(const std::vector<UnicodeSet> &sets) {
     476    for (const UnicodeSet & set : sets) {
     477        mTargetMap.emplace(&set, PabloBlock::createZeroes());
     478    }
     479}
     480
     481/** ------------------------------------------------------------------------------------------------------------- *
     482 * @brief returnMarkers
     483 ** ------------------------------------------------------------------------------------------------------------- */
     484inline std::vector<PabloAST *> UCDCompiler::returnMarkers(const std::vector<UnicodeSet> & sets) const {
     485    std::vector<PabloAST *> markers(sets.size());
     486    unsigned i = 0;
     487    for (const UnicodeSet & set : sets) {
     488        auto f = mTargetMap.find(&set);
     489        assert (f != mTargetMap.end());
     490        assert (f->second);
     491        markers[i++] = f->second;
     492    }
     493    return std::move(markers);
    476494}
    477495
  • icGREP/icgrep-devel/icgrep/UCD/ucd_compiler.hpp

    r4804 r4808  
    4141    UCDCompiler(cc::CC_Compiler & ccCompiler);
    4242
    43     PabloAST * generateWithDefaultIfHierarchy(const UnicodeSet & set, PabloBuilder & entry);
     43    std::vector<PabloAST *> generateWithDefaultIfHierarchy(const std::vector<UnicodeSet> &sets, PabloBuilder & entry);
    4444
    45     PabloAST * generateWithoutIfHierarchy(const UnicodeSet & set, PabloBuilder & entry);
     45    std::vector<PabloAST *> generateWithoutIfHierarchy(const std::vector<UnicodeSet> & sets, PabloBuilder & entry);
    4646
    4747protected:
     
    6363    PabloAST * makePrefix(const codepoint_t cp, const unsigned byte_no, PabloBuilder & builder, PabloAST * prefix);
    6464
    65     void addTarget(const UnicodeSet & set);
    66 
    6765    static RangeList byteDefinitions(const RangeList & list, const unsigned byte_no);
    6866
     
    7674    static RangeList innerRanges(const RangeList & list);
    7775
     76    void addTargets(const std::vector<UnicodeSet> & sets);
     77
     78    std::vector<PabloAST *> returnMarkers(const std::vector<UnicodeSet> &sets) const;
     79
    7880private:
    7981    cc::CC_Compiler &       mCharacterClassCompiler;
Note: See TracChangeset for help on using the changeset viewer.