Ignore:
Timestamp:
Aug 28, 2017, 4:00:17 PM (21 months ago)
Author:
nmedfort
Message:

Bug fixes for multigrep mode. Optional PabloKernel? branch hit counter added. Minor optimizations.

Location:
icGREP/icgrep-devel/icgrep/cc
Files:
4 edited

Legend:

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

    r5279 r5620  
    1212// of the nth character is just the given value n, if it is in range.
    1313
    14 UCD::codepoint_t Alphabet::toUnicode(unsigned n) {
     14UCD::codepoint_t Alphabet::toUnicode(const unsigned n) const {
    1515    UCD::codepoint_t cp = n;
    1616    if (mCharSet.contains(cp)) return cp;
     
    2121// of a Unicode codepoint is just the given codepoint, if it is in range.
    2222
    23 unsigned Alphabet::fromUnicode(UCD::codepoint_t codepoint) {
     23unsigned Alphabet::fromUnicode(const UCD::codepoint_t codepoint) const {
    2424    if (mCharSet.contains(codepoint)) return codepoint;
    2525    throw std::runtime_error("fromUnicode: codepoint not found in alphabet.");
     
    3636}   
    3737
    38 template <class uint_t> UCD::codepoint_t ExtendedASCII<uint_t>::toUnicode(unsigned n) {
     38template <class uint_t> UCD::codepoint_t ExtendedASCII<uint_t>::toUnicode(const unsigned n) const {
    3939    //  The first 128 characters are just ASCII.
    4040    if (n < 128) return n;
     
    4343}   
    4444
    45 template <class uint_t> unsigned ExtendedASCII<uint_t>::fromUnicode(UCD::codepoint_t codepoint) {
     45template <class uint_t> unsigned ExtendedASCII<uint_t>::fromUnicode(const UCD::codepoint_t codepoint) const {
    4646    if (codepoint < 128) return codepoint;
    4747    for (unsigned i = 0; i < 128; i++) {
  • icGREP/icgrep-devel/icgrep/cc/alphabet.h

    r5281 r5620  
    2626        mAlphabetName(alphabetName), mCharSet(UCD::UnicodeSet(0, maxChar)) {}
    2727       
    28     std::string getName() { return mAlphabetName;}
     28    const std::string & getName() const { return mAlphabetName;}
    2929   
    30     UCD::UnicodeSet getSet() { return mCharSet;}
     30    const UCD::UnicodeSet & getSet() const { return mCharSet;}
    3131   
    3232    //  The Unicode codepoint of the nth character (the character whose alphabet code is n).
    33     virtual UCD::codepoint_t toUnicode(unsigned n);
     33    virtual UCD::codepoint_t toUnicode(const unsigned n) const;
    3434   
    3535    //  The ordinal position of the character whose Unicode codepoint value is ucp.
    36     virtual unsigned fromUnicode(UCD::codepoint_t ucp);
     36    virtual unsigned fromUnicode(const UCD::codepoint_t ucp) const;
    3737
    3838protected:
     
    5959public:
    6060    ExtendedASCII(std::string alphabetName, const uint_t (& extendedTable)[128]);
    61     UCD::codepoint_t  toUnicode(unsigned n) override;
    62     unsigned fromUnicode(UCD::codepoint_t ucp) override;
     61    UCD::codepoint_t toUnicode(const unsigned n) const final;
     62    unsigned fromUnicode(const UCD::codepoint_t ucp) const final;
    6363private:
    6464    const uint_t (& mExtendedCharacterTable)[128];
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.cpp

    r5310 r5620  
    1212#include <pablo/builder.hpp>
    1313#include <pablo/pablo_kernel.h>
     14
    1415
    1516using namespace re;
     
    3334   
    3435   
    35     CC_Compiler::CC_Compiler(pablo::PabloKernel * kernel, pablo::Var * basisBits)
    36     : mBuilder(kernel->getEntryBlock())
    37     , mEncodingBits(basisBits->getType()->getArrayNumElements())
    38     , mBasisBit(mEncodingBits) {
    39         for (unsigned i = 0; i != mEncodingBits; i++) {
    40             mBasisBit[i] = mBuilder.createExtract(basisBits, mBuilder.getInteger(i)); assert (mBasisBit[i]);
    41         }
    42         mEncodingMask = (static_cast<unsigned>(1) << mEncodingBits) - static_cast<unsigned>(1);
    43     }
    44    
    45    
    46 
    47 PabloAST * CC_Compiler::compileCC(const std::string & canonicalName, const CC *cc, PabloBlock & block) {
     36CC_Compiler::CC_Compiler(pablo::PabloKernel * kernel, pablo::Var * basisBits)
     37: mBuilder(kernel->getEntryBlock())
     38, mEncodingBits(basisBits->getType()->getArrayNumElements())
     39, mBasisBit(mEncodingBits) {
     40    for (unsigned i = 0; i != mEncodingBits; i++) {
     41        mBasisBit[i] = mBuilder.createExtract(basisBits, mBuilder.getInteger(i)); assert (mBasisBit[i]);
     42    }
     43    mEncodingMask = (static_cast<unsigned>(1) << mEncodingBits) - static_cast<unsigned>(1);
     44}
     45
     46PabloAST * CC_Compiler::compileCC(const std::string & canonicalName, const CC *cc, PabloBlock & block) {   
    4847    PabloAST * const var = charset_expr(cc, block);
    4948    if (LLVM_LIKELY(isa<Statement>(var))) {
     
    155154    for (codepoint_t diff_bits = n1 ^ n2; diff_bits; diff_count++, diff_bits >>= 1);
    156155
    157     if ((n2 < n1) || (diff_count > mEncodingBits))
    158     {
    159         throw std::runtime_error("Bad Range: [" + std::to_string(n1) + "," + std::to_string(n2) + "]");
     156    if ((n2 < n1) || (diff_count > mEncodingBits)) {
     157        throw std::runtime_error("Bad Range: [" + std::to_string(n1) + "," +
     158                                 std::to_string(n2) + "] for " +
     159                                 std::to_string(mEncodingBits) + "-bit encoding");
    160160    }
    161161
  • icGREP/icgrep-devel/icgrep/cc/cc_compiler.h

    r5440 r5620  
    3838    pablo::PabloBuilder & getBuilder();
    3939
    40     const std::vector<pablo::PabloAST *> & getBasisBits() {
     40    const std::vector<pablo::PabloAST *> & getBasisBits() const {
    4141        return mBasisBit;
    4242    }
Note: See TracChangeset for help on using the changeset viewer.