From 41105631759ac33a45a4f71aaf104d2029fbba68 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Fri, 5 May 2023 08:45:36 -0700 Subject: [PATCH] Support TLFilter.mSubtract with multiple AddressSets (#3339) Enables filtering out multiple ranges at once. --- src/main/scala/tilelink/Filter.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/scala/tilelink/Filter.scala b/src/main/scala/tilelink/Filter.scala index 419d7a2997a..fcc59dc5eb5 100644 --- a/src/main/scala/tilelink/Filter.scala +++ b/src/main/scala/tilelink/Filter.scala @@ -89,12 +89,16 @@ object TLFilter } // make everything except the intersected address sets visible - def mSubtract(except: AddressSet): ManagerFilter = { m => - val filtered = m.address.flatMap(_.subtract(except)) + def mSubtract(excepts: Seq[AddressSet]): ManagerFilter = { m => + val filtered = excepts.foldLeft(m.address) { (a,e) => a.flatMap(_.subtract(e)) } val alignment: BigInt = if (filtered.isEmpty) 0 else filtered.map(_.alignment).min transferSizeHelper(m, filtered, alignment) } + def mSubtract(except: AddressSet): ManagerFilter = { m => + mSubtract(Seq(except))(m) + } + // adjust supported transfer sizes based on filtered intersection private def transferSizeHelper(m: TLSlaveParameters, filtered: Seq[AddressSet], alignment: BigInt): Option[TLSlaveParameters] = { val maxTransfer = 1 << 30