MLIR  19.0.0git
Namespaces | Macros | Functions
SCCP.cpp File Reference
#include "mlir/Transforms/Passes.h"
#include "mlir/Analysis/DataFlow/ConstantPropagationAnalysis.h"
#include "mlir/Analysis/DataFlow/DeadCodeAnalysis.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/Dialect.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/FoldUtils.h"
#include "mlir/Transforms/Passes.h.inc"

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Macros

#define GEN_PASS_DEF_SCCP
 

Functions

static LogicalResult replaceWithConstant (DataFlowSolver &solver, OpBuilder &builder, OperationFolder &folder, Value value)
 Replace the given value with a constant if the corresponding lattice represents a constant. More...
 
static void rewrite (DataFlowSolver &solver, MLIRContext *context, MutableArrayRef< Region > initialRegions)
 Rewrite the given regions using the computing analysis. More...
 

Macro Definition Documentation

◆ GEN_PASS_DEF_SCCP

#define GEN_PASS_DEF_SCCP

Definition at line 28 of file SCCP.cpp.

Function Documentation

◆ replaceWithConstant()

static LogicalResult replaceWithConstant ( DataFlowSolver solver,
OpBuilder builder,
OperationFolder folder,
Value  value 
)
static

Replace the given value with a constant if the corresponding lattice represents a constant.

Returns success if the value was replaced, failure otherwise.

Definition at line 42 of file SCCP.cpp.

References mlir::failure(), mlir::dataflow::ConstantValue::getConstantDialect(), mlir::dataflow::ConstantValue::getConstantValue(), mlir::OpBuilder::getInsertionBlock(), mlir::OperationFolder::getOrCreateConstant(), mlir::Value::getType(), mlir::DataFlowSolver::lookupState(), mlir::Value::replaceAllUsesWith(), and mlir::success().

◆ rewrite()

static void rewrite ( DataFlowSolver solver,
MLIRContext context,
MutableArrayRef< Region initialRegions 
)
static

Rewrite the given regions using the computing analysis.

This replaces the uses of all values that have been computed to be constant, and erases as many newly dead operations.

Definition at line 67 of file SCCP.cpp.

Referenced by mlir::detail::ConversionPatternRewriterImpl::applyRewrites(), checkAndNestUnderRewriteOp(), computeNecessaryMaterializations(), findSingleRewrite(), and mlir::detail::ConversionPatternRewriterImpl::undoRewrites().