[mlir] Rename the Standard dialect to the Func dialect
The last remaining operations in the standard dialect all revolve around FuncOp/function related constructs. This patch simply handles the initial renaming (which by itself is already huge), but there are a large number of cleanups unlocked/necessary afterwards: * Removing a bunch of unnecessary dependencies on Func * Cleaning up the From/ToStandard conversion passes * Preparing for the move of FuncOp to the Func dialect See the discussion at https://discourse.llvm.org/t/standard-dialect-the-final-chapter/6061 Differential Revision: https://reviews.llvm.org/D120624
This commit is contained in:
parent
9bf6e3e97e
commit
23aa5a7446
|
@ -16,7 +16,7 @@
|
|||
#include "flang/Common/indirection.h"
|
||||
#include "flang/Parser/char-block.h"
|
||||
#include "flang/Semantics/tools.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <cstdint>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "flang/Optimizer/Dialect/FIROps.h"
|
||||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
|
||||
namespace mlir {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_CHARACTER_H
|
||||
#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_CHARACTER_H
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
namespace fir {
|
||||
class ExtendedValue;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_NUMERIC_H
|
||||
#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_NUMERIC_H
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
namespace fir {
|
||||
class ExtendedValue;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_REDUCTION_H
|
||||
#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_REDUCTION_H
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
namespace fir {
|
||||
class ExtendedValue;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_TRANSFORMATIONAL_H
|
||||
#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_TRANSFORMATIONAL_H
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
namespace fir {
|
||||
class ExtendedValue;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
include "mlir/IR/OpBase.td"
|
||||
include "mlir/Dialect/Arithmetic/IR/ArithmeticOps.td"
|
||||
include "mlir/Dialect/StandardOps/IR/Ops.td"
|
||||
include "flang/Optimizer/Dialect/FIROps.td"
|
||||
|
||||
def IdenticalTypePred : Constraint<CPred<"$0.getType() == $1.getType()">>;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Interfaces/LoopLikeInterface.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#define FORTRAN_OPTIMIZER_DIALECT_FIROPSSUPPORT_H
|
||||
|
||||
#include "flang/Optimizer/Dialect/FIROps.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
|
||||
namespace fir {
|
||||
|
@ -25,7 +25,7 @@ inline bool nonVolatileLoad(mlir::Operation *op) {
|
|||
/// return true iff the Operation is a call
|
||||
inline bool isaCall(mlir::Operation *op) {
|
||||
return isa<fir::CallOp>(op) || isa<fir::DispatchOp>(op) ||
|
||||
isa<mlir::CallOp>(op) || isa<mlir::CallIndirectOp>(op);
|
||||
isa<mlir::func::CallOp>(op) || isa<mlir::func::CallIndirectOp>(op);
|
||||
}
|
||||
|
||||
/// return true iff the Operation is a fir::CallOp, fir::DispatchOp,
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace fir::support {
|
|||
mlir::AffineDialect, FIROpsDialect, mlir::acc::OpenACCDialect, \
|
||||
mlir::omp::OpenMPDialect, mlir::scf::SCFDialect, \
|
||||
mlir::arith::ArithmeticDialect, mlir::cf::ControlFlowDialect, \
|
||||
mlir::StandardOpsDialect, mlir::vector::VectorDialect
|
||||
mlir::func::FuncDialect, mlir::vector::VectorDialect
|
||||
|
||||
// The definitive list of dialects used by flang.
|
||||
#define FLANG_DIALECT_LIST \
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "flang/Common/default-kinds.h"
|
||||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
|
||||
namespace fir {
|
||||
|
|
|
@ -25,7 +25,7 @@ def AbstractResultOpt : Pass<"abstract-result-opt", "mlir::FuncOp"> {
|
|||
}];
|
||||
let constructor = "::fir::createAbstractResultOptPass()";
|
||||
let dependentDialects = [
|
||||
"fir::FIROpsDialect", "mlir::StandardOpsDialect"
|
||||
"fir::FIROpsDialect", "mlir::func::FuncDialect"
|
||||
];
|
||||
let options = [
|
||||
Option<"passResultAsBox", "abstract-result-as-box",
|
||||
|
@ -56,7 +56,7 @@ def AffineDialectPromotion : Pass<"promote-to-affine", "::mlir::FuncOp"> {
|
|||
}];
|
||||
let constructor = "::fir::createPromoteToAffinePass()";
|
||||
let dependentDialects = [
|
||||
"fir::FIROpsDialect", "mlir::StandardOpsDialect", "mlir::AffineDialect"
|
||||
"fir::FIROpsDialect", "mlir::func::FuncDialect", "mlir::AffineDialect"
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ def AffineDialectDemotion : Pass<"demote-affine", "::mlir::FuncOp"> {
|
|||
}];
|
||||
let constructor = "::fir::createAffineDemotionPass()";
|
||||
let dependentDialects = [
|
||||
"fir::FIROpsDialect", "mlir::StandardOpsDialect", "mlir::AffineDialect"
|
||||
"fir::FIROpsDialect", "mlir::func::FuncDialect", "mlir::AffineDialect"
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ def CFGConversion : Pass<"cfg-conversion", "::mlir::FuncOp"> {
|
|||
}];
|
||||
let constructor = "::fir::createFirToCfgPass()";
|
||||
let dependentDialects = [
|
||||
"fir::FIROpsDialect", "mlir::StandardOpsDialect"
|
||||
"fir::FIROpsDialect", "mlir::func::FuncDialect"
|
||||
];
|
||||
let options = [
|
||||
Option<"forceLoopToExecuteOnce", "always-execute-loop-body", "bool",
|
||||
|
@ -148,7 +148,7 @@ def MemRefDataFlowOpt : Pass<"fir-memref-dataflow-opt", "::mlir::FuncOp"> {
|
|||
}];
|
||||
let constructor = "::fir::createMemDataFlowOptPass()";
|
||||
let dependentDialects = [
|
||||
"fir::FIROpsDialect", "mlir::StandardOpsDialect"
|
||||
"fir::FIROpsDialect", "mlir::func::FuncDialect"
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -427,7 +427,7 @@ private:
|
|||
/// Generate the cleanup block before the program exits
|
||||
void genExitRoutine() {
|
||||
if (blockIsUnterminated())
|
||||
builder->create<mlir::ReturnOp>(toLocation());
|
||||
builder->create<mlir::func::ReturnOp>(toLocation());
|
||||
}
|
||||
void genFIR(const Fortran::parser::EndProgramStmt &) { genExitRoutine(); }
|
||||
|
||||
|
@ -459,7 +459,7 @@ private:
|
|||
TODO(loc, "Convert to actual type");
|
||||
return builder->create<fir::LoadOp>(loc, resultRef);
|
||||
});
|
||||
builder->create<mlir::ReturnOp>(loc, resultVal);
|
||||
builder->create<mlir::func::ReturnOp>(loc, resultVal);
|
||||
}
|
||||
|
||||
void genFIRProcedureExit(Fortran::lower::pft::FunctionLikeUnit &funit,
|
||||
|
|
|
@ -37,9 +37,9 @@ add_flang_library(FortranLower
|
|||
FortranEvaluate
|
||||
FortranSemantics
|
||||
MLIRAffineToStandard
|
||||
MLIRFunc
|
||||
MLIRLLVMIR
|
||||
MLIRSCFToControlFlow
|
||||
MLIRStandard
|
||||
|
||||
LINK_COMPONENTS
|
||||
Support
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "flang/Semantics/symbol.h"
|
||||
#include "flang/Semantics/tools.h"
|
||||
#include "flang/Semantics/type.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
|
||||
#define DEBUG_TYPE "flang-lower-expr"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "flang/Optimizer/Builder/FIRBuilder.h"
|
||||
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
|
||||
#include "flang/Runtime/character.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
using namespace Fortran::runtime;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "flang/Optimizer/Builder/FIRBuilder.h"
|
||||
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
|
||||
#include "flang/Runtime/numeric.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
using namespace Fortran::runtime;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "flang/Optimizer/Builder/FIRBuilder.h"
|
||||
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
|
||||
#include "flang/Runtime/reduction.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
using namespace Fortran::runtime;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
|
||||
#include "flang/Runtime/matmul.h"
|
||||
#include "flang/Runtime/transformational.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
using namespace Fortran::runtime;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#define OPTIMIZER_CODEGEN_CGOPS_H
|
||||
|
||||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
|
|
|
@ -262,7 +262,7 @@ public:
|
|||
mlir::OpBuilder rewriter(&context);
|
||||
mlir::ConversionTarget target(context);
|
||||
target.addLegalDialect<mlir::arith::ArithmeticDialect, FIROpsDialect,
|
||||
FIRCodeGenDialect, mlir::StandardOpsDialect>();
|
||||
FIRCodeGenDialect, mlir::func::FuncDialect>();
|
||||
target.addIllegalOp<ArrayCoorOp>();
|
||||
target.addIllegalOp<ReboxOp>();
|
||||
target.addDynamicallyLegalOp<EmboxOp>([](EmboxOp embox) {
|
||||
|
|
|
@ -599,20 +599,20 @@ public:
|
|||
auto newArg = func.front().insertArgument(fixup.index,
|
||||
newInTys[fixup.index], loc);
|
||||
offset++;
|
||||
func.walk([&](mlir::ReturnOp ret) {
|
||||
func.walk([&](mlir::func::ReturnOp ret) {
|
||||
rewriter->setInsertionPoint(ret);
|
||||
auto oldOper = ret.getOperand(0);
|
||||
auto oldOperTy = ReferenceType::get(oldOper.getType());
|
||||
auto cast = rewriter->create<ConvertOp>(loc, oldOperTy, newArg);
|
||||
rewriter->create<fir::StoreOp>(loc, oldOper, cast);
|
||||
rewriter->create<mlir::ReturnOp>(loc);
|
||||
rewriter->create<mlir::func::ReturnOp>(loc);
|
||||
ret.erase();
|
||||
});
|
||||
} break;
|
||||
case FixupTy::Codes::ReturnType: {
|
||||
// The function is still returning a value, but its type has likely
|
||||
// changed to suit the target ABI convention.
|
||||
func.walk([&](mlir::ReturnOp ret) {
|
||||
func.walk([&](mlir::func::ReturnOp ret) {
|
||||
rewriter->setInsertionPoint(ret);
|
||||
auto oldOper = ret.getOperand(0);
|
||||
auto oldOperTy = ReferenceType::get(oldOper.getType());
|
||||
|
@ -621,7 +621,7 @@ public:
|
|||
auto cast = rewriter->create<ConvertOp>(loc, oldOperTy, mem);
|
||||
rewriter->create<fir::StoreOp>(loc, oldOper, cast);
|
||||
mlir::Value load = rewriter->create<fir::LoadOp>(loc, mem);
|
||||
rewriter->create<mlir::ReturnOp>(loc, load);
|
||||
rewriter->create<mlir::func::ReturnOp>(loc, load);
|
||||
ret.erase();
|
||||
});
|
||||
} break;
|
||||
|
|
|
@ -42,7 +42,7 @@ struct FIRInlinerInterface : public mlir::DialectInlinerInterface {
|
|||
/// return.
|
||||
void handleTerminator(mlir::Operation *op,
|
||||
llvm::ArrayRef<mlir::Value> valuesToRepl) const final {
|
||||
auto returnOp = cast<mlir::ReturnOp>(op);
|
||||
auto returnOp = cast<mlir::func::ReturnOp>(op);
|
||||
assert(returnOp.getNumOperands() == valuesToRepl.size());
|
||||
for (const auto &it : llvm::enumerate(returnOp.getOperands()))
|
||||
valuesToRepl[it.index()].replaceAllUsesWith(it.value());
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "flang/Optimizer/Support/Utils.h"
|
||||
#include "mlir/Dialect/CommonFolders.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "flang/Optimizer/Dialect/FIROps.h"
|
||||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "flang/Optimizer/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
|
@ -149,14 +149,14 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class ReturnOpConversion : public mlir::OpRewritePattern<mlir::ReturnOp> {
|
||||
class ReturnOpConversion : public mlir::OpRewritePattern<mlir::func::ReturnOp> {
|
||||
public:
|
||||
using OpRewritePattern::OpRewritePattern;
|
||||
ReturnOpConversion(mlir::MLIRContext *context,
|
||||
const AbstractResultOptions &opt)
|
||||
: OpRewritePattern(context), options{opt} {}
|
||||
mlir::LogicalResult
|
||||
matchAndRewrite(mlir::ReturnOp ret,
|
||||
matchAndRewrite(mlir::func::ReturnOp ret,
|
||||
mlir::PatternRewriter &rewriter) const override {
|
||||
rewriter.setInsertionPoint(ret);
|
||||
auto returnedValue = ret.getOperand(0);
|
||||
|
@ -177,7 +177,7 @@ public:
|
|||
if (!replacedStorage)
|
||||
rewriter.create<fir::StoreOp>(ret.getLoc(), returnedValue,
|
||||
options.newArg);
|
||||
rewriter.replaceOpWithNewOp<mlir::ReturnOp>(ret);
|
||||
rewriter.replaceOpWithNewOp<mlir::func::ReturnOp>(ret);
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
|
@ -239,8 +239,8 @@ public:
|
|||
rewriter.create<fir::BoxAddrOp>(loc, bufferType, options.newArg);
|
||||
}
|
||||
patterns.insert<ReturnOpConversion>(context, options);
|
||||
target.addDynamicallyLegalOp<mlir::ReturnOp>(
|
||||
[](mlir::ReturnOp ret) { return ret.operands().empty(); });
|
||||
target.addDynamicallyLegalOp<mlir::func::ReturnOp>(
|
||||
[](mlir::func::ReturnOp ret) { return ret.operands().empty(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ public:
|
|||
|
||||
// Convert the calls and, if needed, the ReturnOp in the function body.
|
||||
target.addLegalDialect<fir::FIROpsDialect, mlir::arith::ArithmeticDialect,
|
||||
mlir::StandardOpsDialect>();
|
||||
mlir::func::FuncDialect>();
|
||||
target.addIllegalOp<fir::SaveResultOp>();
|
||||
target.addDynamicallyLegalOp<fir::CallOp>([](fir::CallOp call) {
|
||||
return !mustConvertCallOrFunc(call.getFunctionType());
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#include "flang/Optimizer/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Affine/Utils.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/SCF/SCF.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/IntegerSet.h"
|
||||
#include "mlir/IR/Visitors.h"
|
||||
|
@ -158,7 +158,7 @@ public:
|
|||
});
|
||||
target.addLegalDialect<FIROpsDialect, mlir::scf::SCFDialect,
|
||||
mlir::arith::ArithmeticDialect,
|
||||
mlir::StandardOpsDialect>();
|
||||
mlir::func::FuncDialect>();
|
||||
|
||||
if (mlir::failed(mlir::applyPartialConversion(function, target,
|
||||
std::move(patterns)))) {
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "flang/Optimizer/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/SCF/SCF.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/IntegerSet.h"
|
||||
#include "mlir/IR/Visitors.h"
|
||||
|
@ -595,7 +595,7 @@ public:
|
|||
mlir::ConversionTarget target = *context;
|
||||
target.addLegalDialect<
|
||||
mlir::AffineDialect, FIROpsDialect, mlir::scf::SCFDialect,
|
||||
mlir::arith::ArithmeticDialect, mlir::StandardOpsDialect>();
|
||||
mlir::arith::ArithmeticDialect, mlir::func::FuncDialect>();
|
||||
target.addDynamicallyLegalOp<IfOp>([&functionAnalysis](fir::IfOp op) {
|
||||
return !(functionAnalysis.getChildIfAnalysis(op).canPromoteToAffine());
|
||||
});
|
||||
|
|
|
@ -792,7 +792,7 @@ public:
|
|||
mlir::ConversionTarget target(*context);
|
||||
target.addLegalDialect<
|
||||
FIROpsDialect, mlir::scf::SCFDialect, mlir::arith::ArithmeticDialect,
|
||||
mlir::cf::ControlFlowDialect, mlir::StandardOpsDialect>();
|
||||
mlir::cf::ControlFlowDialect, mlir::func::FuncDialect>();
|
||||
target.addIllegalOp<ArrayFetchOp, ArrayUpdateOp, ArrayModifyOp>();
|
||||
// Rewrite the array fetch and array update ops.
|
||||
if (mlir::failed(
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "flang/Optimizer/Support/FIRContext.h"
|
||||
#include "flang/Optimizer/Support/KindMapping.h"
|
||||
#include "flang/Optimizer/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
mlir::ConversionTarget target(*context);
|
||||
target.addLegalDialect<mlir::AffineDialect, fir::FIROpsDialect,
|
||||
mlir::arith::ArithmeticDialect,
|
||||
mlir::StandardOpsDialect>();
|
||||
mlir::func::FuncDialect>();
|
||||
|
||||
// apply the patterns
|
||||
target.addIllegalOp<fir::CharConvertOp>();
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "flang/Optimizer/Dialect/FIROps.h"
|
||||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "flang/Optimizer/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/Dominance.h"
|
||||
#include "mlir/IR/Operation.h"
|
||||
#include "mlir/Transforms/Passes.h"
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "flang/Optimizer/Dialect/FIROps.h"
|
||||
#include "flang/Optimizer/Dialect/FIRType.h"
|
||||
#include "flang/Optimizer/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
if (auto func = mlir::dyn_cast<mlir::FuncOp>(op))
|
||||
for (mlir::Block &block : func)
|
||||
for (mlir::Operation &i : block)
|
||||
if (mlir::isa<mlir::ReturnOp>(i)) {
|
||||
if (mlir::isa<mlir::func::ReturnOp>(i)) {
|
||||
returnMap[op].push_back(&i);
|
||||
break;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
const auto &analysis = getAnalysis<ReturnAnalysis>();
|
||||
|
||||
target.addLegalDialect<fir::FIROpsDialect, mlir::arith::ArithmeticDialect,
|
||||
mlir::StandardOpsDialect>();
|
||||
mlir::func::FuncDialect>();
|
||||
target.addDynamicallyLegalOp<fir::AllocaOp>([&](fir::AllocaOp alloca) {
|
||||
return keepStackAllocation(alloca, &func.front(), options);
|
||||
});
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
|
||||
#include "flang/Optimizer/Dialect/FIRDialect.h"
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
||||
#include "mlir/Dialect/OpenACC/OpenACC.h"
|
||||
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Pass/PassRegistry.h"
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "flang/Optimizer/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
@ -304,7 +304,7 @@ public:
|
|||
context, forceLoopToExecuteOnce);
|
||||
mlir::ConversionTarget target(*context);
|
||||
target.addLegalDialect<mlir::AffineDialect, mlir::cf::ControlFlowDialect,
|
||||
FIROpsDialect, mlir::StandardOpsDialect>();
|
||||
FIROpsDialect, mlir::func::FuncDialect>();
|
||||
|
||||
// apply the patterns
|
||||
target.addIllegalOp<ResultOp, DoLoopOp, IfOp, IterWhileOp>();
|
||||
|
|
|
@ -6,9 +6,9 @@ import mlir.all_passes_registration
|
|||
from mlir import ir
|
||||
from mlir.dialects import arith
|
||||
from mlir.dialects import builtin
|
||||
from mlir.dialects import func
|
||||
from mlir.dialects import memref
|
||||
from mlir.dialects import scf
|
||||
from mlir.dialects import std
|
||||
from mlir.passmanager import PassManager
|
||||
|
||||
|
||||
|
@ -93,15 +93,15 @@ def emit_benchmark_wrapped_main_func(func, timer_func):
|
|||
iter_args = list(wrapped_func.arguments[-num_results - 1:-1])
|
||||
loop = scf.ForOp(zero, n_iterations, one, iter_args)
|
||||
with ir.InsertionPoint(loop.body):
|
||||
start = std.CallOp(timer_func, [])
|
||||
call = std.CallOp(
|
||||
start = func.CallOp(timer_func, [])
|
||||
call = func.CallOp(
|
||||
func,
|
||||
wrapped_func.arguments[:-num_results - 1] + loop.inner_iter_args
|
||||
)
|
||||
end = std.CallOp(timer_func, [])
|
||||
end = func.CallOp(timer_func, [])
|
||||
time_taken = arith.SubIOp(end, start)
|
||||
memref.StoreOp(time_taken, timer_buffer, [loop.induction_variable])
|
||||
scf.YieldOp(list(call.results))
|
||||
std.ReturnOp(loop)
|
||||
func.ReturnOp(loop)
|
||||
|
||||
return wrapped_func
|
||||
|
|
|
@ -885,16 +885,16 @@ Each dialect with a mapping to python requires that an appropriate
|
|||
`_{DIALECT_NAMESPACE}_ops_gen.py` wrapper module is created. This is done by
|
||||
invoking `mlir-tblgen` on a python-bindings specific tablegen wrapper that
|
||||
includes the boilerplate and actual dialect specific `td` file. An example, for
|
||||
the `StandardOps` (which is assigned the namespace `std` as a special case):
|
||||
the `Func` (which is assigned the namespace `func` as a special case):
|
||||
|
||||
```tablegen
|
||||
#ifndef PYTHON_BINDINGS_STANDARD_OPS
|
||||
#define PYTHON_BINDINGS_STANDARD_OPS
|
||||
#ifndef PYTHON_BINDINGS_FUNC_OPS
|
||||
#define PYTHON_BINDINGS_FUNC_OPS
|
||||
|
||||
include "mlir/Bindings/Python/Attributes.td"
|
||||
include "mlir/Dialect/StandardOps/IR/Ops.td"
|
||||
include "mlir/Dialect/Func/IR/FuncOps.td"
|
||||
|
||||
#endif
|
||||
#endif // PYTHON_BINDINGS_FUNC_OPS
|
||||
```
|
||||
|
||||
In the main repository, building the wrapper is done via the CMake function
|
||||
|
|
|
@ -169,7 +169,7 @@ struct TensorBufferizePass : public TensorBufferizeBase<TensorBufferizePass> {
|
|||
|
||||
populateTensorBufferizePatterns(typeConverter, patterns);
|
||||
target.addIllegalOp<tensor::CastOp, tensor::ExtractOp>();
|
||||
target.addLegalDialect<StandardOpsDialect>();
|
||||
target.addLegalDialect<func::FuncDialect>();
|
||||
|
||||
if (failed(
|
||||
applyPartialConversion(getOperation(), target, std::move(patterns))))
|
||||
|
|
|
@ -100,9 +100,9 @@ struct MyTarget : public ConversionTarget {
|
|||
/// constraints.
|
||||
addDynamicallyLegalDialect<AffineDialect>([](Operation *op) { ... });
|
||||
|
||||
/// Mark `std.return` as dynamically legal, but provide a specific legality
|
||||
/// Mark `func.return` as dynamically legal, but provide a specific legality
|
||||
/// callback.
|
||||
addDynamicallyLegalOp<ReturnOp>([](ReturnOp op) { ... });
|
||||
addDynamicallyLegalOp<func::ReturnOp>([](func::ReturnOp op) { ... });
|
||||
|
||||
/// Treat unknown operations, i.e. those without a legalization action
|
||||
/// directly set, as dynamically legal.
|
||||
|
@ -424,15 +424,15 @@ Example output is shown below:
|
|||
|
||||
```
|
||||
//===-------------------------------------------===//
|
||||
Legalizing operation : 'std.return'(0x608000002e20) {
|
||||
"std.return"() : () -> ()
|
||||
Legalizing operation : 'func.return'(0x608000002e20) {
|
||||
"func.return"() : () -> ()
|
||||
|
||||
* Fold {
|
||||
} -> FAILURE : unable to fold
|
||||
|
||||
* Pattern : 'std.return -> ()' {
|
||||
* Pattern : 'func.return -> ()' {
|
||||
** Insert : 'spv.Return'(0x6070000453e0)
|
||||
** Replace : 'std.return'(0x608000002e20)
|
||||
** Replace : 'func.return'(0x608000002e20)
|
||||
|
||||
//===-------------------------------------------===//
|
||||
Legalizing operation : 'spv.Return'(0x6070000453e0) {
|
||||
|
@ -445,8 +445,8 @@ Legalizing operation : 'std.return'(0x608000002e20) {
|
|||
//===-------------------------------------------===//
|
||||
```
|
||||
|
||||
This output is describing the legalization of an `std.return` operation. We
|
||||
This output is describing the legalization of an `func.return` operation. We
|
||||
first try to legalize by folding the operation, but that is unsuccessful for
|
||||
`std.return`. From there, a pattern is applied that replaces the `std.return`
|
||||
`func.return`. From there, a pattern is applied that replaces the `func.return`
|
||||
with a `spv.Return`. The newly generated `spv.Return` is then processed for
|
||||
legalization, but is found to already legal as per the target.
|
||||
|
|
|
@ -66,7 +66,7 @@ argument for an op with trait `AffineScope` (eg. `FuncOp`), 2. a value defined
|
|||
at the top level of an `AffineScope` op (i.e., immediately enclosed by the
|
||||
latter), 3. a value that dominates the `AffineScope` op enclosing the value's
|
||||
use, 4. the result of a
|
||||
[`constant` operation](Standard.md/#stdconstant-constantop), 5. the result of an
|
||||
constant operation, 5. the result of an
|
||||
[`affine.apply` operation](#affineapply-affineapplyop) that recursively takes as
|
||||
arguments any valid symbolic identifiers, or 6. the result of a
|
||||
[`dim` operation](MemRef.md/#memrefdim-mlirmemrefdimop) on either a memref that
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
# 'func' Dialect
|
||||
|
||||
This dialect provides documentation for operations within the Func dialect.
|
||||
|
||||
This dialect contains operations surrounding high order function
|
||||
abstractions, such as calls.
|
||||
|
||||
**Please post an RFC on the [forum](https://llvm.discourse.group/c/mlir/31)
|
||||
before adding or changing any operation in this dialect.**
|
||||
|
||||
[TOC]
|
||||
|
||||
## Operations
|
||||
|
||||
[include "Dialects/FuncOps.md"]
|
|
@ -1,15 +0,0 @@
|
|||
# 'std' Dialect
|
||||
|
||||
This dialect provides documentation for operations within the Standard dialect.
|
||||
|
||||
Note: This dialect is a collection of operations for several different concepts,
|
||||
and should be split into multiple more-focused dialects accordingly.
|
||||
|
||||
**Please post an RFC on the [forum](https://llvm.discourse.group/c/mlir/31)
|
||||
before adding or changing any operation in this dialect.**
|
||||
|
||||
[TOC]
|
||||
|
||||
## Operations
|
||||
|
||||
[include "Dialects/StandardOps.md"]
|
|
@ -99,7 +99,7 @@ Some existing Standard and Vector Dialect on `n-D` `vector` types comprise:
|
|||
|
||||
```mlir
|
||||
%2 = arith.addf %0, %1 : vector<3x7x8xf32> // -> vector<3x7x8xf32> %2 =
|
||||
arith.mulf %0, %1 : vector<3x7x8xf32> // -> vector<3x7x8xf32> %2 = std.splat
|
||||
arith.mulf %0, %1 : vector<3x7x8xf32> // -> vector<3x7x8xf32> %2 = vector.splat
|
||||
%1 : vector<3x7x8xf32> // -> vector<3x7x8xf32>
|
||||
|
||||
%1 = vector.extract %0[1]: vector<3x7x8xf32> // -> vector<7x8xf32> %1 =
|
||||
|
|
|
@ -26,10 +26,10 @@ translating the following operations:
|
|||
* 'cf' Dialect
|
||||
* `cf.br`
|
||||
* `cf.cond_br`
|
||||
* 'std' Dialect
|
||||
* `std.call`
|
||||
* `std.constant`
|
||||
* `std.return`
|
||||
* 'func' Dialect
|
||||
* `func.call`
|
||||
* `func.constant`
|
||||
* `func.return`
|
||||
* 'scf' Dialect
|
||||
* `scf.for`
|
||||
* `scf.if`
|
||||
|
|
|
@ -256,10 +256,10 @@ between, and within, different dialects.
|
|||
A few of the dialects supported by MLIR:
|
||||
|
||||
* [Affine dialect](Dialects/Affine.md)
|
||||
* [Func dialect](Dialects/Func.md)
|
||||
* [GPU dialect](Dialects/GPU.md)
|
||||
* [LLVM dialect](Dialects/LLVM.md)
|
||||
* [SPIR-V dialect](Dialects/SPIR-V.md)
|
||||
* [Standard dialect](Dialects/Standard.md)
|
||||
* [Vector dialect](Dialects/Vector.md)
|
||||
|
||||
### Target specific operations
|
||||
|
|
|
@ -861,7 +861,7 @@ The `elements` of an optional group have the following requirements:
|
|||
- All region variables can be used. When a non-variable length region is
|
||||
used, if the group is not present the region is empty.
|
||||
|
||||
An example of an operation with an optional group is `std.return`, which has a
|
||||
An example of an operation with an optional group is `func.return`, which has a
|
||||
variadic number of operands.
|
||||
|
||||
```tablegen
|
||||
|
|
|
@ -28,6 +28,10 @@ This document describes the available MLIR passes and their contracts.
|
|||
|
||||
[include "ArithmeticPasses.md"]
|
||||
|
||||
## `func` Dialect Passes
|
||||
|
||||
[include "FuncPasses.md"]
|
||||
|
||||
## `gpu` Dialect Passes
|
||||
|
||||
[include "GPUPasses.md"]
|
||||
|
@ -68,10 +72,6 @@ This document describes the available MLIR passes and their contracts.
|
|||
|
||||
[include "SPIRVPasses.md"]
|
||||
|
||||
## `standard` Dialect Passes
|
||||
|
||||
[include "StandardPasses.md"]
|
||||
|
||||
## `tensor` Dialect Passes
|
||||
|
||||
[include "TensorPasses.md"]
|
||||
|
|
|
@ -33,7 +33,7 @@ result value, and may be referred to by other operations to provide a symbolic
|
|||
link, or use, to the symbol. An example of a `Symbol` operation is
|
||||
[`builtin.func`](Dialects/Builtin.md/#func-mlirfuncop). `builtin.func` defines a
|
||||
symbol name, which is [referred to](#referencing-a-symbol) by operations like
|
||||
[`std.call`](Dialects/Standard.md/#stdcall-callop).
|
||||
[`func.call`](Dialects/Func.md/#funccall-callop).
|
||||
|
||||
### Defining or declaring a Symbol
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ individual scalar arguments.
|
|||
|
||||
Examples:
|
||||
|
||||
This convention is implemented in the conversion of `std.func` and `std.call` to
|
||||
This convention is implemented in the conversion of `builtin.func` and `func.call` to
|
||||
the LLVM dialect, with the former unpacking the descriptor into a set of
|
||||
individual values and the latter packing those values back into a descriptor so
|
||||
as to make it transparently usable by other operations. Conversions from other
|
||||
|
@ -481,7 +481,7 @@ be returned from a function, the ranked descriptor it points to is copied into
|
|||
dynamically allocated memory, and the pointer in the unranked descriptor is
|
||||
updated accordingly. The allocation happens immediately before returning. It is
|
||||
the responsibility of the caller to free the dynamically allocated memory. The
|
||||
default conversion of `std.call` and `std.call_indirect` copies the ranked
|
||||
default conversion of `func.call` and `func.call_indirect` copies the ranked
|
||||
descriptor to newly allocated memory on the caller's stack. Thus, the convention
|
||||
of the ranked memref descriptor pointed to by an unranked memref descriptor
|
||||
being stored on stack is respected.
|
||||
|
|
|
@ -130,7 +130,7 @@ mlir/lib/Conversion/GPUCommon.
|
|||
Each conversion typically exists in a separate library, declared with
|
||||
add_mlir_conversion_library(). Conversion libraries typically depend
|
||||
on their source and target dialects, but may also depend on other
|
||||
dialects (e.g. MLIRStandard). Typically this dependence is specified
|
||||
dialects (e.g. MLIRFunc). Typically this dependence is specified
|
||||
using target_link_libraries() and the PUBLIC keyword. For instance:
|
||||
|
||||
```cmake
|
||||
|
|
|
@ -63,9 +63,9 @@ void ToyToAffineLoweringPass::runOnOperation() {
|
|||
|
||||
// We define the specific operations, or dialects, that are legal targets for
|
||||
// this lowering. In our case, we are lowering to a combination of the
|
||||
// `Affine`, `Arithmetic`, `MemRef`, and `Standard` dialects.
|
||||
// `Affine`, `Arithmetic`, `Func`, and `MemRef` dialects.
|
||||
target.addLegalDialect<AffineDialect, arith::ArithmeticDialect,
|
||||
memref::MemRefDialect, StandardOpsDialect>();
|
||||
func::FuncDialect, memref::MemRefDialect>();
|
||||
|
||||
// We also define the Toy dialect as Illegal so that the conversion will fail
|
||||
// if any of these operations are *not* converted. Given that we actually want
|
||||
|
|
|
@ -28,7 +28,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
mlir::DialectRegistry registry;
|
||||
registry.insert<mlir::standalone::StandaloneDialect,
|
||||
mlir::arith::ArithmeticDialect, mlir::StandardOpsDialect>();
|
||||
mlir::arith::ArithmeticDialect, mlir::func::FuncDialect>();
|
||||
// Add the following to include *all* MLIR Core dialects, or selectively
|
||||
// include what you need like above. You only need to register dialects that
|
||||
// will be *parsed* by the tool, not the one generated
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
#include "llvm/ADT/Sequence.h"
|
||||
|
@ -229,8 +229,8 @@ struct ReturnOpLowering : public OpRewritePattern<toy::ReturnOp> {
|
|||
if (op.hasOperand())
|
||||
return failure();
|
||||
|
||||
// We lower "toy.return" directly to "std.return".
|
||||
rewriter.replaceOpWithNewOp<ReturnOp>(op);
|
||||
// We lower "toy.return" directly to "func.return".
|
||||
rewriter.replaceOpWithNewOp<func::ReturnOp>(op);
|
||||
return success();
|
||||
}
|
||||
};
|
||||
|
@ -279,7 +279,7 @@ namespace {
|
|||
struct ToyToAffineLoweringPass
|
||||
: public PassWrapper<ToyToAffineLoweringPass, OperationPass<FuncOp>> {
|
||||
void getDependentDialects(DialectRegistry ®istry) const override {
|
||||
registry.insert<AffineDialect, memref::MemRefDialect, StandardOpsDialect>();
|
||||
registry.insert<AffineDialect, func::FuncDialect, memref::MemRefDialect>();
|
||||
}
|
||||
void runOnOperation() final;
|
||||
};
|
||||
|
@ -305,9 +305,9 @@ void ToyToAffineLoweringPass::runOnOperation() {
|
|||
|
||||
// We define the specific operations, or dialects, that are legal targets for
|
||||
// this lowering. In our case, we are lowering to a combination of the
|
||||
// `Affine`, `Arithmetic`, `MemRef`, and `Standard` dialects.
|
||||
// `Affine`, `Arithmetic`, `Func`, and `MemRef` dialects.
|
||||
target.addLegalDialect<AffineDialect, arith::ArithmeticDialect,
|
||||
memref::MemRefDialect, StandardOpsDialect>();
|
||||
func::FuncDialect, memref::MemRefDialect>();
|
||||
|
||||
// We also define the Toy dialect as Illegal so that the conversion will fail
|
||||
// if any of these operations are *not* converted. Given that we actually want
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
#include "llvm/ADT/Sequence.h"
|
||||
|
@ -229,8 +229,8 @@ struct ReturnOpLowering : public OpRewritePattern<toy::ReturnOp> {
|
|||
if (op.hasOperand())
|
||||
return failure();
|
||||
|
||||
// We lower "toy.return" directly to "std.return".
|
||||
rewriter.replaceOpWithNewOp<ReturnOp>(op);
|
||||
// We lower "toy.return" directly to "func.return".
|
||||
rewriter.replaceOpWithNewOp<func::ReturnOp>(op);
|
||||
return success();
|
||||
}
|
||||
};
|
||||
|
@ -279,7 +279,7 @@ namespace {
|
|||
struct ToyToAffineLoweringPass
|
||||
: public PassWrapper<ToyToAffineLoweringPass, OperationPass<FuncOp>> {
|
||||
void getDependentDialects(DialectRegistry ®istry) const override {
|
||||
registry.insert<AffineDialect, memref::MemRefDialect, StandardOpsDialect>();
|
||||
registry.insert<AffineDialect, func::FuncDialect, memref::MemRefDialect>();
|
||||
}
|
||||
void runOnOperation() final;
|
||||
};
|
||||
|
@ -305,9 +305,9 @@ void ToyToAffineLoweringPass::runOnOperation() {
|
|||
|
||||
// We define the specific operations, or dialects, that are legal targets for
|
||||
// this lowering. In our case, we are lowering to a combination of the
|
||||
// `Affine`, `Arithmetic`, `MemRef`, and `Standard` dialects.
|
||||
// `Affine`, `Arithmetic`, `Func`, and `MemRef` dialects.
|
||||
target.addLegalDialect<AffineDialect, arith::ArithmeticDialect,
|
||||
memref::MemRefDialect, StandardOpsDialect>();
|
||||
func::FuncDialect, memref::MemRefDialect>();
|
||||
|
||||
// We also define the Toy dialect as Illegal so that the conversion will fail
|
||||
// if any of these operations are *not* converted. Given that we actually want
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/SCF/SCF.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
#include "llvm/ADT/Sequence.h"
|
||||
|
@ -91,8 +91,8 @@ public:
|
|||
|
||||
// Insert a newline after each of the inner dimensions of the shape.
|
||||
if (i != e - 1)
|
||||
rewriter.create<CallOp>(loc, printfRef, rewriter.getIntegerType(32),
|
||||
newLineCst);
|
||||
rewriter.create<func::CallOp>(loc, printfRef,
|
||||
rewriter.getIntegerType(32), newLineCst);
|
||||
rewriter.create<scf::YieldOp>(loc);
|
||||
rewriter.setInsertionPointToStart(loop.getBody());
|
||||
}
|
||||
|
@ -101,8 +101,9 @@ public:
|
|||
auto printOp = cast<toy::PrintOp>(op);
|
||||
auto elementLoad =
|
||||
rewriter.create<memref::LoadOp>(loc, printOp.input(), loopIvs);
|
||||
rewriter.create<CallOp>(loc, printfRef, rewriter.getIntegerType(32),
|
||||
ArrayRef<Value>({formatSpecifierCst, elementLoad}));
|
||||
rewriter.create<func::CallOp>(
|
||||
loc, printfRef, rewriter.getIntegerType(32),
|
||||
ArrayRef<Value>({formatSpecifierCst, elementLoad}));
|
||||
|
||||
// Notify the rewriter that this operation has been removed.
|
||||
rewriter.eraseOp(op);
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
#include "llvm/ADT/Sequence.h"
|
||||
|
@ -229,8 +229,8 @@ struct ReturnOpLowering : public OpRewritePattern<toy::ReturnOp> {
|
|||
if (op.hasOperand())
|
||||
return failure();
|
||||
|
||||
// We lower "toy.return" directly to "std.return".
|
||||
rewriter.replaceOpWithNewOp<ReturnOp>(op);
|
||||
// We lower "toy.return" directly to "func.return".
|
||||
rewriter.replaceOpWithNewOp<func::ReturnOp>(op);
|
||||
return success();
|
||||
}
|
||||
};
|
||||
|
@ -279,7 +279,7 @@ namespace {
|
|||
struct ToyToAffineLoweringPass
|
||||
: public PassWrapper<ToyToAffineLoweringPass, OperationPass<FuncOp>> {
|
||||
void getDependentDialects(DialectRegistry ®istry) const override {
|
||||
registry.insert<AffineDialect, memref::MemRefDialect, StandardOpsDialect>();
|
||||
registry.insert<AffineDialect, func::FuncDialect, memref::MemRefDialect>();
|
||||
}
|
||||
void runOnOperation() final;
|
||||
};
|
||||
|
@ -305,9 +305,9 @@ void ToyToAffineLoweringPass::runOnOperation() {
|
|||
|
||||
// We define the specific operations, or dialects, that are legal targets for
|
||||
// this lowering. In our case, we are lowering to a combination of the
|
||||
// `Affine`, `Arithmetic`, `MemRef`, and `Standard` dialects.
|
||||
// `Affine`, `Arithmetic`, `Func`, and `MemRef` dialects.
|
||||
target.addLegalDialect<AffineDialect, arith::ArithmeticDialect,
|
||||
memref::MemRefDialect, StandardOpsDialect>();
|
||||
func::FuncDialect, memref::MemRefDialect>();
|
||||
|
||||
// We also define the Toy dialect as Illegal so that the conversion will fail
|
||||
// if any of these operations are *not* converted. Given that we actually want
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h"
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/SCF/SCF.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
#include "llvm/ADT/Sequence.h"
|
||||
|
@ -91,8 +91,8 @@ public:
|
|||
|
||||
// Insert a newline after each of the inner dimensions of the shape.
|
||||
if (i != e - 1)
|
||||
rewriter.create<CallOp>(loc, printfRef, rewriter.getIntegerType(32),
|
||||
newLineCst);
|
||||
rewriter.create<func::CallOp>(loc, printfRef,
|
||||
rewriter.getIntegerType(32), newLineCst);
|
||||
rewriter.create<scf::YieldOp>(loc);
|
||||
rewriter.setInsertionPointToStart(loop.getBody());
|
||||
}
|
||||
|
@ -101,8 +101,9 @@ public:
|
|||
auto printOp = cast<toy::PrintOp>(op);
|
||||
auto elementLoad =
|
||||
rewriter.create<memref::LoadOp>(loc, printOp.input(), loopIvs);
|
||||
rewriter.create<CallOp>(loc, printfRef, rewriter.getIntegerType(32),
|
||||
ArrayRef<Value>({formatSpecifierCst, elementLoad}));
|
||||
rewriter.create<func::CallOp>(
|
||||
loc, printfRef, rewriter.getIntegerType(32),
|
||||
ArrayRef<Value>({formatSpecifierCst, elementLoad}));
|
||||
|
||||
// Notify the rewriter that this operation has been removed.
|
||||
rewriter.eraseOp(op);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===-- mlir-c/Dialect/Standard.h - C API for Standard dialect ----*- C -*-===//
|
||||
//===-- mlir-c/Dialect/Func.h - C API for Func dialect ------------*- C -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions.
|
||||
|
@ -8,15 +8,15 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This header declares the C interface for registering and accessing the
|
||||
// Standard dialect. A dialect should be registered with a context to make it
|
||||
// Func dialect. A dialect should be registered with a context to make it
|
||||
// available to users of the context. These users must load the dialect
|
||||
// before using any of its attributes, operations or types. Parser and pass
|
||||
// manager can load registered dialects automatically.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_C_DIALECT_STANDARD_H
|
||||
#define MLIR_C_DIALECT_STANDARD_H
|
||||
#ifndef MLIR_C_DIALECT_FUNC_H
|
||||
#define MLIR_C_DIALECT_FUNC_H
|
||||
|
||||
#include "mlir-c/Registration.h"
|
||||
|
||||
|
@ -24,10 +24,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Standard, std);
|
||||
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Func, func);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // MLIR_C_DIALECT_STANDARD_H
|
||||
#endif // MLIR_C_DIALECT_FUNC_H
|
|
@ -20,7 +20,7 @@ extern "C" {
|
|||
// Dialect registration declarations.
|
||||
// Registration entry-points for each dialect are declared using the common
|
||||
// MLIR_DECLARE_DIALECT_REGISTRATION_CAPI macro, which takes the dialect
|
||||
// API name (i.e. "Standard", "Tensor", "Linalg") and namespace (i.e. "std",
|
||||
// API name (i.e. "Func", "Tensor", "Linalg") and namespace (i.e. "func",
|
||||
// "tensor", "linalg"). The following declarations are produced:
|
||||
//
|
||||
// /// Gets the above hook methods in struct form for a dialect by namespace.
|
||||
|
|
|
@ -25,8 +25,8 @@ class MLIRContext;
|
|||
/// to derive the bitwidth from the LLVM data layout.
|
||||
static constexpr unsigned kDeriveIndexBitwidthFromDataLayout = 0;
|
||||
|
||||
/// Options to control the Standard dialect to LLVM lowering. The struct is used
|
||||
/// to share lowering options between passes, patterns, and type converter.
|
||||
/// Options to control the LLVM lowering. The struct is used to share lowering
|
||||
/// options between passes, patterns, and type converter.
|
||||
class LowerToLLVMOptions {
|
||||
public:
|
||||
explicit LowerToLLVMOptions(MLIRContext *ctx);
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace LLVM {
|
|||
class LLVMDialect;
|
||||
} // namespace LLVM
|
||||
|
||||
/// Conversion from types in the Standard dialect to the LLVM IR dialect.
|
||||
/// Conversion from types to the LLVM IR dialect.
|
||||
class LLVMTypeConverter : public TypeConverter {
|
||||
/// Give structFuncArgTypeConverter access to memref-specific functions.
|
||||
friend LogicalResult
|
||||
|
|
|
@ -20,7 +20,7 @@ class OperationPass;
|
|||
namespace linalg {
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Patterns to convert a LinalgOp to std.call @external library implementation.
|
||||
// Patterns to convert a LinalgOp to func.call @external library implementation.
|
||||
//===----------------------------------------------------------------------===//
|
||||
// These patterns are exposed individually because they are expected to be
|
||||
// typically used individually.
|
||||
|
|
|
@ -67,9 +67,9 @@ def ConvertAffineToStandard : Pass<"lower-affine"> {
|
|||
}];
|
||||
let constructor = "mlir::createLowerAffinePass()";
|
||||
let dependentDialects = [
|
||||
"func::FuncDialect",
|
||||
"memref::MemRefDialect",
|
||||
"scf::SCFDialect",
|
||||
"StandardOpsDialect",
|
||||
"vector::VectorDialect"
|
||||
];
|
||||
}
|
||||
|
@ -227,9 +227,9 @@ def ConvertGpuOpsToNVVMOps : Pass<"convert-gpu-to-nvvm", "gpu::GPUModuleOp"> {
|
|||
let summary = "Generate NVVM operations for gpu operations";
|
||||
let constructor = "mlir::createLowerGpuOpsToNVVMOpsPass()";
|
||||
let dependentDialects = [
|
||||
"func::FuncDialect",
|
||||
"memref::MemRefDialect",
|
||||
"NVVM::NVVMDialect",
|
||||
"StandardOpsDialect",
|
||||
];
|
||||
let options = [
|
||||
Option<"indexBitwidth", "index-bitwidth", "unsigned",
|
||||
|
@ -327,7 +327,7 @@ def ConvertLinalgToStandard : Pass<"convert-linalg-to-std", "ModuleOp"> {
|
|||
let summary = "Convert the operations from the linalg dialect into the "
|
||||
"Standard dialect";
|
||||
let constructor = "mlir::createConvertLinalgToStandardPass()";
|
||||
let dependentDialects = ["memref::MemRefDialect", "StandardOpsDialect"];
|
||||
let dependentDialects = ["func::FuncDialect", "memref::MemRefDialect"];
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -356,7 +356,7 @@ def ConvertMathToLibm : Pass<"convert-math-to-libm", "ModuleOp"> {
|
|||
let constructor = "mlir::createConvertMathToLibmPass()";
|
||||
let dependentDialects = [
|
||||
"arith::ArithmeticDialect",
|
||||
"StandardOpsDialect",
|
||||
"func::FuncDialect",
|
||||
"vector::VectorDialect",
|
||||
];
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ def ConvertShapeToStandard : Pass<"convert-shape-to-std", "ModuleOp"> {
|
|||
"dialect";
|
||||
let constructor = "mlir::createConvertShapeToStandardPass()";
|
||||
let dependentDialects = [
|
||||
"StandardOpsDialect",
|
||||
"func::FuncDialect",
|
||||
"scf::SCFDialect",
|
||||
];
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ def TosaToStandard : Pass<"tosa-to-standard"> {
|
|||
let summary = "Lower TOSA to the Standard dialect";
|
||||
let dependentDialects = [
|
||||
"arith::ArithmeticDialect",
|
||||
"StandardOpsDialect",
|
||||
"func::FuncDialect",
|
||||
"tensor::TensorDialect",
|
||||
];
|
||||
let description = [{
|
||||
|
|
|
@ -74,7 +74,7 @@ struct VectorTransferToSCFOptions {
|
|||
}
|
||||
};
|
||||
|
||||
/// Collect a set of patterns to convert from the Vector dialect to SCF + std.
|
||||
/// Collect a set of patterns to convert from the Vector dialect to SCF + func.
|
||||
void populateVectorToSCFConversionPatterns(
|
||||
RewritePatternSet &patterns,
|
||||
const VectorTransferToSCFOptions &options = VectorTransferToSCFOptions());
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define MLIR_DIALECT_AFFINE_ANALYSIS_AFFINEANALYSIS_H
|
||||
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/IR/Value.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
|
|
|
@ -31,7 +31,7 @@ def ArithmeticBufferize : Pass<"arith-bufferize", "ModuleOp"> {
|
|||
def ArithmeticExpandOps : Pass<"arith-expand"> {
|
||||
let summary = "Legalize Arithmetic ops to be convertible to LLVM.";
|
||||
let constructor = "mlir::arith::createArithmeticExpandOpsPass()";
|
||||
let dependentDialects = ["StandardOpsDialect"];
|
||||
let dependentDialects = ["func::FuncDialect"];
|
||||
}
|
||||
|
||||
#endif // MLIR_DIALECT_ARITHMETIC_TRANSFORMS_PASSES
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
#include "mlir/Dialect/ArmSVE/ArmSVEDialect.h.inc"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/ArmSVE/ArmSVE.h.inc"
|
||||
|
|
|
@ -9,6 +9,7 @@ add_subdirectory(Complex)
|
|||
add_subdirectory(ControlFlow)
|
||||
add_subdirectory(DLTI)
|
||||
add_subdirectory(EmitC)
|
||||
add_subdirectory(Func)
|
||||
add_subdirectory(GPU)
|
||||
add_subdirectory(Math)
|
||||
add_subdirectory(Linalg)
|
||||
|
@ -23,7 +24,6 @@ add_subdirectory(SCF)
|
|||
add_subdirectory(Shape)
|
||||
add_subdirectory(SparseTensor)
|
||||
add_subdirectory(SPIRV)
|
||||
add_subdirectory(StandardOps)
|
||||
add_subdirectory(Tensor)
|
||||
add_subdirectory(Tosa)
|
||||
add_subdirectory(Vector)
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef STANDARD_OPS
|
||||
#define STANDARD_OPS
|
||||
#ifndef MLIR_DIALECTS_CONTROLFLOW_IR_CONTROLFLOWOPS_TD
|
||||
#define MLIR_DIALECTS_CONTROLFLOW_IR_CONTROLFLOWOPS_TD
|
||||
|
||||
include "mlir/IR/OpAsmInterface.td"
|
||||
include "mlir/Interfaces/ControlFlowInterfaces.td"
|
||||
|
@ -310,4 +310,4 @@ def SwitchOp : CF_Op<"switch",
|
|||
let hasVerifier = 1;
|
||||
}
|
||||
|
||||
#endif // STANDARD_OPS
|
||||
#endif // MLIR_DIALECTS_CONTROLFLOW_IR_CONTROLFLOWOPS_TD
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
set(LLVM_TARGET_DEFINITIONS FuncOps.td)
|
||||
mlir_tablegen(FuncOps.h.inc -gen-op-decls)
|
||||
mlir_tablegen(FuncOps.cpp.inc -gen-op-defs)
|
||||
mlir_tablegen(FuncOpsDialect.h.inc -gen-dialect-decls)
|
||||
mlir_tablegen(FuncOpsDialect.cpp.inc -gen-dialect-defs)
|
||||
add_public_tablegen_target(MLIRFuncOpsIncGen)
|
||||
|
||||
add_mlir_doc(FuncOps FuncOps Dialects/ -gen-op-doc)
|
|
@ -1,44 +1,32 @@
|
|||
//===- Ops.h - Standard MLIR Operations -------------------------*- C++ -*-===//
|
||||
//===- FuncOps.h - Func Dialect Operations ----------------------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines convenience types for working with standard operations
|
||||
// in the MLIR operation set.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_DIALECT_STANDARDOPS_IR_OPS_H
|
||||
#define MLIR_DIALECT_STANDARDOPS_IR_OPS_H
|
||||
#ifndef MLIR_DIALECT_FUNC_IR_OPS_H
|
||||
#define MLIR_DIALECT_FUNC_IR_OPS_H
|
||||
|
||||
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/OpImplementation.h"
|
||||
#include "mlir/Interfaces/CallInterfaces.h"
|
||||
#include "mlir/Interfaces/CastInterfaces.h"
|
||||
#include "mlir/Interfaces/ControlFlowInterfaces.h"
|
||||
#include "mlir/Interfaces/InferTypeOpInterface.h"
|
||||
#include "mlir/Interfaces/SideEffectInterfaces.h"
|
||||
|
||||
// Pull in all enum type definitions and utility function declarations.
|
||||
#include "mlir/Dialect/StandardOps/IR/OpsEnums.h.inc"
|
||||
|
||||
namespace mlir {
|
||||
class AffineMap;
|
||||
class Builder;
|
||||
class FuncOp;
|
||||
class OpBuilder;
|
||||
class PatternRewriter;
|
||||
} // namespace mlir
|
||||
|
||||
#define GET_OP_CLASSES
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h.inc"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h.inc"
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/OpsDialect.h.inc"
|
||||
#include "mlir/Dialect/Func/IR/FuncOpsDialect.h.inc"
|
||||
|
||||
#endif // MLIR_DIALECT_STANDARDOPS_IR_OPS_H
|
||||
#endif // MLIR_DIALECT_FUNC_IR_OPS_H
|
|
@ -1,56 +1,51 @@
|
|||
//===- Ops.td - Standard operation definitions -------------*- tablegen -*-===//
|
||||
//===- FuncOps.td - Func operation definitions -------------*- tablegen -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Defines some MLIR standard operations.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef STANDARD_OPS
|
||||
#define STANDARD_OPS
|
||||
#ifndef MLIR_DIALECT_FUNC_IR_FUNCOPS_TD
|
||||
#define MLIR_DIALECT_FUNC_IR_FUNCOPS_TD
|
||||
|
||||
include "mlir/IR/OpAsmInterface.td"
|
||||
include "mlir/IR/SymbolInterfaces.td"
|
||||
include "mlir/Interfaces/CallInterfaces.td"
|
||||
include "mlir/Interfaces/CastInterfaces.td"
|
||||
include "mlir/Interfaces/ControlFlowInterfaces.td"
|
||||
include "mlir/Interfaces/InferTypeOpInterface.td"
|
||||
include "mlir/Interfaces/SideEffectInterfaces.td"
|
||||
|
||||
def StandardOps_Dialect : Dialect {
|
||||
let name = "std";
|
||||
let cppNamespace = "::mlir";
|
||||
def Func_Dialect : Dialect {
|
||||
let name = "func";
|
||||
let cppNamespace = "::mlir::func";
|
||||
let dependentDialects = ["cf::ControlFlowDialect"];
|
||||
let hasConstantMaterializer = 1;
|
||||
let emitAccessorPrefix = kEmitAccessorPrefix_Prefixed;
|
||||
}
|
||||
|
||||
// Base class for Standard dialect ops.
|
||||
class Std_Op<string mnemonic, list<Trait> traits = []> :
|
||||
Op<StandardOps_Dialect, mnemonic, traits>;
|
||||
// Base class for Func dialect ops.
|
||||
class Func_Op<string mnemonic, list<Trait> traits = []> :
|
||||
Op<Func_Dialect, mnemonic, traits>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// CallOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def CallOp : Std_Op<"call",
|
||||
def CallOp : Func_Op<"call",
|
||||
[CallOpInterface, MemRefsNormalizable,
|
||||
DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
|
||||
let summary = "call operation";
|
||||
let description = [{
|
||||
The `call` operation represents a direct call to a function that is within
|
||||
the same symbol scope as the call. The operands and result types of the
|
||||
call must match the specified function type. The callee is encoded as a
|
||||
The `func.call` operation represents a direct call to a function that is
|
||||
within the same symbol scope as the call. The operands and result types of
|
||||
the call must match the specified function type. The callee is encoded as a
|
||||
symbol reference attribute named "callee".
|
||||
|
||||
Example:
|
||||
|
||||
```mlir
|
||||
%2 = call @my_add(%0, %1) : (f32, f32) -> f32
|
||||
%2 = func.call @my_add(%0, %1) : (f32, f32) -> f32
|
||||
```
|
||||
}];
|
||||
|
||||
|
@ -105,7 +100,7 @@ def CallOp : Std_Op<"call",
|
|||
// CallIndirectOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def CallIndirectOp : Std_Op<"call_indirect", [
|
||||
def CallIndirectOp : Func_Op<"call_indirect", [
|
||||
CallOpInterface,
|
||||
TypesMatchWith<"callee input types match argument types",
|
||||
"callee", "callee_operands",
|
||||
|
@ -116,19 +111,18 @@ def CallIndirectOp : Std_Op<"call_indirect", [
|
|||
]> {
|
||||
let summary = "indirect call operation";
|
||||
let description = [{
|
||||
The `call_indirect` operation represents an indirect call to a value of
|
||||
function type. Functions are first class types in MLIR, and may be passed as
|
||||
arguments and merged together with block arguments. The operands and result
|
||||
types of the call must match the specified function type.
|
||||
The `func.call_indirect` operation represents an indirect call to a value
|
||||
of function type. The operands and result types of the call must match the
|
||||
specified function type.
|
||||
|
||||
Function values can be created with the
|
||||
[`constant` operation](#stdconstant-constantop).
|
||||
[`func.constant` operation](#funcconstant-constantop).
|
||||
|
||||
Example:
|
||||
|
||||
```mlir
|
||||
%31 = call_indirect %15(%0, %1)
|
||||
: (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32>
|
||||
%func = func.constant @my_func : (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32>
|
||||
%result = func.call_indirect %func(%0, %1) : (tensor<16xf32>, tensor<16xf32>) -> tensor<16xf32>
|
||||
```
|
||||
}];
|
||||
|
||||
|
@ -160,38 +154,31 @@ def CallIndirectOp : Std_Op<"call_indirect", [
|
|||
}];
|
||||
|
||||
let hasCanonicalizeMethod = 1;
|
||||
|
||||
let assemblyFormat =
|
||||
"$callee `(` $callee_operands `)` attr-dict `:` type($callee)";
|
||||
let assemblyFormat = [{
|
||||
$callee `(` $callee_operands `)` attr-dict `:` type($callee)
|
||||
}];
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ConstantOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def ConstantOp : Std_Op<"constant",
|
||||
def ConstantOp : Func_Op<"constant",
|
||||
[ConstantLike, NoSideEffect,
|
||||
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getAsmResultNames"]>]> {
|
||||
let summary = "constant";
|
||||
let description = [{
|
||||
Syntax:
|
||||
|
||||
```
|
||||
operation ::= ssa-id `=` `std.constant` attribute-value `:` type
|
||||
```
|
||||
|
||||
The `constant` operation produces an SSA value from a symbol reference to a
|
||||
`builtin.func` operation
|
||||
The `func.constant` operation produces an SSA value from a symbol reference
|
||||
to a `func.func` operation
|
||||
|
||||
Example:
|
||||
|
||||
```mlir
|
||||
// Reference to function @myfn.
|
||||
%2 = constant @myfn : (tensor<16xf32>, f32) -> tensor<16xf32>
|
||||
%2 = func.constant @myfn : (tensor<16xf32>, f32) -> tensor<16xf32>
|
||||
|
||||
// Equivalent generic forms
|
||||
%2 = "std.constant"() {value = @myfn}
|
||||
: () -> ((tensor<16xf32>, f32) -> tensor<16xf32>)
|
||||
%2 = "func.constant"() { value = @myfn } : () -> ((tensor<16xf32>, f32) -> tensor<16xf32>)
|
||||
```
|
||||
|
||||
MLIR does not allow direct references to functions in SSA operands because
|
||||
|
@ -218,11 +205,11 @@ def ConstantOp : Std_Op<"constant",
|
|||
// ReturnOp
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
def ReturnOp : Std_Op<"return", [NoSideEffect, HasParent<"FuncOp">,
|
||||
def ReturnOp : Func_Op<"return", [NoSideEffect, HasParent<"FuncOp">,
|
||||
MemRefsNormalizable, ReturnLike, Terminator]> {
|
||||
let summary = "return operation";
|
||||
let summary = "Function return operation";
|
||||
let description = [{
|
||||
The `return` operation represents a return operation within a function.
|
||||
The `func.return` operation represents a return operation within a function.
|
||||
The operation takes variable number of operands and produces no results.
|
||||
The operand number and types must match the signature of the function
|
||||
that contains the operation.
|
||||
|
@ -230,7 +217,7 @@ def ReturnOp : Std_Op<"return", [NoSideEffect, HasParent<"FuncOp">,
|
|||
Example:
|
||||
|
||||
```mlir
|
||||
func @foo() : (i32, f8) {
|
||||
func.func @foo() : (i32, f8) {
|
||||
...
|
||||
return %0, %1 : i32, f8
|
||||
}
|
||||
|
@ -239,12 +226,12 @@ def ReturnOp : Std_Op<"return", [NoSideEffect, HasParent<"FuncOp">,
|
|||
|
||||
let arguments = (ins Variadic<AnyType>:$operands);
|
||||
|
||||
let builders = [
|
||||
OpBuilder<(ins),
|
||||
[{ build($_builder, $_state, llvm::None); }]>];
|
||||
let builders = [OpBuilder<(ins), [{
|
||||
build($_builder, $_state, llvm::None);
|
||||
}]>];
|
||||
|
||||
let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
|
||||
let hasVerifier = 1;
|
||||
}
|
||||
|
||||
#endif // STANDARD_OPS
|
||||
#endif // MLIR_DIALECT_FUNC_IR_FUNCOPS_TD
|
|
@ -0,0 +1,5 @@
|
|||
set(LLVM_TARGET_DEFINITIONS Passes.td)
|
||||
mlir_tablegen(Passes.h.inc -gen-pass-decls -name Func)
|
||||
add_public_tablegen_target(MLIRFuncTransformsIncGen)
|
||||
|
||||
add_mlir_doc(Passes FuncPasses ./ -gen-pass-doc)
|
|
@ -15,8 +15,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_DIALECT_STANDARDOPS_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H
|
||||
#define MLIR_DIALECT_STANDARDOPS_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H
|
||||
#ifndef MLIR_DIALECT_FUNC_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H
|
||||
#define MLIR_DIALECT_FUNC_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H
|
||||
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
|
||||
|
@ -88,4 +88,4 @@ void populateDecomposeCallGraphTypesPatterns(MLIRContext *context,
|
|||
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_STANDARDOPS_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H
|
||||
#endif // MLIR_DIALECT_FUNC_TRANSFORMS_DECOMPOSECALLGRAPHTYPES_H
|
|
@ -1,4 +1,4 @@
|
|||
//===- FuncConversions.h - Patterns for converting std.funcs ----*- C++ -*-===//
|
||||
//===- FuncConversions.h - Patterns for converting func.func ----*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -6,12 +6,12 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This files contains patterns for converting standard functions.
|
||||
// This files contains patterns for converting functions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_DIALECT_STANDARDOPS_TRANSFORMS_FUNCCONVERSIONS_H_
|
||||
#define MLIR_DIALECT_STANDARDOPS_TRANSFORMS_FUNCCONVERSIONS_H_
|
||||
#ifndef MLIR_DIALECT_FUNC_TRANSFORMS_FUNCCONVERSIONS_H_
|
||||
#define MLIR_DIALECT_FUNC_TRANSFORMS_FUNCCONVERSIONS_H_
|
||||
|
||||
#include "mlir/Support/LLVM.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
@ -70,4 +70,4 @@ bool isLegalForReturnOpTypeConversionPattern(Operation *op,
|
|||
bool isNotBranchOpInterfaceOrReturnLikeOp(Operation *op);
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_STANDARDOPS_TRANSFORMS_FUNCCONVERSIONS_H_
|
||||
#endif // MLIR_DIALECT_FUNC_TRANSFORMS_FUNCCONVERSIONS_H_
|
|
@ -6,13 +6,13 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This header file defines prototypes that expose pass constructors in the loop
|
||||
// This header file defines prototypes that expose pass constructors in the Func
|
||||
// transformation library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_DIALECT_STANDARDOPS_TRANSFORMS_PASSES_H
|
||||
#define MLIR_DIALECT_STANDARDOPS_TRANSFORMS_PASSES_H
|
||||
#ifndef MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_H
|
||||
#define MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_H
|
||||
|
||||
#include "mlir/Pass/Pass.h"
|
||||
|
||||
|
@ -23,6 +23,7 @@ class BufferizeTypeConverter;
|
|||
|
||||
class RewritePatternSet;
|
||||
|
||||
namespace func {
|
||||
/// Creates an instance of func bufferization pass.
|
||||
std::unique_ptr<Pass> createFuncBufferizePass();
|
||||
|
||||
|
@ -32,8 +33,9 @@ std::unique_ptr<Pass> createFuncBufferizePass();
|
|||
|
||||
/// Generate the code for registering passes.
|
||||
#define GEN_PASS_REGISTRATION
|
||||
#include "mlir/Dialect/StandardOps/Transforms/Passes.h.inc"
|
||||
#include "mlir/Dialect/Func/Transforms/Passes.h.inc"
|
||||
|
||||
} // namespace func
|
||||
} // namespace mlir
|
||||
|
||||
#endif // MLIR_DIALECT_STANDARDOPS_TRANSFORMS_PASSES_H
|
||||
#endif // MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_H
|
|
@ -1,4 +1,4 @@
|
|||
//===-- Passes.td - StandardOps pass definition file -------*- tablegen -*-===//
|
||||
//===-- Passes.td - Func pass definition file --------------*- tablegen -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -6,17 +6,17 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES
|
||||
#define MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES
|
||||
#ifndef MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_TD
|
||||
#define MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_TD
|
||||
|
||||
include "mlir/Pass/PassBase.td"
|
||||
|
||||
def FuncBufferize : Pass<"func-bufferize", "ModuleOp"> {
|
||||
let summary = "Bufferize func/call/return ops";
|
||||
let description = [{
|
||||
A bufferize pass that bufferizes std.func and std.call ops.
|
||||
A bufferize pass that bufferizes builtin.func and func.call ops.
|
||||
|
||||
Because this pass updates std.func ops, it must be a module pass. It is
|
||||
Because this pass updates builtin.func ops, it must be a module pass. It is
|
||||
useful to keep this pass separate from other bufferizations so that the
|
||||
other ones can be run at function-level in parallel.
|
||||
|
||||
|
@ -35,9 +35,9 @@ def FuncBufferize : Pass<"func-bufferize", "ModuleOp"> {
|
|||
Finally, this pass fails for unknown terminators, as we cannot decide
|
||||
whether they need rewriting.
|
||||
}];
|
||||
let constructor = "mlir::createFuncBufferizePass()";
|
||||
let constructor = "mlir::func::createFuncBufferizePass()";
|
||||
let dependentDialects = ["bufferization::BufferizationDialect",
|
||||
"memref::MemRefDialect"];
|
||||
}
|
||||
|
||||
#endif // MLIR_DIALECT_STANDARD_TRANSFORMS_PASSES
|
||||
#endif // MLIR_DIALECT_FUNC_TRANSFORMS_PASSES_TD
|
|
@ -541,9 +541,9 @@ makeTiledLoopRanges(RewriterBase &b, Location loc, AffineMap map,
|
|||
/// operand_dim_1 = dim %operand, 1 : memref<50x100xf32>
|
||||
/// scf.for %k = %c0 to operand_dim_0 step %c10 {
|
||||
/// scf.for %l = %c0 to operand_dim_1 step %c25 {
|
||||
/// %4 = std.subview %operand[%k, %l][%c10, %c25][%c1, %c1]
|
||||
/// %4 = memref.subview %operand[%k, %l][%c10, %c25][%c1, %c1]
|
||||
/// : memref<50x100xf32> to memref<?x?xf32, #strided>
|
||||
/// %5 = std.subview %result[%k, %l][%c10, %c25][%c1, %c1]
|
||||
/// %5 = memref.subview %result[%k, %l][%c10, %c25][%c1, %c1]
|
||||
/// : memref<50x100xf32> to memref<?x?xf32, #strided>
|
||||
/// linalg.generic pointwise_2d_trait %4, %5 {
|
||||
/// ^bb0(%operand_in: f32, %result_in: f32):
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
#ifndef MLIR_DIALECT_LINALG_UTILS_UTILS_H
|
||||
#define MLIR_DIALECT_LINALG_UTILS_UTILS_H
|
||||
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h"
|
||||
#include "mlir/Dialect/Linalg/IR/Linalg.h"
|
||||
#include "mlir/Dialect/SCF/SCF.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
|
||||
|
|
|
@ -732,12 +732,6 @@ def Math_SqrtOp : Math_FloatUnaryOp<"sqrt"> {
|
|||
def Math_TanhOp : Math_FloatUnaryOp<"tanh"> {
|
||||
let summary = "hyperbolic tangent of the specified value";
|
||||
let description = [{
|
||||
Syntax:
|
||||
|
||||
```
|
||||
operation ::= ssa-id `=` `std.tanh` ssa-use `:` type
|
||||
```
|
||||
|
||||
The `tanh` operation computes the hyperbolic tangent. It takes one operand
|
||||
and returns one result of the same type. This type may be a float scalar
|
||||
type, a vector whose element type is float, or a tensor of floats. It has
|
||||
|
|
|
@ -903,7 +903,7 @@ def LoadOp : MemRef_Op<"load",
|
|||
In an `affine.if` or `affine.for` body, the indices of a load are restricted
|
||||
to SSA values bound to surrounding loop induction variables,
|
||||
[symbols](Affine.md/#dimensions-and-symbols), results of a
|
||||
[`constant` operation](Standard.md/#stdconstant-constantop), or the result of an
|
||||
constant operations, or the result of an
|
||||
`affine.apply` operation that can in turn take as arguments all of the
|
||||
aforementioned SSA values or the recursively result of such an
|
||||
`affine.apply` operation.
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
namespace mlir {
|
||||
|
||||
class AffineDialect;
|
||||
class StandardOpsDialect;
|
||||
namespace func {
|
||||
class FuncDialect;
|
||||
} // namespace func
|
||||
namespace tensor {
|
||||
class TensorDialect;
|
||||
} // namespace tensor
|
||||
|
|
|
@ -14,7 +14,7 @@ include "mlir/Pass/PassBase.td"
|
|||
def ExpandOps : Pass<"memref-expand", "FuncOp"> {
|
||||
let summary = "Legalize memref operations to be convertible to LLVM.";
|
||||
let constructor = "mlir::memref::createExpandOpsPass()";
|
||||
let dependentDialects = ["StandardOpsDialect"];
|
||||
let dependentDialects = ["func::FuncDialect"];
|
||||
}
|
||||
|
||||
def FoldSubViewOps : Pass<"fold-memref-subview-ops"> {
|
||||
|
@ -45,7 +45,7 @@ def NormalizeMemRefs : Pass<"normalize-memrefs", "ModuleOp"> {
|
|||
contained in the op. Operations marked with the [MemRefsNormalizable]
|
||||
(https://mlir.llvm.org/docs/Traits/#memrefsnormalizable) trait are
|
||||
expected to be normalizable. Supported operations include affine
|
||||
operations, memref.alloc, memref.dealloc, and std.return.
|
||||
operations, memref.alloc, memref.dealloc, and func.return.
|
||||
|
||||
Given an appropriate layout map specified in the code, this transformation
|
||||
can express tiled or linearized access to multi-dimensional data
|
||||
|
|
|
@ -314,7 +314,7 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
|
|||
|
||||
```mlir
|
||||
// Define an instance with single range of operands.
|
||||
%op = pdl.operation "std.return"(%allArgs : !pdl.range<value>)
|
||||
%op = pdl.operation "func.return"(%allArgs : !pdl.range<value>)
|
||||
```
|
||||
|
||||
2) A variadic number of either !pdl.value or !pdl.range<value>:
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
set(LLVM_TARGET_DEFINITIONS Ops.td)
|
||||
mlir_tablegen(Ops.h.inc -gen-op-decls)
|
||||
mlir_tablegen(Ops.cpp.inc -gen-op-defs)
|
||||
mlir_tablegen(OpsDialect.h.inc -gen-dialect-decls)
|
||||
mlir_tablegen(OpsDialect.cpp.inc -gen-dialect-defs)
|
||||
mlir_tablegen(OpsEnums.h.inc -gen-enum-decls)
|
||||
mlir_tablegen(OpsEnums.cpp.inc -gen-enum-defs)
|
||||
add_public_tablegen_target(MLIRStandardOpsIncGen)
|
||||
|
||||
add_mlir_doc(Ops StandardOps Dialects/ -gen-op-doc)
|
|
@ -1,5 +0,0 @@
|
|||
set(LLVM_TARGET_DEFINITIONS Passes.td)
|
||||
mlir_tablegen(Passes.h.inc -gen-pass-decls -name Standard)
|
||||
add_public_tablegen_target(MLIRStandardTransformsIncGen)
|
||||
|
||||
add_mlir_doc(Passes StandardPasses ./ -gen-pass-doc)
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef MLIR_DIALECT_TOSA_TRANSFORMS_PASSDETAIL_H
|
||||
#define MLIR_DIALECT_TOSA_TRANSFORMS_PASSDETAIL_H
|
||||
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
||||
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
|
|
|
@ -24,7 +24,7 @@ def TosaInferShapes : Pass<"tosa-infer-shapes", "FuncOp"> {
|
|||
|
||||
let constructor = "createTosaInferShapesPass()";
|
||||
let dependentDialects = [
|
||||
"StandardOpsDialect",
|
||||
"func::FuncDialect",
|
||||
"tensor::TensorDialect",
|
||||
"tosa::TosaDialect",
|
||||
];
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#define DIALECT_TOSA_UTILS_COVERSION_UTILS_H_
|
||||
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
||||
#include "mlir/Dialect/Utils/StructuredOpsUtils.h"
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "mlir/Dialect/ControlFlow/IR/ControlFlow.h"
|
||||
#include "mlir/Dialect/DLTI/DLTI.h"
|
||||
#include "mlir/Dialect/EmitC/IR/EmitC.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/GPU/GPUDialect.h"
|
||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
||||
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
|
||||
|
@ -44,7 +45,6 @@
|
|||
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
|
||||
#include "mlir/Dialect/Shape/IR/Shape.h"
|
||||
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Tensor/IR/Tensor.h"
|
||||
#include "mlir/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.h"
|
||||
#include "mlir/Dialect/Tensor/IR/TensorTilingInterfaceImpl.h"
|
||||
|
@ -71,6 +71,7 @@ inline void registerAllDialects(DialectRegistry ®istry) {
|
|||
complex::ComplexDialect,
|
||||
DLTIDialect,
|
||||
emitc::EmitCDialect,
|
||||
func::FuncDialect,
|
||||
gpu::GPUDialect,
|
||||
LLVM::LLVMDialect,
|
||||
linalg::LinalgDialect,
|
||||
|
@ -82,7 +83,6 @@ inline void registerAllDialects(DialectRegistry ®istry) {
|
|||
pdl_interp::PDLInterpDialect,
|
||||
quant::QuantizationDialect,
|
||||
spirv::SPIRVDialect,
|
||||
StandardOpsDialect,
|
||||
arm_sve::ArmSVEDialect,
|
||||
vector::VectorDialect,
|
||||
NVVM::NVVMDialect,
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "mlir/Dialect/Arithmetic/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Async/Passes.h"
|
||||
#include "mlir/Dialect/Bufferization/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Func/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/GPU/Passes.h"
|
||||
#include "mlir/Dialect/LLVMIR/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Linalg/Passes.h"
|
||||
|
@ -29,7 +30,6 @@
|
|||
#include "mlir/Dialect/Shape/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/SparseTensor/Pipelines/Passes.h"
|
||||
#include "mlir/Dialect/SparseTensor/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/StandardOps/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Tensor/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Tosa/Transforms/Passes.h"
|
||||
#include "mlir/Dialect/Vector/Transforms/Passes.h"
|
||||
|
@ -58,6 +58,7 @@ inline void registerAllPasses() {
|
|||
registerAsyncPasses();
|
||||
arith::registerArithmeticPasses();
|
||||
bufferization::registerBufferizationPasses();
|
||||
func::registerFuncPasses();
|
||||
registerGPUPasses();
|
||||
registerGpuSerializeToCubinPass();
|
||||
registerGpuSerializeToHsacoPass();
|
||||
|
@ -69,7 +70,6 @@ inline void registerAllPasses() {
|
|||
registerSCFPasses();
|
||||
registerShapePasses();
|
||||
spirv::registerSPIRVPasses();
|
||||
registerStandardPasses();
|
||||
tensor::registerTensorPasses();
|
||||
tosa::registerTosaOptPasses();
|
||||
vector::registerVectorPasses();
|
||||
|
|
|
@ -80,13 +80,13 @@ add_mlir_upstream_c_api_library(MLIRCAPISparseTensor
|
|||
MLIRSparseTensorTransforms
|
||||
)
|
||||
|
||||
add_mlir_upstream_c_api_library(MLIRCAPIStandard
|
||||
Standard.cpp
|
||||
add_mlir_upstream_c_api_library(MLIRCAPIFunc
|
||||
Func.cpp
|
||||
|
||||
PARTIAL_SOURCES_INTENDED
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRCAPIIR
|
||||
MLIRStandard
|
||||
MLIRFunc
|
||||
)
|
||||
|
||||
add_mlir_upstream_c_api_library(MLIRCAPITensor
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===- Standard.cpp - C Interface for Standard dialect --------------------===//
|
||||
//===- Func.cpp - C Interface for Func dialect ----------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
|
@ -6,8 +6,8 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "mlir-c/Dialect/Standard.h"
|
||||
#include "mlir-c/Dialect/Func.h"
|
||||
#include "mlir/CAPI/Registration.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
|
||||
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Standard, std, mlir::StandardOpsDialect)
|
||||
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Func, func, mlir::func::FuncDialect)
|
|
@ -16,9 +16,9 @@
|
|||
#include "../PassDetail.h"
|
||||
#include "mlir/Dialect/Affine/IR/AffineOps.h"
|
||||
#include "mlir/Dialect/Affine/Utils.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/MemRef/IR/MemRef.h"
|
||||
#include "mlir/Dialect/SCF/SCF.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/Vector/IR/VectorOps.h"
|
||||
#include "mlir/IR/BlockAndValueMapping.h"
|
||||
#include "mlir/IR/IntegerSet.h"
|
||||
|
@ -553,9 +553,9 @@ class LowerAffinePass : public ConvertAffineToStandardBase<LowerAffinePass> {
|
|||
populateAffineToStdConversionPatterns(patterns);
|
||||
populateAffineToVectorConversionPatterns(patterns);
|
||||
ConversionTarget target(getContext());
|
||||
target
|
||||
.addLegalDialect<arith::ArithmeticDialect, memref::MemRefDialect,
|
||||
scf::SCFDialect, StandardOpsDialect, VectorDialect>();
|
||||
target.addLegalDialect<arith::ArithmeticDialect, func::FuncDialect,
|
||||
memref::MemRefDialect, scf::SCFDialect,
|
||||
VectorDialect>();
|
||||
if (failed(applyPartialConversion(getOperation(), target,
|
||||
std::move(patterns))))
|
||||
signalPassFailure();
|
||||
|
|
|
@ -14,11 +14,11 @@ add_mlir_conversion_library(MLIRAffineToStandard
|
|||
MLIRAffine
|
||||
MLIRAffineUtils
|
||||
MLIRArithmetic
|
||||
MLIRFunc
|
||||
MLIRIR
|
||||
MLIRMemRef
|
||||
MLIRSCF
|
||||
MLIRPass
|
||||
MLIRStandard
|
||||
MLIRTransforms
|
||||
MLIRVector
|
||||
)
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
#include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/Async/IR/Async.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/Func/Transforms/FuncConversions.h"
|
||||
#include "mlir/Dialect/LLVMIR/FunctionCallUtils.h"
|
||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h"
|
||||
#include "mlir/IR/ImplicitLocOpBuilder.h"
|
||||
#include "mlir/IR/TypeUtilities.h"
|
||||
#include "mlir/Pass/Pass.h"
|
||||
|
@ -549,8 +549,8 @@ public:
|
|||
|
||||
// Tokens creation maps to a simple function call.
|
||||
if (resultType.isa<TokenType>()) {
|
||||
rewriter.replaceOpWithNewOp<CallOp>(op, kCreateToken,
|
||||
converter->convertType(resultType));
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(
|
||||
op, kCreateToken, converter->convertType(resultType));
|
||||
return success();
|
||||
}
|
||||
|
||||
|
@ -574,8 +574,8 @@ public:
|
|||
return rewriter.create<LLVM::PtrToIntOp>(loc, i64, gep);
|
||||
};
|
||||
|
||||
rewriter.replaceOpWithNewOp<CallOp>(op, kCreateValue, resultType,
|
||||
sizeOf(value));
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(op, kCreateValue, resultType,
|
||||
sizeOf(value));
|
||||
|
||||
return success();
|
||||
}
|
||||
|
@ -601,9 +601,9 @@ public:
|
|||
TypeConverter *converter = getTypeConverter();
|
||||
Type resultType = op.getResult().getType();
|
||||
|
||||
rewriter.replaceOpWithNewOp<CallOp>(op, kCreateGroup,
|
||||
converter->convertType(resultType),
|
||||
adaptor.getOperands());
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(
|
||||
op, kCreateGroup, converter->convertType(resultType),
|
||||
adaptor.getOperands());
|
||||
return success();
|
||||
}
|
||||
};
|
||||
|
@ -627,8 +627,8 @@ public:
|
|||
.Case<TokenType>([](Type) { return kEmplaceToken; })
|
||||
.Case<ValueType>([](Type) { return kEmplaceValue; });
|
||||
|
||||
rewriter.replaceOpWithNewOp<CallOp>(op, apiFuncName, TypeRange(),
|
||||
adaptor.getOperands());
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(op, apiFuncName, TypeRange(),
|
||||
adaptor.getOperands());
|
||||
|
||||
return success();
|
||||
}
|
||||
|
@ -653,8 +653,8 @@ public:
|
|||
.Case<TokenType>([](Type) { return kSetTokenError; })
|
||||
.Case<ValueType>([](Type) { return kSetValueError; });
|
||||
|
||||
rewriter.replaceOpWithNewOp<CallOp>(op, apiFuncName, TypeRange(),
|
||||
adaptor.getOperands());
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(op, apiFuncName, TypeRange(),
|
||||
adaptor.getOperands());
|
||||
|
||||
return success();
|
||||
}
|
||||
|
@ -679,8 +679,8 @@ public:
|
|||
.Case<GroupType>([](Type) { return kIsGroupError; })
|
||||
.Case<ValueType>([](Type) { return kIsValueError; });
|
||||
|
||||
rewriter.replaceOpWithNewOp<CallOp>(op, apiFuncName, rewriter.getI1Type(),
|
||||
adaptor.getOperands());
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(
|
||||
op, apiFuncName, rewriter.getI1Type(), adaptor.getOperands());
|
||||
return success();
|
||||
}
|
||||
};
|
||||
|
@ -704,8 +704,8 @@ public:
|
|||
.Case<ValueType>([](Type) { return kAwaitValue; })
|
||||
.Case<GroupType>([](Type) { return kAwaitGroup; });
|
||||
|
||||
rewriter.create<CallOp>(op->getLoc(), apiFuncName, TypeRange(),
|
||||
adaptor.getOperands());
|
||||
rewriter.create<func::CallOp>(op->getLoc(), apiFuncName, TypeRange(),
|
||||
adaptor.getOperands());
|
||||
rewriter.eraseOp(op);
|
||||
|
||||
return success();
|
||||
|
@ -741,8 +741,9 @@ public:
|
|||
auto resumePtr = rewriter.create<LLVM::AddressOfOp>(
|
||||
op->getLoc(), LLVM::LLVMPointerType::get(resumeFnTy), kResume);
|
||||
|
||||
rewriter.create<CallOp>(op->getLoc(), apiFuncName, TypeRange(),
|
||||
ValueRange({operand, handle, resumePtr.getRes()}));
|
||||
rewriter.create<func::CallOp>(
|
||||
op->getLoc(), apiFuncName, TypeRange(),
|
||||
ValueRange({operand, handle, resumePtr.getRes()}));
|
||||
rewriter.eraseOp(op);
|
||||
|
||||
return success();
|
||||
|
@ -770,7 +771,7 @@ public:
|
|||
|
||||
// Call async runtime API to execute a coroutine in the managed thread.
|
||||
auto coroHdl = adaptor.handle();
|
||||
rewriter.replaceOpWithNewOp<CallOp>(
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(
|
||||
op, TypeRange(), kExecute, ValueRange({coroHdl, resumePtr.getRes()}));
|
||||
|
||||
return success();
|
||||
|
@ -795,8 +796,8 @@ public:
|
|||
// Get a pointer to the async value storage from the runtime.
|
||||
auto i8Ptr = AsyncAPI::opaquePointerType(rewriter.getContext());
|
||||
auto storage = adaptor.storage();
|
||||
auto storagePtr = rewriter.create<CallOp>(loc, kGetValueStorage,
|
||||
TypeRange(i8Ptr), storage);
|
||||
auto storagePtr = rewriter.create<func::CallOp>(loc, kGetValueStorage,
|
||||
TypeRange(i8Ptr), storage);
|
||||
|
||||
// Cast from i8* to the LLVM pointer type.
|
||||
auto valueType = op.value().getType();
|
||||
|
@ -838,8 +839,8 @@ public:
|
|||
// Get a pointer to the async value storage from the runtime.
|
||||
auto i8Ptr = AsyncAPI::opaquePointerType(rewriter.getContext());
|
||||
auto storage = adaptor.storage();
|
||||
auto storagePtr = rewriter.create<CallOp>(loc, kGetValueStorage,
|
||||
TypeRange(i8Ptr), storage);
|
||||
auto storagePtr = rewriter.create<func::CallOp>(loc, kGetValueStorage,
|
||||
TypeRange(i8Ptr), storage);
|
||||
|
||||
// Cast from i8* to the LLVM pointer type.
|
||||
auto valueType = op.result().getType();
|
||||
|
@ -878,7 +879,7 @@ public:
|
|||
return rewriter.notifyMatchFailure(op, "only token type is supported");
|
||||
|
||||
// Replace with a runtime API function call.
|
||||
rewriter.replaceOpWithNewOp<CallOp>(
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(
|
||||
op, kAddTokenToGroup, rewriter.getI64Type(), adaptor.getOperands());
|
||||
|
||||
return success();
|
||||
|
@ -902,8 +903,8 @@ public:
|
|||
ConversionPatternRewriter &rewriter) const override {
|
||||
|
||||
// Replace with a runtime API function call.
|
||||
rewriter.replaceOpWithNewOp<CallOp>(op, kGetNumWorkerThreads,
|
||||
rewriter.getIndexType());
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(op, kGetNumWorkerThreads,
|
||||
rewriter.getIndexType());
|
||||
|
||||
return success();
|
||||
}
|
||||
|
@ -932,8 +933,8 @@ public:
|
|||
rewriter.getI64IntegerAttr(op.count()));
|
||||
|
||||
auto operand = adaptor.operand();
|
||||
rewriter.replaceOpWithNewOp<CallOp>(op, TypeRange(), apiFunctionName,
|
||||
ValueRange({operand, count}));
|
||||
rewriter.replaceOpWithNewOp<func::CallOp>(op, TypeRange(), apiFunctionName,
|
||||
ValueRange({operand, count}));
|
||||
|
||||
return success();
|
||||
}
|
||||
|
@ -961,14 +962,14 @@ public:
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
class ReturnOpOpConversion : public OpConversionPattern<ReturnOp> {
|
||||
class ReturnOpOpConversion : public OpConversionPattern<func::ReturnOp> {
|
||||
public:
|
||||
using OpConversionPattern::OpConversionPattern;
|
||||
|
||||
LogicalResult
|
||||
matchAndRewrite(ReturnOp op, OpAdaptor adaptor,
|
||||
matchAndRewrite(func::ReturnOp op, OpAdaptor adaptor,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
rewriter.replaceOpWithNewOp<ReturnOp>(op, adaptor.getOperands());
|
||||
rewriter.replaceOpWithNewOp<func::ReturnOp>(op, adaptor.getOperands());
|
||||
return success();
|
||||
}
|
||||
};
|
||||
|
@ -1032,8 +1033,8 @@ void ConvertAsyncToLLVMPass::runOnOperation() {
|
|||
converter, ctx);
|
||||
|
||||
ConversionTarget target(*ctx);
|
||||
target
|
||||
.addLegalOp<arith::ConstantOp, ConstantOp, UnrealizedConversionCastOp>();
|
||||
target.addLegalOp<arith::ConstantOp, func::ConstantOp,
|
||||
UnrealizedConversionCastOp>();
|
||||
target.addLegalDialect<LLVM::LLVMDialect>();
|
||||
|
||||
// All operations from Async dialect must be lowered to the runtime API and
|
||||
|
@ -1043,9 +1044,10 @@ void ConvertAsyncToLLVMPass::runOnOperation() {
|
|||
// Add dynamic legality constraints to apply conversions defined above.
|
||||
target.addDynamicallyLegalOp<FuncOp>(
|
||||
[&](FuncOp op) { return converter.isSignatureLegal(op.getType()); });
|
||||
target.addDynamicallyLegalOp<ReturnOp>(
|
||||
[&](ReturnOp op) { return converter.isLegal(op.getOperandTypes()); });
|
||||
target.addDynamicallyLegalOp<CallOp>([&](CallOp op) {
|
||||
target.addDynamicallyLegalOp<func::ReturnOp>([&](func::ReturnOp op) {
|
||||
return converter.isLegal(op.getOperandTypes());
|
||||
});
|
||||
target.addDynamicallyLegalOp<func::CallOp>([&](func::CallOp op) {
|
||||
return converter.isSignatureLegal(op.getCalleeType());
|
||||
});
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ add_mlir_conversion_library(MLIRAsyncToLLVM
|
|||
LINK_LIBS PUBLIC
|
||||
MLIRArithmetic
|
||||
MLIRAsync
|
||||
MLIRFuncTransforms
|
||||
MLIRLLVMCommonConversion
|
||||
MLIRLLVMIR
|
||||
MLIRStandardOpsTransforms
|
||||
MLIRStandardToLLVM
|
||||
MLIRTransforms
|
||||
)
|
||||
|
|
|
@ -12,8 +12,8 @@ add_mlir_conversion_library(MLIRComplexToLLVM
|
|||
|
||||
LINK_LIBS PUBLIC
|
||||
MLIRComplex
|
||||
MLIRFuncTransforms
|
||||
MLIRLLVMCommonConversion
|
||||
MLIRLLVMIR
|
||||
MLIRStandardOpsTransforms
|
||||
MLIRTransforms
|
||||
)
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "mlir/Conversion/LLVMCommon/Pattern.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/Complex/IR/Complex.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
|
||||
using namespace mlir;
|
||||
using namespace mlir::LLVM;
|
||||
|
|
|
@ -10,8 +10,8 @@ add_mlir_conversion_library(MLIRComplexToStandard
|
|||
LINK_LIBS PUBLIC
|
||||
MLIRArithmetic
|
||||
MLIRComplex
|
||||
MLIRFunc
|
||||
MLIRIR
|
||||
MLIRMath
|
||||
MLIRStandard
|
||||
MLIRTransforms
|
||||
)
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#include "../PassDetail.h"
|
||||
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
|
||||
#include "mlir/Dialect/Complex/IR/Complex.h"
|
||||
#include "mlir/Dialect/Func/IR/FuncOps.h"
|
||||
#include "mlir/Dialect/Math/IR/Math.h"
|
||||
#include "mlir/Dialect/StandardOps/IR/Ops.h"
|
||||
#include "mlir/IR/ImplicitLocOpBuilder.h"
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
#include "mlir/Transforms/DialectConversion.h"
|
||||
|
@ -652,7 +652,7 @@ void ConvertComplexToStandardPass::runOnOperation() {
|
|||
populateComplexToStandardConversionPatterns(patterns);
|
||||
|
||||
ConversionTarget target(getContext());
|
||||
target.addLegalDialect<arith::ArithmeticDialect, StandardOpsDialect,
|
||||
target.addLegalDialect<arith::ArithmeticDialect, func::FuncDialect,
|
||||
math::MathDialect>();
|
||||
target.addLegalOp<complex::CreateOp, complex::ImOp, complex::ReOp>();
|
||||
if (failed(applyPartialConversion(function, target, std::move(patterns))))
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue