2018-01-23 19:16:39 +00:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2018 MerryMage
|
2020-04-23 15:25:11 +01:00
|
|
|
* SPDX-License-Identifier: 0BSD
|
2018-01-23 19:16:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <boost/icl/interval_map.hpp>
|
|
|
|
#include <boost/icl/interval_set.hpp>
|
2020-05-21 21:31:18 +01:00
|
|
|
#include <tsl/robin_set.h>
|
2018-01-23 19:16:39 +00:00
|
|
|
|
2018-08-14 13:13:47 -05:00
|
|
|
#include "backend/x64/block_range_information.h"
|
2018-01-23 19:16:39 +00:00
|
|
|
#include "common/common_types.h"
|
|
|
|
|
2020-04-08 11:46:36 +01:00
|
|
|
namespace Dynarmic::Backend::X64 {
|
2018-01-23 19:16:39 +00:00
|
|
|
|
|
|
|
template <typename ProgramCounterType>
|
|
|
|
void BlockRangeInformation<ProgramCounterType>::AddRange(boost::icl::discrete_interval<ProgramCounterType> range, IR::LocationDescriptor location) {
|
|
|
|
block_ranges.add(std::make_pair(range, std::set<IR::LocationDescriptor>{location}));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename ProgramCounterType>
|
|
|
|
void BlockRangeInformation<ProgramCounterType>::ClearCache() {
|
|
|
|
block_ranges.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename ProgramCounterType>
|
2020-05-21 21:31:18 +01:00
|
|
|
tsl::robin_set<IR::LocationDescriptor> BlockRangeInformation<ProgramCounterType>::InvalidateRanges(const boost::icl::interval_set<ProgramCounterType>& ranges) {
|
|
|
|
tsl::robin_set<IR::LocationDescriptor> erase_locations;
|
2018-01-23 19:16:39 +00:00
|
|
|
for (auto invalidate_interval : ranges) {
|
|
|
|
auto pair = block_ranges.equal_range(invalidate_interval);
|
|
|
|
for (auto it = pair.first; it != pair.second; ++it) {
|
|
|
|
for (const auto &descriptor : it->second) {
|
|
|
|
erase_locations.insert(descriptor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO: EFFICIENCY: Remove ranges that are to be erased.
|
|
|
|
return erase_locations;
|
|
|
|
}
|
|
|
|
|
|
|
|
template class BlockRangeInformation<u32>;
|
|
|
|
template class BlockRangeInformation<u64>;
|
|
|
|
|
2020-04-08 11:46:36 +01:00
|
|
|
} // namespace Dynarmic::Backend::X64
|