Changeset 5904 for icGREP


Ignore:
Timestamp:
Mar 13, 2018, 11:08:20 AM (15 months ago)
Author:
nmedfort
Message:

minor bug fix

File:
1 edited

Legend:

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

    r5821 r5904  
    2424#include <llvm/Support/Format.h>
    2525#include <llvm/ADT/SmallVector.h>
     26#ifndef NDEBUG
     27#include <llvm/Support/ErrorHandling.h>
     28#endif
    2629
    2730namespace UCD {
     
    4952const auto QUAD_LIMIT = (QUAD_BITS - 1);
    5053const auto UNICODE_QUAD_COUNT = (UNICODE_MAX + 1) / QUAD_BITS;
    51 const bitquad_t FULL_QUAD_MASK = ~static_cast<bitquad_t>(0);
     54const auto FULL_QUAD_MASK = std::numeric_limits<bitquad_t>::max();
    5255
    5356inline run_type_t typeOf(const run_t & run) {
     
    116119    if (LLVM_UNLIKELY(quad == 0)) {
    117120        type = Empty;
    118     } else if (LLVM_UNLIKELY(~quad == 0)) {
     121    } else if (LLVM_UNLIKELY(quad == FULL_QUAD_MASK)) {
    119122        type = Full;
    120123    } else {
     
    137140        const auto type = typeOf(runs[i]);
    138141        if (LLVM_UNLIKELY(type != Empty && type != Mixed && type != Full)) {
    139             llvm::errs() << "illegal run type " << type << " found\n";
     142            report_fatal_error("illegal run type " + std::to_string(type) + " found");
    140143            return false;
    141144        }
    142145        const auto l = lengthOf(runs[i]);
    143146        if (LLVM_UNLIKELY(l == 0)) {
    144             llvm::errs() << "zero-length quad found\n";
     147            report_fatal_error("zero-length quad found");
    145148            return false;
    146149        }
     
    151154    }
    152155    if (LLVM_UNLIKELY(sum != UNICODE_QUAD_COUNT)) {
    153         llvm::errs() << "found " << sum << " quads but expected " << UNICODE_QUAD_COUNT << "\n";
     156        report_fatal_error("found " + std::to_string(sum) + " quads but expected " + std::to_string(UNICODE_QUAD_COUNT));
    154157        return false;
    155158    }
    156159    if (LLVM_UNLIKELY(mixedQuads != quadLength)) {
    157         llvm::errs() << "found " << quadLength << " mixed quad(s) but expected " << mixedQuads << "\n";
     160        report_fatal_error("found " + std::to_string(quadLength) + " mixed quad(s) but expected " + std::to_string(mixedQuads));
    158161        return false;
    159162    }
    160163    for (unsigned i = 0; i < quadLength; ++i) {
    161         if (LLVM_UNLIKELY((quads[i] == 0) || (~quads[i] == 0))) {
    162             llvm::errs() << "Empty or Full quad found in Mixed quad array\n";
     164        if (LLVM_UNLIKELY((quads[i] == 0) || (quads[i] == FULL_QUAD_MASK))) {
     165            report_fatal_error("Empty or Full quad found in Mixed quad array");
    163166            return false;
    164167        }
     
    594597    }
    595598
    596     if (LLVM_LIKELY(type == Mixed)) {       
     599    if (LLVM_LIKELY(type == Mixed)) {
    597600        quadIndex += offset;
    598601        if (LLVM_UNLIKELY(mQuadCapacity == 0)) {
     
    600603            std::memcpy(quads, mQuads, (quadIndex - 1) * sizeof(bitquad_t));
    601604            quads[quadIndex] = mQuads[quadIndex] | value;
    602             const unsigned offset = (~quads[quadIndex] == 0) ? 1 : 0;
     605            const unsigned offset = (quads[quadIndex] == FULL_QUAD_MASK) ? 1 : 0;
    603606            mQuadCapacity = mQuadLength;
    604607            mQuadLength -= offset;
     
    614617        } else { // reuse the buffer
    615618            mQuads[quadIndex] |= value;
    616             if (LLVM_LIKELY(~mQuads[quadIndex] != 0)) { // no change to runs needed
     619            if (LLVM_LIKELY(mQuads[quadIndex] == FULL_QUAD_MASK)) { // no change to runs needed
    617620                assert (verify(mRuns, mRunLength, mQuads, mQuadLength));
    618621                assert (contains(cp));
     
    620623            }
    621624            --mQuadLength;
    622             ++quadIndex;
    623625            std::memmove(mQuads + quadIndex, mQuads + quadIndex + 1, (mQuadLength - quadIndex) * sizeof(bitquad_t));
    624626        }
Note: See TracChangeset for help on using the changeset viewer.