예제 #1
0
// class method
NoOperation::IndexIntervals
NoOperation::largestEarliestNonOverlapping(const NoOperation::IndexIntervals &in) {
    NoOperation::IndexIntervals sorted = in, retval;
    std::sort(sorted.begin(), sorted.end(), sortBySizeAddress);
    Sawyer::Container::IntervalSet<IndexInterval> seen;
    BOOST_FOREACH (const NoOperation::IndexInterval &where, sorted) {
        if (!seen.isOverlapping(where)) {
            retval.push_back(where);
            seen.insert(where);
        }
    }
    return retval;
}
void
RegisterStateGeneric::assertStorageConditions(const std::string &when, const RegisterDescriptor &reg) const {
#if !defined(NDEBUG) && defined(RegisterStateGeneric_ExtraAssertions)
#if 1 // DEBUGGING [Robb P. Matzke 2015-09-28]
    static volatile size_t ncalls = 0;
    ++ncalls;
#endif
    std::ostringstream error;
    BOOST_FOREACH (const Registers::Node &rnode, registers_.nodes()) {
        Sawyer::Container::IntervalSet<BitRange> foundLocations;
        BOOST_FOREACH (const RegPair &regpair, rnode.value()) {
            if (!regpair.desc.is_valid()) {
                error <<"invalid register descriptor";
            } else if (regpair.desc.get_major() != rnode.key().majr || regpair.desc.get_minor() != rnode.key().minr) {
                error <<"register is in wrong list; register=" <<regpair.desc.get_major() <<"." <<regpair.desc.get_minor()
                      <<", list=" <<rnode.key().majr <<"." <<rnode.key().minr;
            } else if (regpair.value == NULL) {
                error <<"value is null for register " <<regpair.desc;
            } else if (regpair.value->get_width() != regpair.desc.get_nbits()) {
                error <<"value width (" <<regpair.value->get_width() <<") is incorrect for register " <<regpair.desc;
            } else if (foundLocations.isOverlapping(regpair.location())) {
                error <<"register " <<regpair.desc <<" is stored multiple times in the list";
            }
            foundLocations.insert(regpair.location());
            if (!error.str().empty())
                break;
        }
        if (!error.str().empty()) {
            mlog[FATAL] <<when <<" register " <<reg <<":\n";
            mlog[FATAL] <<"  " <<error.str() <<"\n";
            mlog[FATAL] <<"  related registers:\n";
            BOOST_FOREACH (const RegPair &regpair, rnode.value()) {
                mlog[FATAL] <<"    " <<regpair.desc;
                if (regpair.value == NULL)
                    mlog[FATAL] <<"\tnull value";
                mlog[FATAL] <<"\n";
            }
            abort();
        }
    }