addr_range.hh (10678:d95e81d44e36) | addr_range.hh (10853:5312e4cb6547) |
---|---|
1/* 2 * Copyright (c) 2012, 2014 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 268 unchanged lines hidden (view full) --- 277 * is an address that is both in this range and the other 278 * range. No check is made to ensure either range is valid. 279 * 280 * @param r Range to intersect with 281 * @return true if the intersection of the two ranges is not empty 282 */ 283 bool intersects(const AddrRange& r) const 284 { | 1/* 2 * Copyright (c) 2012, 2014 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 268 unchanged lines hidden (view full) --- 277 * is an address that is both in this range and the other 278 * range. No check is made to ensure either range is valid. 279 * 280 * @param r Range to intersect with 281 * @return true if the intersection of the two ranges is not empty 282 */ 283 bool intersects(const AddrRange& r) const 284 { |
285 if (!interleaved()) { 286 return _start <= r._end && _end >= r._start; 287 } | 285 if (_start > r._end || _end < r._start) 286 // start with the simple case of no overlap at all, 287 // applicable even if we have interleaved ranges 288 return false; 289 else if (!interleaved() && !r.interleaved()) 290 // if neither range is interleaved, we are done 291 return true; |
288 | 292 |
289 // the current range is interleaved, split the check up in 290 // three cases | 293 // now it gets complicated, focus on the cases we care about |
291 if (r.size() == 1) 292 // keep it simple and check if the address is within 293 // this range 294 return contains(r.start()); | 294 if (r.size() == 1) 295 // keep it simple and check if the address is within 296 // this range 297 return contains(r.start()); |
295 else if (!r.interleaved()) 296 // be conservative and ignore the interleaving 297 return _start <= r._end && _end >= r._start; | |
298 else if (mergesWith(r)) 299 // restrict the check to ranges that belong to the 300 // same chunk 301 return intlvMatch == r.intlvMatch; 302 else | 298 else if (mergesWith(r)) 299 // restrict the check to ranges that belong to the 300 // same chunk 301 return intlvMatch == r.intlvMatch; 302 else |
303 panic("Cannot test intersection of interleaved range %s\n", 304 to_string()); | 303 panic("Cannot test intersection of %s and %s\n", 304 to_string(), r.to_string()); |
305 } 306 307 /** 308 * Determine if this range is a subset of another range, i.e. if 309 * every address in this range is also in the other range. No 310 * check is made to ensure either range is valid. 311 * 312 * @param r Range to compare with --- 95 unchanged lines hidden --- | 305 } 306 307 /** 308 * Determine if this range is a subset of another range, i.e. if 309 * every address in this range is also in the other range. No 310 * check is made to ensure either range is valid. 311 * 312 * @param r Range to compare with --- 95 unchanged lines hidden --- |