#include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Interfaces/SubsetOpInterface.h"
#include "llvm/Support/Debug.h"
#include <queue>
#define DEBUG_TYPE …
usingnamespacemlir;
static bool canBeHoisted(Operation *op,
function_ref<bool(OpOperand &)> condition) { … }
static bool canBeHoisted(Operation *op,
function_ref<bool(Value)> definedOutside) { … }
size_t mlir::moveLoopInvariantCode(
ArrayRef<Region *> regions,
function_ref<bool(Value, Region *)> isDefinedOutsideRegion,
function_ref<bool(Operation *, Region *)> shouldMoveOutOfRegion,
function_ref<void(Operation *, Region *)> moveOutOfRegion) { … }
size_t mlir::moveLoopInvariantCode(LoopLikeOpInterface loopLike) { … }
namespace {
class MatchingSubsets { … };
}
static OpOperand *getSingleTerminatorUse(Value value) { … }
LogicalResult
MatchingSubsets::populateSubsetOpsAtIterArg(LoopLikeOpInterface loopLike,
BlockArgument iterArg,
bool collectHoistableOps) { … }
static LoopLikeOpInterface hoistSubsetAtIterArg(RewriterBase &rewriter,
LoopLikeOpInterface loopLike,
BlockArgument iterArg) { … }
LoopLikeOpInterface
mlir::hoistLoopInvariantSubsets(RewriterBase &rewriter,
LoopLikeOpInterface loopLike) { … }