20#include <unordered_map>
68 if (std::dynamic_pointer_cast<const ControlType>(input->
Type()))
110 observers_.emplace(®ion, std::make_unique<Observer>(region,
this));
120 std::unordered_map<Input *, PredicateValueRange> &
visitedInputs,
157 std::unordered_map<Input *, PredicateValueRange> &
visitedInputs,
165 auto origin = input.
origin();
178 return PredicateValueRange::CreateSingleValue(op.value());
182 return PredicateValueRange::CreateUnknown(type);
190 auto exitVar = node.MapOutputExitVar(*origin);
205 auto loopVar = node.MapOutputLoopVar(*origin);
233 return ComputeAndRecord(regionPredRange, *entry.input, visitedInputs, type);
237 return PredicateValueRange::CreateUnknown(type);
242 auto loopVar = node.MapPreLoopVar(*origin);
280 std::unordered_map<Input *, PredicateValueRange>
visitedInputs;
310 req.push_back(std::make_pair(node.predicate(), region.index()));
363 auto &
controlType = *util::assertedCast<const ControlType>(output.
Type().get());
374 auto exitVar = gamma->MapOutputExitVar(output);
377 for (
auto result :
exitVar.branchResult)
391 auto loopVar = theta->MapOutputLoopVar(output);
434 auto exitVar = gamma->MapOutputExitVar(output);
437 for (
auto result :
exitVar.branchResult)
450 auto loopVar = theta->MapOutputLoopVar(output);
476 auto key = std::make_pair(&output, value);
554 *gamma->predicate()->origin(),
bool markRequiredPredicateValueInternal(Output &output, size_t value, std::vector< Region * > &impossibleOrigins)
AlternativeRegionPredicateTracer()
bool markRequiredPredicateValue(Output &output, size_t value, std::vector< Region * > &impossibleOrigins)
std::unordered_map< std::pair< Output *, size_t >, std::vector< Region * >, util::Hash< std::pair< Output *, size_t > > > impossibleOriginRegions_
std::unordered_map< Output *, PredicateValueRange > predicateValueRanges_
PredicateValueRange getPossibleValuesInternal(Output &output)
bool canCurrentOriginSatisfyRequirement(Output &output, size_t value)
bool isReachableFromRegion(Region &targetRegion, Region &originRegion)
PredicateValueRange & getPossibleValues(Output &output)
util::HashSet< Region * > currentOriginRegionAncestors_
Conditional operator / pattern matching.
std::variant< MatchVar, EntryVar > MapBranchArgument(const rvsdg::Output &output) const
Maps branch subregion entry argument to its role (pattern match or entry variable).
rvsdg::Region * region() const noexcept
rvsdg::Region * region() const noexcept
const std::shared_ptr< const rvsdg::Type > & Type() const noexcept
Value range for a predicate.
static PredicateValueRange CreateEmpty(const ControlType &type)
Constructs empty value range (unsatisfiable predicate range).
static PredicateValueRange CreateSingleValue(const ControlValueRepresentation &value)
Definite value range (exactly one value possible).
static PredicateValueRange CreateUnknown(const ControlType &type)
Constructs full value range (every value possible).
Proxy object to observe changes to a region.
Observer(const Region ®ion, RegionPredicateTrace *tracer)
RegionPredicateTrace * tracer_
void onInputCreate(Input *input) override
void onNodeDestroy(Node *node) override
void onNodeCreate(Node *node) override
void onInputChange(Input *input, Output *, Output *) override
void onInputDestroy(Input *input) override
Traces region reachability by predicate assertions.
PredicateValueRange GetRegionPredicateAssignConstraints(Region ®ion, Input &predUse)
Computes value range for a predicate when exiting a region.
PredicateSatRequired GetRegionSatRequired(Region ®ion)
Computes required predicate assignments for region.
std::unordered_map< Region *, PredicateSatRequired > predSat_
bool CheckPredicatesSatisfiable(Region &originRegion, Region &targetRegion)
Checks for dynamic reachability between two regions.
void ObserveRegion(Region ®ion)
PredicateValueRange Compute(RegionPredRange ®ionPredRange, Input &input, std::unordered_map< Input *, PredicateValueRange > &visitedInputs, const ControlType &type)
const PredicateValueRange & ComputeAndRecord(RegionPredRange ®ionPredRange, Input &input, std::unordered_map< Input *, PredicateValueRange > &visitedInputs, const ControlType &type)
std::unordered_map< Region *, PredicateValueRange > RegionPredRange
std::unordered_map< Input *, RegionPredRange > predAssignment_
std::unordered_map< Region *, std::unique_ptr< Observer > > observers_
Represent acyclic RVSDG subgraphs.
rvsdg::StructuralNode * node() const noexcept
const SimpleOperation & GetOperation() const noexcept override
void MatchTypeWithDefault(T &obj, const Fns &... fns)
Pattern match over subclass type of given object with default handler.
void MatchType(T &obj, const Fns &... fns)
Pattern match over subclass type of given object.
decltype(auto) MatchVariant(T &&obj, Fns &&... fns)
Pattern match over variant.
Output & traceOutputIntraProcedurally(Output &output, bool mayEnterSubregions)
NodeType * TryGetOwnerNode(const rvsdg::Input &input) noexcept
Checks if this is an input to a node of specified type.
std::vector< std::pair< Input *, std::size_t > > PredicateSatRequired
Describes which predicates need to be satisfied.
A variable routed into all gamma regions.
The match/discriminator variable of this gamma node.