The class ResourceSegments is used to keep track of the intervals
that represent resource usage of a collection of instruction that are
being scheduled by the machine scheduler.
The collection is made of intervals that are closed on the left and
open on the right (represented by the standard notation [a, b)).
These collection of intervals can be extended by adding new
intervals accordingly while scheduling a basic block.
Unit tests are added to verify the possible configurations of
intervals, and the relative possibility of scheduling a new
instruction in these configurations. Specifically, the methods
getFirstAvailableAtFromBottom and getFirstAvailableAtFromTop are
tested to make sure that both bottom-up and top-down scheduling work
when tracking resource usage across the basic block with
ResourceSegments.
Note that the scheduler tracks resource usage with two methods:
- counters (via std::vector<unsigned> ReservedCycles;);
- intervals (via std::map<unsigned, ResourceSegments> ReservedResourceSegments;).
This patch can be considered a NFC test for existing scheduling models
because the tracking system that uses intervals is turned off by
default (field bit EnableIntervals = false; in the tablegen class
SchedMachineModel).
#include "llvm/Support/raw_ostream.h" ?