1#ifndef ROSE_BinaryAnalysis_Partitioner2_AddressUsageMap_H
2#define ROSE_BinaryAnalysis_Partitioner2_AddressUsageMap_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/Partitioner2/BasicTypes.h>
7#include <Rose/BinaryAnalysis/AddressIntervalSet.h>
9#include <Sawyer/IntervalMap.h>
10#include <Sawyer/IntervalSet.h>
11#include <Sawyer/Optional.h>
13#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
14#include <boost/serialization/access.hpp>
24namespace BinaryAnalysis {
25namespace Partitioner2 {
38 std::vector<BasicBlockPtr> bblocks_;
41#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
43 friend class boost::serialization::access;
44 template<
class S>
void serialize(S&,
const unsigned version);
142 operator bool()
const {
142 operator bool()
const {
…}
158 std::vector<AddressUser> users_;
160#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
162 friend class boost::serialization::access;
163 template<
class S>
void serialize(S&,
const unsigned version);
291 template<
class UserPredicate>
296 retval.users_.push_back(user);
375#ifdef ROSE_ENABLE_BOOST_SERIALIZATION
377 friend class boost::serialization::access;
378 template<
class S>
void serialize(S&,
const unsigned version);
548 template<
class UserPredicate>
554 retval = 0==nIters++ ? users : retval.
intersection(users);
573 template<
class UserPredicate>
577 retval.
insert(node.value().select(userPredicate));
608 void print(std::ostream&,
const std::string &prefix=
"")
const;
AddressIntervalSet unusedExtent(const AddressIntervalSet &) const
Addresses not represented.
SgAsmInstruction * eraseInstruction(SgAsmInstruction *, const BasicBlockPtr &)
Remove the specified instruction/basic block pair.
DataBlockPtr dataBlockExists(const DataBlockPtr &) const
Determines if a data block exists.
AddressUsers spanning(const AddressInterval &interval, UserPredicate userPredicate) const
Find address users that span the entire interval.
AddressUser insertDataBlock(const DataBlockPtr &)
Insert the data block.
bool anyExists(const AddressInterval &) const
Predicate to determine whether any of the specified addresses are used.
SgAsmInstruction * instructionExists(Address va) const
Determines whether the specified instruction or an equivalent exists.
bool anyExists(const AddressIntervalSet &) const
Predicate to determine whether any of the specified addresses are used.
void clear()
Reset map to initial empty state.
DataBlockPtr eraseDataBlock(const DataBlockPtr &)
Remove the specified data block.
AddressUser findInstruction(Address va) const
Find an AddressUser record for the specified instruction, or equivalent.
AddressUser findBasicBlock(Address va) const
Find an AddressUser record for the specified basic block, or equivalent.
AddressUsers containedIn(const AddressInterval &) const
Users that are fully contained in the interval.
AddressUsers spanning(const AddressInterval &) const
Find address users that span the entire interval.
AddressIntervalSet extent() const
Addresses represented.
Sawyer::Optional< Address > leastUnmapped(Address startVa) const
Returns the least unmapped address with specified lower limit.
BasicBlockPtr basicBlockExists(Address startOfBlock) const
Determine if a basic block exists.
void checkConsistency() const
Check invariants.
AddressUser findDataBlock(Address va, Address size) const
Find an AddressUser record for the specified data block, or equivalent.
AddressIntervalSet unusedExtent(const AddressInterval &) const
Addresses not represented.
AddressInterval hull() const
Minimum and maximum used addresses.
AddressUsers overlapping(const AddressInterval &interval, UserPredicate userPredicate) const
Users that overlap the interval.
AddressInterval nextUnused(Address minVa) const
Next unused address interval.
AddressUser findInstruction(SgAsmInstruction *) const
Find an AddressUser record for the specified instruction, or equivalent.
bool exists(Address) const
Predicate to determine whether an address is used.
AddressIntervalSet unusedExtent(size_t nBits) const
Addresses not represented.
bool isEmpty() const
Determines whether a map is empty.
BasicBlockPtr basicBlockExists(const BasicBlockPtr &) const
Determine if a basic block exists.
void print(std::ostream &, const std::string &prefix="") const
Dump the contents of this AUM to a stream.
AddressUsers overlapping(const AddressInterval &) const
Users that overlap the interval.
AddressUser findBasicBlock(const BasicBlockPtr &) const
Find an AddressUser record for the specified basic block, or equivalent.
SgAsmInstruction * instructionExists(SgAsmInstruction *) const
Determines whether the specified instruction or an equivalent exists.
AddressUser insertInstruction(SgAsmInstruction *, const BasicBlockPtr &)
Insert the instruction along with an owning basic block.
DataBlockPtr dataBlockExists(Address va, Address size) const
Determines if a data block exists.
AddressUser findDataBlock(const DataBlockPtr &) const
Find an AddressUser record for the specified data block, or equivalent.
size_t size() const
Number of addresses represented by the map.
bool operator==(const AddressUser &other) const
Compare two users for equality.
void insertBasicBlock(const BasicBlockPtr &bblock)
Add another basic block to the set of basic blocks.
Address address() const
Address of user.
bool isBasicBlock() const
Predicate returning true if user is a basic block or instruction.
AddressUser(SgAsmInstruction *, const BasicBlockPtr &)
Constructs new user which is an instruction and its basic block.
bool isConsistent() const
Perform logic consistency checks.
void eraseBasicBlock(const BasicBlockPtr &bblock)
Remove a basic block from the set of basic blocks.
BasicBlockPtr isBlockEntry() const
Determines if this user is a first instruction of a basic block.
void print(std::ostream &) const
Print the pair on one line.
bool isDataBlock() const
Predicate returning true if user is a data block.
bool isEmpty() const
True if this object was default constructed.
bool operator<(const AddressUser &) const
Compare two users for sorting.
const std::vector< BasicBlockPtr > & basicBlocks() const
Returns all basic blocks to which this instruction belongs.
DataBlockPtr dataBlock() const
Returns the data block.
SgAsmInstruction * insn() const
Return the instruction.
AddressUser(const DataBlockPtr &)
Constructs a new user which is a data block.
BasicBlockPtr firstBasicBlock() const
Returns an arbitrary basic block.
AddressUser()
Default constructed user is empty.
List of virtual address users.
DataBlockPtr dataBlockExists(Address va, Address size) const
Determines whether the specified data block or an equivalent exists.
std::vector< SgAsmInstruction * > instructions() const
Returns all instructions.
bool isEmpty() const
Determines whether this address user list is empty.
AddressUsers(SgAsmInstruction *insn, const BasicBlockPtr &)
Constructs a list having one instruction user.
BasicBlockPtr basicBlockExists(Address va) const
Determines whether the specified basic block or an equivalent exists.
AddressUsers union_(const AddressUsers &) const
Computes the union of this list with another.
std::vector< BasicBlockPtr > instructionOwners() const
Returns all basic blocks.
BasicBlockPtr basicBlockExists(const BasicBlockPtr &) const
Determines whether the specified basic block or an equivalent exists.
SgAsmInstruction * instructionExists(SgAsmInstruction *) const
Determines whether the specified instruction or an equivalent exists.
DataBlockPtr eraseDataBlock(const DataBlockPtr &)
Erase a data block from this list.
void insert(const AddressUsers &)
Insert one set of address users into another.
bool operator==(const AddressUsers &other) const
True if two lists are equal.
static bool selectBasicBlocks(const AddressUser &)
Selector to select instructions and basic blocks.
AddressUser findDataBlock(Address va, Address size) const
Find an AddressUser record for the specified data block, or equivalent.
static bool selectDataBlocks(const AddressUser &)
Selector to select data blocks.
const std::vector< AddressUser > & addressUsers() const
Return all address users.
AddressUsers intersection(const AddressUsers &) const
Computes the intersection of this list with another.
bool isConsistent() const
Check logical consistency.
size_t size() const
Number of address users.
SgAsmInstruction * eraseInstruction(SgAsmInstruction *, const BasicBlockPtr &)
Erase an instruction/basic block pair from this list.
AddressUser findBasicBlock(const BasicBlockPtr &) const
Find an AddressUser record for the specified basic block, or equivalent.
AddressUser findInstruction(Address va) const
Find an AddressUser record for the specified instruction, or equivalent.
AddressUser findBasicBlock(Address va) const
Find an AddressUser record for the specified basic block, or equivalent.
AddressUsers(const DataBlockPtr &)
Constructs a list having one data block user.
void print(std::ostream &) const
Prints pairs space separated on a single line.
AddressUser insertInstruction(SgAsmInstruction *, const BasicBlockPtr &)
Insert an instruction/basic block pair.
static bool selectAllUsers(const AddressUser &)
Selector to select all users.
AddressUser insertDataBlock(const DataBlockPtr &)
Insert a data block.
AddressUsers instructionUsers() const
Returns all instruction users.
AddressUsers select(UserPredicate predicate) const
Selects certain users from a list.
AddressUsers dataBlockUsers() const
Returns all data block users.
DataBlockPtr dataBlockExists(const DataBlockPtr &) const
Determines whether the specified data block or an equivalent exists.
std::vector< DataBlockPtr > dataBlocks() const
Returns all data blocks.
AddressUsers()
Constructs an empty list.
AddressUser findInstruction(SgAsmInstruction *) const
Find an AddressUser record for the specified instruction, or equivalent.
AddressUser findDataBlock(const DataBlockPtr &) const
Find an AddressUser record for the specified data block, or equivalent.
SgAsmInstruction * instructionExists(Address va) const
Determines whether the specified instruction or an equivalent exists.
boost::iterator_range< NodeIterator > findAll(const Interval &interval)
Finds all nodes overlapping the specified interval.
Holds a value or nothing.
Base class for machine instructions.
std::uint64_t Address
Address.