// Compute a range A-B and add it to the list. void HexagonBlockRanges::RangeList::addsub(const IndexRange &A, const IndexRange &B) { // Exclusion of non-overlapping ranges makes some checks simpler // later in this function. if (!A.overlaps(B)) { // A - B = A. add(A); return; } IndexType AS = A.start(), AE = A.end(); IndexType BS = B.start(), BE = B.end(); // If AE is None, then A is included in B, since A and B overlap. // The result of subtraction if empty, so just return. if (AE == IndexType::None) return; if (AS < BS) { // A starts before B. // AE cannot be None since A and B overlap. assert(AE != IndexType::None); // Add the part of A that extends on the "less" side of B. add(AS, BS, A.Fixed, false); } if (BE < AE) { // BE cannot be Exit here. if (BE == IndexType::None) add(BS, AE, A.Fixed, false); else add(BE, AE, A.Fixed, false); } }