#include "mlir/Conversion/SCFToEmitC/SCFToEmitC.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/EmitC/IR/EmitC.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/Passes.h"
namespace mlir {
#define GEN_PASS_DEF_SCFTOEMITC
#include "mlir/Conversion/Passes.h.inc"
}
usingnamespacemlir;
usingnamespacemlir::scf;
namespace {
struct SCFToEmitCPass : public impl::SCFToEmitCBase<SCFToEmitCPass> { … };
struct ForLowering : public OpRewritePattern<ForOp> { … };
template <typename T>
static SmallVector<Value> createVariablesForResults(T op,
PatternRewriter &rewriter) { … }
static void assignValues(ValueRange values, SmallVector<Value> &variables,
PatternRewriter &rewriter, Location loc) { … }
SmallVector<Value> loadValues(const SmallVector<Value> &variables,
PatternRewriter &rewriter, Location loc) { … }
static void lowerYield(SmallVector<Value> &resultVariables,
PatternRewriter &rewriter, scf::YieldOp yield) { … }
static void lowerRegion(SmallVector<Value> &resultVariables,
PatternRewriter &rewriter, Region ®ion,
Region &loweredRegion) { … }
LogicalResult ForLowering::matchAndRewrite(ForOp forOp,
PatternRewriter &rewriter) const { … }
struct IfLowering : public OpRewritePattern<IfOp> { … };
}
LogicalResult IfLowering::matchAndRewrite(IfOp ifOp,
PatternRewriter &rewriter) const { … }
struct IndexSwitchOpLowering : public OpRewritePattern<IndexSwitchOp> { … };
LogicalResult
IndexSwitchOpLowering::matchAndRewrite(IndexSwitchOp indexSwitchOp,
PatternRewriter &rewriter) const { … }
void mlir::populateSCFToEmitCConversionPatterns(RewritePatternSet &patterns) { … }
void SCFToEmitCPass::runOnOperation() { … }