17#ifndef MLIR_REDUCER_REDUCTIONNODE_H
18#define MLIR_REDUCER_REDUCTIONNODE_H
25#include "llvm/ADT/ArrayRef.h"
26#include "llvm/Support/Allocator.h"
27#include "llvm/Support/ToolOutputFile.h"
45 template <TraversalMode mode>
48 using Range = std::pair<int, int>;
51 llvm::SpecificBumpPtrAllocator<ReductionNode> &allocator);
85 void update(std::pair<Tester::Interestingness, size_t>
result);
102 template <
typename T>
106 BaseIterator(
const BaseIterator &) =
default;
107 BaseIterator() =
default;
109 static BaseIterator end() {
return BaseIterator(); }
111 bool operator==(
const BaseIterator &i) {
112 return visitQueue == i.visitQueue;
114 bool operator!=(
const BaseIterator &i) {
return !(*
this == i); }
116 BaseIterator &operator++() {
120 visitQueue.push(node);
124 BaseIterator operator++(
int) {
125 BaseIterator tmp = *
this;
130 ReductionNode &operator*()
const {
return *(visitQueue.front()); }
131 ReductionNode *operator->()
const {
return visitQueue.front(); }
134 ArrayRef<ReductionNode *> getNeighbors(
ReductionNode *node) {
135 return static_cast<T *
>(
this)->getNeighbors(node);
139 std::queue<ReductionNode *> visitQueue;
144 OwningOpRef<ModuleOp> module;
147 Region *region =
nullptr;
169 std::vector<Range> ranges;
176 const std::vector<Range> startRanges;
180 std::vector<ReductionNode *> variants;
182 llvm::SpecificBumpPtrAllocator<ReductionNode> &allocator;
188 :
public BaseIterator<iterator<SinglePath>> {
189 friend BaseIterator<iterator<SinglePath>>;
190 using BaseIterator::BaseIterator;
ReductionTreePass will build a reduction tree during module reduction and the ReductionNode represent...
std::pair< int, int > Range
LogicalResult initialize(ModuleOp parentModule, Region &parentRegion)
Each Reduction Node contains a copy of module for applying rewrite patterns.
ReductionNode(ReductionNode *parent, const std::vector< Range > &range, llvm::SpecificBumpPtrAllocator< ReductionNode > &allocator)
Root node will have the parent pointer point to themselves.
ArrayRef< Range > getRanges() const
Return the range set we are using to generate variants.
size_t getSize() const
Return the size of the module.
ModuleOp getModule() const
If the ReductionNode hasn't been tested the interestingness, it'll be the same module as the one in t...
Region & getRegion() const
Return the region we're reducing.
Tester::Interestingness isInteresting() const
Returns true if the module exhibits the interesting behavior.
ArrayRef< ReductionNode * > generateNewVariants()
Split the ranges and generate new variants.
ArrayRef< ReductionNode * > getVariants() const
Return the generated variants(the child nodes).
ReductionNode * getParent() const
ArrayRef< Range > getStartRanges() const
Return the range information that how this node is reduced from the parent node.
void update(std::pair< Tester::Interestingness, size_t > result)
Update the interestingness result from tester.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Include the generated interface declarations.
TraversalMode
Defines the traversal method options to be used in the reduction tree traversal.